@iframe-resizer/core 5.5.3-beta.6 → 5.5.3-beta.7
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 +1 -1
- package/index.cjs.js +2 -2
- package/index.esm.js +2 -2
- package/index.umd.js +2 -2
- package/package.json +1 -1
package/README.md
CHANGED
package/index.cjs.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
* @preserve
|
|
3
3
|
*
|
|
4
|
-
* @module iframe-resizer/core 5.5.3-beta.
|
|
4
|
+
* @module iframe-resizer/core 5.5.3-beta.7 (cjs) - 2025-08-19
|
|
5
5
|
*
|
|
6
6
|
* @license GPL-3.0 for non-commercial use only.
|
|
7
7
|
* For commercial use, you must purchase a license from
|
|
@@ -17,5 +17,5 @@
|
|
|
17
17
|
*/
|
|
18
18
|
|
|
19
19
|
|
|
20
|
-
"use strict";const e=require("auto-console-group"),i="5.5.3-beta.6",t="none",o="vertical",n="horizontal",r="[iFrameSizer]",s=Object.freeze({max:1,scroll:1,bodyScroll:1,documentElementScroll:1}),a="onload",l="init",c=Object.freeze({[a]:1,[l]:1}),d="expanded",u="collapsed",f=Object.freeze({[d]:1,[u]:1}),p=(e,i,t,o)=>e.addEventListener(i,t,o||!1),m=(e,i,t)=>e.removeEventListener(i,t,!1),h=e=>{if(!e)return"";let i=-559038744,t=1103547984;for(let o,n=0;n<e.length;n++)o=e.codePointAt(n),i=Math.imul(i^o,2246822519),t=Math.imul(t^o,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)},g=e=>e.replace(/[A-Za-z]/g,e=>String.fromCodePoint((e<="Z"?90:122)>=(e=e.codePointAt(0)+19)?e:e-26)),y=["spjluzl","rlf","clyzpvu"],b=["<yi>Puchspk Spjluzl Rlf</><iy><iy>","<yi>Tpzzpun Spjluzl Rlf</><iy><iy>","Aopz spiyhyf pz hchpshisl dpao ivao Jvttlyjphs huk Vwlu-Zvbyjl spjluzlz.<iy><iy><i>Jvttlyjphs Spjluzl</><iy>Mvy jvttlyjphs bzl, <p>pmyhtl-ylzpgly</> ylxbpylz h svd jvza vul aptl spjluzl mll. Mvy tvyl pumvythapvu cpzpa <b>oaawz://pmyhtl-ylzpgly.jvt/wypjpun</>.<iy><iy><i>Vwlu Zvbyjl Spjluzl</><iy>Pm fvb hyl bzpun aopz spiyhyf pu h uvu-jvttlyjphs vwlu zvbyjl wyvqlja aolu fvb jhu bzl pa mvy myll bukly aol alytz vm aol NWS C3 Spjluzl. Av jvumpyt fvb hjjlwa aolzl alytz, wslhzl zla aol <i>spjluzl</> rlf pu <p>pmyhtl-ylzpgly</> vwapvuz av <i>NWSc3</>.<iy><iy>Mvy tvyl pumvythapvu wslhzl zll: <b>oaawz://pmyhtl-ylzpgly.jvt/nws</>","<i>NWSc3 Spjluzl Clyzpvu</><iy><iy>Aopz clyzpvu vm <p>pmyhtl-ylzpgly</> pz ilpun bzlk bukly aol alytz vm aol <i>NWS C3</> spjluzl. Aopz spjluzl hssvdz fvb av bzl <p>pmyhtl-ylzpgly</> pu Vwlu Zvbyjl wyvqljaz, iba pa ylxbpylz fvby wyvqlja av il wbispj, wyvcpkl haaypibapvu huk il spjluzlk bukly clyzpvu 3 vy shaly vm aol NUB Nlulyhs Wbispj Spjluzl.<iy><iy>Pm fvb hyl bzpun aopz spiyhyf pu h uvu-vwlu zvbyjl wyvqlja vy dlizpal, fvb dpss ullk av wbyjohzl h svd jvza vul aptl jvttlyjphs spjluzl.<iy><iy>Mvy tvyl pumvythapvu cpzpa <b>oaawz://pmyhtl-ylzpgly.jvt/wypjpun</>.","<iy><yi>Zvsv spjluzl kvlz uva zbwwvya jyvzz-kvthpu</><iy><iy>Av bzl <p>pmyhtl-ylzpgly</> dpao jyvzz kvthpu pmyhtlz fvb ullk lpaoly aol Wyvmlzzpvuhs vy Ibzpulzz spjluzlz. Mvy klahpsz vu bwnyhkl wypjpun wslhzl jvuahja pumv@pmyhtl-ylzpgly.jvt."],v=["NWSc3","zvsv","wyv","ibzpulzz","vlt"],w=Object.fromEntries(["2cgs7fdf4xb","1c9ctcccr4z","1q2pc4eebgb","ueokt0969w","w2zxchhgqz","1umuxblj2e5"].map((e,i)=>[e,Math.max(0,i-1)])),z=e=>g(b[e]),H=e=>{const i=e[g(y[0])]||e[g(y[1])]||e[g(y[2])];if(!i)return-1;const t=i.split("-");let o=function(e=""){let i=-2;const t=h(g(e));return t in w&&(i=w[t]),i}(t[0]);return 0===o||(e=>e[2]===h(e[0]+e[1]))(t)||(o=-2),o},I=Object.hasOwn||((e,i)=>Object.prototype.hasOwnProperty.call(e,i)),$=e=>e,T=e=>i=>window.chrome?e(i.replaceAll("<br>","\n").replaceAll("<rb>","[31;1m").replaceAll("</>","[m").replaceAll("<b>","[1m").replaceAll("<i>","[3m").replaceAll("<u>","[4m")):e((e=>e.replaceAll("<br>","\n").replaceAll(/<[/a-z]+>/gi,""))(i)),j=(k=e,k?.__esModule?k.default:k);var k;let G={},O=!1;const R=e=>window.top===window.self?`parent(${e})`:`nested parent(${e})`;const L=e=>(i,...t)=>G[i]?.console[e](...t),x=(M="log",(e,...i)=>!0===(e=>G[e]?G[e].log:O)(e)?L(M)(e,...i):null);var M;const S=x,E=L("warn"),C=L("error"),A=L("event"),N=L("purge"),W=L("errorBoundary");const F=(e,...i)=>G[e]?G[e].console.warn(T($)(...i)):queueMicrotask(()=>console?.warn(T((e=>(...i)=>[`iframeResizer(${e})`,...i].join(" "))(e))(...i))),B=(e=>(i,t="renamed to")=>(o,n,r="",s="")=>e(s,`<rb>Deprecated ${i}(${o.replace("()","")})</>\n\nThe <b>${o}</> ${i.toLowerCase()} has been ${t} <b>${n}</>. ${r}Use of the old ${i.toLowerCase()} will be removed in a future version of <i>iframe-resizer</>.`))(F),P=B("Option");function D(e,i){const{msgTimeout:t,warningTimeout:o}=i[e];o&&(t&&clearTimeout(t),i[e].msgTimeout=setTimeout(function(){if(void 0===i[e])return;const{ready:t,loadErrorShown:o}=i[e];i[e].msgTimeout=void 0,t||o||(i[e].loadErrorShown=!0,function(e,i){const{iframe:t,waitForLoad:o}=i[e],{sandbox:n}=t,r="object"==typeof n&&n.length>0&&!(n.contains("allow-scripts")&&n.contains("allow-same-origin"));A(e,"noResponse"),F(e,`<rb>No response from iframe</>\n \nThe iframe (<i>${e}</>) has not responded within ${i[e].warningTimeout/1e3} seconds. Check <b>@iframe-resizer/child</> package has been loaded in the iframe.\n${o?"\nThe <b>waitForLoad</> option is currently set to <b>'true'</>. If the iframe loads before <i>iframe-resizer</> runs, this option will prevent <i>iframe-resizer</> initialising. To disable this option, set <b>waitForLoad</> to <b>'false'</>. \n":""}${r?"\nThe iframe has the <b>sandbox</> attribute, please ensure it contains both the <i>'allow-same-origin'</> and <i>'allow-scripts'</> values.\n":""}\nThis message can be ignored if everything is working, or you can set the <b>warningTimeout</> option to a higher value or zero to suppress this warning.\n`)}(e,i))},o))}const U={},q=Object.freeze({autoResize:!0,bodyBackground:null,bodyMargin:null,bodyPadding:null,checkOrigin:!0,direction:o,inPageLinks:!1,heightCalculationMethod:"auto",id:"iFrameResizer",log:!1,logExpand:!1,license:void 0,mouseEvents:!0,offsetHeight:null,offsetWidth:null,postMessageTarget:null,sameDomain:!1,scrolling:!1,sizeHeight:!0,sizeWidth:!1,tolerance:0,waitForLoad:!1,warningTimeout:5e3,widthCalculationMethod:"auto",onBeforeClose:()=>!0,onAfterClose(){},onInit:!1,onMessage:null,onMouseEnter(){},onMouseLeave(){},onReady:e=>{"function"==typeof U[e.id].onInit&&(P("init()","onReady()","",e.id),U[e.id].onInit(e))},onResized(){},onScroll:()=>!0}),J={position:null,version:i};function V(t){function o(){ie(k),Q(G),I("onResized",k)}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 s(e){if("border-box"!==e.boxSizing)return 0;return(e.borderTopWidth?parseInt(e.borderTopWidth,10):0)+(e.borderBottomWidth?parseInt(e.borderBottomWidth,10):0)}const a=e=>j.slice(j.indexOf(":")+7+e);const l=(e,i)=>(t,o)=>{const n={};var r,s;r=function(){oe(`${t} (${e})`,`${e}:${i()}`,o)},n[s=o]||(r(),n[s]=requestAnimationFrame(()=>{n[s]=null}))},c=(e,i)=>()=>{let t=!1;const o=i=>()=>{U[l]?t&&t!==i||(e(i,l),t=i,requestAnimationFrame(()=>{t=!1})):a()},n=o("scroll"),r=o("resize window");function s(e,t){x(l,`${e}listeners for send${i}`),t(window,"scroll",n),t(window,"resize",r)}function a(){A(l,`stop${i}`),s("Remove ",m),c.disconnect(),d.disconnect(),m(U[l].iframe,"load",a)}const l=G,c=new ResizeObserver(o("pageObserver")),d=new ResizeObserver(o("iframeObserver"));U[l]&&(U[l][`stop${i}`]=a,p(U[l].iframe,"load",a),s("Add ",p),c.observe(document.body,{attributes:!0,childList:!0,subtree:!0}),d.observe(U[l].iframe,{attributes:!0,childList:!1,subtree:!1}))},d=e=>()=>{e in U[G]&&(U[G][e](),delete U[G][e])},u=l("pageInfo",function(){const e=document.body.getBoundingClientRect(),i=k.iframe.getBoundingClientRect(),{scrollY:t,scrollX:o,innerHeight:n,innerWidth:r}=window,{clientHeight:s,clientWidth:a}=document.documentElement;return JSON.stringify({iframeHeight:i.height,iframeWidth:i.width,clientHeight:Math.max(s,n||0),clientWidth:Math.max(a,r||0),offsetTop:parseInt(i.top-e.top,10),offsetLeft:parseInt(i.left-e.left,10),scrollTop:t,scrollLeft:o,documentHeight:s,documentWidth:a,windowHeight:n,windowWidth:r})}),f=l("parentInfo",function(){const{iframe:e}=k,{scrollWidth:i,scrollHeight:t}=document.documentElement,{width:o,height:n,offsetLeft:r,offsetTop:s,pageLeft:a,pageTop:l,scale:c}=window.visualViewport;return JSON.stringify({iframe:e.getBoundingClientRect(),document:{scrollWidth:i,scrollHeight:t},viewport:{width:o,height:n,offsetLeft:r,offsetTop:s,pageLeft:a,pageTop:l,scale:c}})}),h=c(u,"PageInfo"),g=c(f,"ParentInfo"),y=d("stopPageInfo"),b=d("stopParentInfo");function v(e){const i=e.getBoundingClientRect();return _(G),{x:Number(i.left)+Number(J.position.x),y:Number(i.top)+Number(J.position.y)}}function w(i){const t=i?v(k.iframe):{x:0,y:0};S(G,`Reposition requested (offset x:%c${t.x}%c y:%c${t.y})`,e.HIGHLIGHT,e.FOREGROUND,e.HIGHLIGHT);const o=((e,i)=>({x:e.width+i.x,y:e.height+i.y}))(k,t),n=window.parentIframe||window.parentIFrame;n?function(e,t){e["scrollTo"+(i?"Offset":"")](t.x,t.y)}(n,o):function(e){J.position=e,z(G)}(o)}function z(e){const{x:i,y:t}=J.position,o=U[e]?.iframe;!1!==I("onScroll",{iframe:o,top:t,left:i,x:i,y:t})?Q(e):K()}function H(e){let i={};if(0===k.width&&0===k.height){const e=a(9).split(":");i={x:e[1],y:e[0]}}else i={x:k.width,y:k.height};I(e,{iframe:k.iframe,screenX:Number(i.x),screenY:Number(i.y),type:k.type})}const I=(e,i)=>Z(G,e,i);function $(){const{height:t,iframe:n,msg:r,type:s,width:l}=k;switch(U[G]?.firstRun&&function(){if(!U[G])return;ce(G,k.mode),U[G].firstRun=!1}(),s){case"close":Y(n);break;case"message":d=a(6),x(G,`onMessage passed: {iframe: %c${k.iframe.id}%c, message: %c${d}%c}`,e.HIGHLIGHT,e.FOREGROUND,e.HIGHLIGHT,e.FOREGROUND),I("onMessage",{iframe:k.iframe,message:JSON.parse(d)});break;case"mouseenter":H("onMouseEnter");break;case"mouseleave":H("onMouseLeave");break;case"autoResize":U[G].autoResize=JSON.parse(a(9));break;case"scrollBy":!function(){const i=k.width,t=k.height,o=window.parentIframe||window.parentIFrame||window;S(G,`scrollBy: x: %c${i}%c y: %c${t}`,e.HIGHLIGHT,e.FOREGROUND,e.HIGHLIGHT),o.scrollBy(i,t)}();break;case"scrollTo":w(!1);break;case"scrollToOffset":w(!0);break;case"pageInfo":h();break;case"parentInfo":g();break;case"pageInfoStop":y();break;case"parentInfoStop":b();break;case"inPageLink":!function(i){const t=i.split("#")[1]||"",o=decodeURIComponent(t);let n=document.getElementById(o)||document.getElementsByName(o)[0];n?function(){const i=v(n);S(G,`Moving to in page link: %c#${t}`,e.HIGHLIGHT),J.position={x:i.x,y:i.y},z(G),window.location.hash=t}():window.top!==window.self?function(){const e=window.parentIframe||window.parentIFrame;e?e.moveToAnchor(t):x(G,`In page link #${t} not found and window.parentIframe not found`)}():x(G,`In page link #${t} not found`)}(a(9));break;case"title":!function(i,t){U[t]?.syncTitle&&(U[t].iframe.title=i,S(t,`Set iframe title attribute: %c${i}`,e.HIGHLIGHT))}(r,G);break;case"reset":ee(k);break;case"init":o(),function(i){try{U[i].sameOrigin=!!U[i]?.iframe?.contentWindow?.iframeChildListener}catch(e){U[i].sameOrigin=!1}x(i,`sameOrigin: %c${U[i].sameOrigin}`,e.HIGHLIGHT)}(G),(c=r)!==i&&(void 0!==c?x(G,`Version mismatch (Child: %c${c}%c !== Parent: %c${i})`,e.HIGHLIGHT,e.FOREGROUND,e.HIGHLIGHT):F(G,"<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")),se=!0,I("onReady",n);break;default:if(0===l&&0===t)return void E(G,`Unsupported message received (${s}), this is likely due to the iframe containing a later version of iframe-resizer than the parent page`);if(0===l||0===t)return void x(G,"Ignoring message with 0 height or width");if(document.hidden)return void x(G,"Page hidden - ignored resize request");o()}var c,d}function T(e){U[e].loaded||(oe("iframe requested init",ne(e),e),D(e,U))}let j=t.data,k={},G=null;"[iFrameResizerChild]Ready"!==j?r===`${j}`.slice(0,13)&&j.slice(13).split(":")[0]in U?(k=function(){const e=j.slice(13).split(":"),i=e[1]?Number(e[1]):0,t=U[e[0]]?.iframe,o=getComputedStyle(t),r={iframe:t,id:e[0],height:i+n(o)+s(o),width:Number(e[2]),type:e[3],msg:e[4]};return e[5]&&(r.mode=e[5]),r}(),G=k.id,G?(A(G,k.type),W(G,function(){!function(e){if(!U[e])throw new Error(`${k.type} No settings for ${e}. Message was: ${j}`)}(G),function(){const e=k.type in{true:1,false:1,undefined:1};return e&&x(G,"Ignoring init message from meta parent page"),e}()||(x(G,`Received: %c${j}`,e.HIGHLIGHT),U[G].loaded=!0,U[G].ready=!0,(null!==k.iframe||(E(G,`The iframe (${k.id}) was not found.`),0))&&function(){const{origin:i,sameOrigin:o}=t;if(o)return!0;let n=U[G]?.checkOrigin;if(n&&"null"!=`${i}`&&!(n.constructor===Array?function(){let t=0,o=!1;for(x(G,`Checking connection is from allowed list of origins: %c${n}`,e.HIGHLIGHT);t<n.length;t++)if(n[t]===i){o=!0;break}return o}():function(){const t=U[G]?.remoteHost;return x(G,`Checking connection is from: %c${t}`,e.HIGHLIGHT),i===t}()))throw new Error(`Unexpected message received from: ${i} for ${k.iframe.id}. Message was: ${t.data}. This error can be disabled by setting the checkOrigin: false option or by providing of array of trusted domains.`);return!0}()&&$())})()):E("","iframeResizer received messageData without id, message was: ",j)):null!==G&&x(G,"Ignored:",j):Object.keys(U).forEach(T)}function Z(e,i,t){let o=null,n=null;if(U[e]){if(o=U[e][i],"function"!=typeof o)throw new TypeError(`${i} on iFrame[${e}] is not a function`);if("onBeforeClose"===i||"onScroll"===i)try{n=o(t)}catch(t){console.error(t),E(e,`Error in ${i} callback`)}else((e,...i)=>{setTimeout(()=>e(...i),0)})(o,t)}return n}function X(e){const{id:i}=e;x(i,"Disconnected from iframe"),delete U[i],delete e.iframeResizer}function Y(i){const{id:t}=i;if(!1!==Z(t,"onBeforeClose",t)){x(t,`Removing iFrame: %c${t}`,e.HIGHLIGHT);try{i.parentNode&&i.remove()}catch(e){E(t,e)}Z(t,"onAfterClose",t),X(i)}else x(t,"Close iframe cancelled by onBeforeClose")}function _(i){null===J.position&&(J.position={x:window.scrollX,y:window.scrollY},x(i,`Get page position: %c${J.position.x}%c, %c${J.position.y}`,e.HIGHLIGHT,e.FOREGROUND,e.HIGHLIGHT))}function K(){J.position=null}function Q(i){null!==J.position&&(window.scrollTo(J.position.x,J.position.y),S(i,`Set page position: %c${J.position.x}%c, %c${J.position.y}`,e.HIGHLIGHT,e.FOREGROUND,e.HIGHLIGHT),K())}function ee(e){x(e.id,"Size reset requested by "+("init"===e.type?"parent page":"child page")),_(e.id),ie(e),oe("reset","reset",e.id)}function ie(i){function t(t){const n=`${i[t]}px`;i.iframe.style[t]=n,S(o,`Set ${t}: %c${n}`,e.HIGHLIGHT)}const{id:o}=i,{sizeHeight:n,sizeWidth:r}=U[o];n&&t("height"),r&&t("width")}G=U;const te=e=>e.split(":").filter((e,i)=>19!==i).join(":");function oe(i,t,o){function n(n){const r=i in c?te(t):t;S(o,n,e.HIGHLIGHT,e.FOREGROUND,e.HIGHLIGHT),S(o,`Message data: %c${r}`,e.HIGHLIGHT)}A(o,i),U[o]&&(U[o]?.postMessageTarget?function(){const{iframe:e,postMessageTarget:i,sameOrigin:s,targetOrigin:a}=U[o];if(s)try{return e.contentWindow.iframeChildListener(r+t),void n(`Sending message to iframe %c${o}%c via sameOrigin`)}catch(e){x(o,"Same domain connection failed. Trying cross domain%c")}n(`Sending message to iframe: %c${o}%c targetOrigin: %c${a}`),i.postMessage(r+t,a)}():E(o,`Iframe(${o}) not found`))}function ne(e){const i=U[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,"",i.logExpand].join(":")}let re=0,se=!1,ae=!1,le=!1;function ce(t,o=-3){if(ae)return;const n=Math.max(U[t].mode,o);if(n>U[t].mode&&(U[t].mode=n),n<0)throw N(t),U[t].vAdvised||F(t||"Parent",`${z(n+2)}${z(2)}`),U[t].vAdvised=!0,z(n+2).replace(/<\/?[a-z][^>]*>|<\/>/gi,"");n>-1&&le||function(i,t){queueMicrotask(()=>console.info(`%ciframe-resizer ${i}`,O||t<1?"font-weight: bold;":e.NORMAL))}(`v${i} (${(e=>g(v[e]))(n)})`,n),n<1&&F("Parent",z(3)),ae=!0}function de(){!1===document.hidden&&(x("document","Trigger event: Visibility change"),function(e,i){const t=e=>U[e]?.autoResize&&!U[e]?.firstRun;Object.keys(U).forEach(function(o){t(o)&&oe(e,i,o)})}("tabVisible","resize"))}const ue=(e=>{let i=!1;return function(){return i?void 0:(i=!0,Reflect.apply(e,this,arguments))}})(()=>{p(window,"message",V),p(document,"visibilitychange",de),window.iframeParentListener=e=>setTimeout(()=>V({data:e,sameOrigin:!0}))});module.exports=i=>r=>{function c(){if(U[w]){const{iframe:e}=U[w],i={close:Y.bind(null,e),disconnect:X.bind(null,e),removeListeners(){F(w,"<rb>Deprecated Method Name</>\n\nThe [removeListeners()</> method has been renamed to [disconnect()</>.\n"),this.disconnect()},resize(){F(w,"<rb>Deprecated Method</>\n \nUse of the <b>resize()</> method from the parent page is deprecated and will be removed in a future version of <i>iframe-resizer</>. As their are no longer any edge cases that require triggering a resize from the parent page, it is recommended to remove this method from your code."),oe.bind(null,"Window resize","resize",w)},moveToAnchor(e){((e,i,t)=>{if(typeof e!==i)throw new TypeError(`${t} is not a ${o=i,o.charAt(0).toUpperCase()+o.slice(1)}`);var o})(e,"string","moveToAnchor(anchor) anchor"),oe("Move to anchor",`moveToAnchor:${e}`,w)},sendMessage(e){oe("message",`message:${e=JSON.stringify(e)}`,w)}};e.iframeResizer=i,e.iFrameResizer=i}}function u(e){const{id:i}=r,{waitForLoad:t}=U[i];p(r,"load",function(){oe(a,`${e}:${se}`,i),U[i].loaded=!0,D(i,U),function(){const e=U[w]?.firstRun,i=U[w]?.heightCalculationMethod in s;!e&&i&&ee({iframe:r,height:0,width:0,type:"init"})}()}),!0!==t&&(oe(l,`${e}:${se}`,i),D(i,U))}function m(e){return e?(("sizeWidth"in e||"sizeHeight"in e||"autoResize"in e)&&F(w,`<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>"${o}"</>, <i>"${n}"</> or <i>"${t}"</>.\n`),e):{}}function h(e){const i=U[e]?.iframe?.title;return""===i||void 0===i}function g(e,i){I(U[w],e)&&(F(w,`<rb>Deprecated option</>\n\nThe <b>${e}</> option has been renamed to <b>${i}</>. Use of the old name will be removed in a future version of <i>iframe-resizer</>.`),U[w][i]=U[w][e],delete U[w][e])}const y=e=>I(e,"onMouseEnter")||I(e,"onMouseLeave");function b(i){var s,a;U[w]={...U[w],iframe:r,firstRun:!0,remoteHost:r?.src.split("/").slice(0,3).join("/"),...q,...m(i),mouseEvents:y(i),mode:H(i),syncTitle:h(w)},g("offset","offsetSize"),g("onClose","onBeforeClose"),g("onClosed","onAfterClose"),A(w,"setup"),function(){const{direction:i}=U[w];switch(i){case o:break;case n:U[w].sizeHeight=!1;case"both":U[w].sizeWidth=!0;break;case t:U[w].sizeWidth=!1,U[w].sizeHeight=!1,U[w].autoResize=!1;break;default:throw new TypeError(w,`Direction value of "${i}" is not valid`)}x(w,`direction: %c${i}`,e.HIGHLIGHT)}(),(s=i?.offsetSize||i?.offset)&&(U[w].direction===o?(U[w].offsetHeight=s,x(w,`Offset height: %c${s}`,e.HIGHLIGHT)):(U[w].offsetWidth=s,x(w,`Offset width: %c${s}`,e.HIGHLIGHT))),function(e){e?.offset&&F(w,"<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</>.")}(i),U[w].warningTimeout||S(w,"warningTimeout:%c disabled",e.HIGHLIGHT),null===U[w].postMessageTarget&&(U[w].postMessageTarget=r.contentWindow),U[w].targetOrigin=!0===U[w].checkOrigin?""===(a=U[w].remoteHost)||null!==a.match(/^(about:blank|javascript:|file:\/\/)/)?"*":a:"*"}const v=()=>"iframeResizer"in r,w=function(e){if(e&&"string"!=typeof e)throw new TypeError("Invalid id for iFrame. Expected String");return""!==e&&e||(e=function(){let e=i?.id||q.id+re++;return null!==document.getElementById(e)&&(e+=re++),e}(),r.id=e,x(e,`Added missing iframe ID: ${e} (${r.src})`)),e}(r.id);if("object"!=typeof i)throw new TypeError("Options is not an object");return function(e){const{search:i}=window.location;i.includes("ifrlog")&&(e.log=d,e.logExpand=!i.includes("ifrlog=collapsed"))}(i),function(e,i){const t=I(i,"log"),o="string"==typeof i.log,n=t?!!o||i.log:q.log;I(i,"logExpand")||(i.logExpand=t&&o?i.log===d:q.logExpand),function(e){-1===e?.log&&(e.log=!1,le=!0)}(i),function({enabled:e,expand:i,iframeId:t}){const o=j({expand:i,label:R(t)});O=e,G[t]||(G[t]={console:o})}({enabled:n,expand:i.logExpand,iframeId:e}),o&&!(i.log in f)&&C(e,'Invalid value for options.log: Accepted values are "expanded" and "collapsed"'),i.log=n}(w,i),W(w,function(e){v()?E(w,`Ignored iframe (${w}), already setup.`):(b(e),function(){if(ae)return;const{mode:e}=U[w];-1!==e&&ce(w,e)}(),ue(),function(){switch(x(w,`Iframe scrolling ${U[w]?.scrolling?"enabled":"disabled"} for ${w}`),r.style.overflow=!1===U[w]?.scrolling?"hidden":"auto",U[w]?.scrolling){case"omit":break;case!0:r.scrolling="yes";break;case!1:r.scrolling="no";break;default:r.scrolling=U[w]?U[w].scrolling:"no"}}(),function(){const{bodyMargin:e}=U[w];"number"!=typeof e&&"0"!==e||(U[w].bodyMargin=`${e}px`)}(),u(ne(w)),c(),x(w,"Setup complete"))})(i),r?.iframeResizer};
|
|
20
|
+
"use strict";const e=require("auto-console-group"),i="5.5.3-beta.7",t="none",o="vertical",n="horizontal",r="[iFrameSizer]",s=Object.freeze({max:1,scroll:1,bodyScroll:1,documentElementScroll:1}),a="onload",l="init",c=Object.freeze({[a]:1,[l]:1}),d="expanded",u="collapsed",f=Object.freeze({[d]:1,[u]:1}),p=(e,i,t,o)=>e.addEventListener(i,t,o||!1),m=(e,i,t)=>e.removeEventListener(i,t,!1),h=e=>{if(!e)return"";let i=-559038744,t=1103547984;for(let o,n=0;n<e.length;n++)o=e.codePointAt(n),i=Math.imul(i^o,2246822519),t=Math.imul(t^o,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)},g=e=>e.replace(/[A-Za-z]/g,e=>String.fromCodePoint((e<="Z"?90:122)>=(e=e.codePointAt(0)+19)?e:e-26)),y=["spjluzl","rlf","clyzpvu"],b=["<yi>Puchspk Spjluzl Rlf</><iy><iy>","<yi>Tpzzpun Spjluzl Rlf</><iy><iy>","Aopz spiyhyf pz hchpshisl dpao ivao Jvttlyjphs huk Vwlu-Zvbyjl spjluzlz.<iy><iy><i>Jvttlyjphs Spjluzl</><iy>Mvy jvttlyjphs bzl, <p>pmyhtl-ylzpgly</> ylxbpylz h svd jvza vul aptl spjluzl mll. Mvy tvyl pumvythapvu cpzpa <b>oaawz://pmyhtl-ylzpgly.jvt/wypjpun</>.<iy><iy><i>Vwlu Zvbyjl Spjluzl</><iy>Pm fvb hyl bzpun aopz spiyhyf pu h uvu-jvttlyjphs vwlu zvbyjl wyvqlja aolu fvb jhu bzl pa mvy myll bukly aol alytz vm aol NWS C3 Spjluzl. Av jvumpyt fvb hjjlwa aolzl alytz, wslhzl zla aol <i>spjluzl</> rlf pu <p>pmyhtl-ylzpgly</> vwapvuz av <i>NWSc3</>.<iy><iy>Mvy tvyl pumvythapvu wslhzl zll: <b>oaawz://pmyhtl-ylzpgly.jvt/nws</>","<i>NWSc3 Spjluzl Clyzpvu</><iy><iy>Aopz clyzpvu vm <p>pmyhtl-ylzpgly</> pz ilpun bzlk bukly aol alytz vm aol <i>NWS C3</> spjluzl. Aopz spjluzl hssvdz fvb av bzl <p>pmyhtl-ylzpgly</> pu Vwlu Zvbyjl wyvqljaz, iba pa ylxbpylz fvby wyvqlja av il wbispj, wyvcpkl haaypibapvu huk il spjluzlk bukly clyzpvu 3 vy shaly vm aol NUB Nlulyhs Wbispj Spjluzl.<iy><iy>Pm fvb hyl bzpun aopz spiyhyf pu h uvu-vwlu zvbyjl wyvqlja vy dlizpal, fvb dpss ullk av wbyjohzl h svd jvza vul aptl jvttlyjphs spjluzl.<iy><iy>Mvy tvyl pumvythapvu cpzpa <b>oaawz://pmyhtl-ylzpgly.jvt/wypjpun</>.","<iy><yi>Zvsv spjluzl kvlz uva zbwwvya jyvzz-kvthpu</><iy><iy>Av bzl <p>pmyhtl-ylzpgly</> dpao jyvzz kvthpu pmyhtlz fvb ullk lpaoly aol Wyvmlzzpvuhs vy Ibzpulzz spjluzlz. Mvy klahpsz vu bwnyhkl wypjpun wslhzl jvuahja pumv@pmyhtl-ylzpgly.jvt."],v=["NWSc3","zvsv","wyv","ibzpulzz","vlt"],w=Object.fromEntries(["2cgs7fdf4xb","1c9ctcccr4z","1q2pc4eebgb","ueokt0969w","w2zxchhgqz","1umuxblj2e5"].map((e,i)=>[e,Math.max(0,i-1)])),z=e=>g(b[e]),H=e=>{const i=e[g(y[0])]||e[g(y[1])]||e[g(y[2])];if(!i)return-1;const t=i.split("-");let o=function(e=""){let i=-2;const t=h(g(e));return t in w&&(i=w[t]),i}(t[0]);return 0===o||(e=>e[2]===h(e[0]+e[1]))(t)||(o=-2),o},I=Object.hasOwn||((e,i)=>Object.prototype.hasOwnProperty.call(e,i)),$=e=>e,T=e=>i=>window.chrome?e(i.replaceAll("<br>","\n").replaceAll("<rb>","[31;1m").replaceAll("</>","[m").replaceAll("<b>","[1m").replaceAll("<i>","[3m").replaceAll("<u>","[4m")):e((e=>e.replaceAll("<br>","\n").replaceAll(/<[/a-z]+>/gi,""))(i)),j=(k=e,k?.__esModule?k.default:k);var k;let G={},O=!1;const R=e=>window.top===window.self?`parent(${e})`:`nested parent(${e})`;const L=e=>(i,...t)=>G[i]?.console[e](...t),x=(M="log",(e,...i)=>!0===(e=>G[e]?G[e].log:O)(e)?L(M)(e,...i):null);var M;const S=x,E=L("warn"),C=L("error"),A=L("event"),N=L("purge"),W=L("errorBoundary");const F=(e,...i)=>G[e]?G[e].console.warn(T($)(...i)):queueMicrotask(()=>console?.warn(T((e=>(...i)=>[`iframeResizer(${e})`,...i].join(" "))(e))(...i))),B=(e=>(i,t="renamed to")=>(o,n,r="",s="")=>e(s,`<rb>Deprecated ${i}(${o.replace("()","")})</>\n\nThe <b>${o}</> ${i.toLowerCase()} has been ${t} <b>${n}</>. ${r}Use of the old ${i.toLowerCase()} will be removed in a future version of <i>iframe-resizer</>.`))(F),P=B("Option");function D(e,i){const{msgTimeout:t,warningTimeout:o}=i[e];o&&(t&&clearTimeout(t),i[e].msgTimeout=setTimeout(function(){if(void 0===i[e])return;const{ready:t,loadErrorShown:o}=i[e];i[e].msgTimeout=void 0,t||o||(i[e].loadErrorShown=!0,function(e,i){const{iframe:t,waitForLoad:o}=i[e],{sandbox:n}=t,r="object"==typeof n&&n.length>0&&!(n.contains("allow-scripts")&&n.contains("allow-same-origin"));A(e,"noResponse"),F(e,`<rb>No response from iframe</>\n \nThe iframe (<i>${e}</>) has not responded within ${i[e].warningTimeout/1e3} seconds. Check <b>@iframe-resizer/child</> package has been loaded in the iframe.\n${o?"\nThe <b>waitForLoad</> option is currently set to <b>'true'</>. If the iframe loads before <i>iframe-resizer</> runs, this option will prevent <i>iframe-resizer</> initialising. To disable this option, set <b>waitForLoad</> to <b>'false'</>. \n":""}${r?"\nThe iframe has the <b>sandbox</> attribute, please ensure it contains both the <i>'allow-same-origin'</> and <i>'allow-scripts'</> values.\n":""}\nThis message can be ignored if everything is working, or you can set the <b>warningTimeout</> option to a higher value or zero to suppress this warning.\n`)}(e,i))},o))}const U={},q=Object.freeze({autoResize:!0,bodyBackground:null,bodyMargin:null,bodyPadding:null,checkOrigin:!0,direction:o,inPageLinks:!1,heightCalculationMethod:"auto",id:"iFrameResizer",log:!1,logExpand:!1,license:void 0,mouseEvents:!0,offsetHeight:null,offsetWidth:null,postMessageTarget:null,sameDomain:!1,scrolling:!1,sizeHeight:!0,sizeWidth:!1,tolerance:0,waitForLoad:!1,warningTimeout:5e3,widthCalculationMethod:"auto",onBeforeClose:()=>!0,onAfterClose(){},onInit:!1,onMessage:null,onMouseEnter(){},onMouseLeave(){},onReady:e=>{"function"==typeof U[e.id].onInit&&(P("init()","onReady()","",e.id),U[e.id].onInit(e))},onResized(){},onScroll:()=>!0}),J={position:null,version:i};function V(t){function o(){ie(k),Q(G),I("onResized",k)}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 s(e){if("border-box"!==e.boxSizing)return 0;return(e.borderTopWidth?parseInt(e.borderTopWidth,10):0)+(e.borderBottomWidth?parseInt(e.borderBottomWidth,10):0)}const a=e=>j.slice(j.indexOf(":")+7+e);const l=(e,i)=>(t,o)=>{const n={};var r,s;r=function(){oe(`${t} (${e})`,`${e}:${i()}`,o)},n[s=o]||(r(),n[s]=requestAnimationFrame(()=>{n[s]=null}))},c=(e,i)=>()=>{let t=!1;const o=i=>()=>{U[l]?t&&t!==i||(e(i,l),t=i,requestAnimationFrame(()=>{t=!1})):a()},n=o("scroll"),r=o("resize window");function s(e,t){x(l,`${e}listeners for send${i}`),t(window,"scroll",n),t(window,"resize",r)}function a(){A(l,`stop${i}`),s("Remove ",m),c.disconnect(),d.disconnect(),m(U[l].iframe,"load",a)}const l=G,c=new ResizeObserver(o("pageObserver")),d=new ResizeObserver(o("iframeObserver"));U[l]&&(U[l][`stop${i}`]=a,p(U[l].iframe,"load",a),s("Add ",p),c.observe(document.body,{attributes:!0,childList:!0,subtree:!0}),d.observe(U[l].iframe,{attributes:!0,childList:!1,subtree:!1}))},d=e=>()=>{e in U[G]&&(U[G][e](),delete U[G][e])},u=l("pageInfo",function(){const e=document.body.getBoundingClientRect(),i=k.iframe.getBoundingClientRect(),{scrollY:t,scrollX:o,innerHeight:n,innerWidth:r}=window,{clientHeight:s,clientWidth:a}=document.documentElement;return JSON.stringify({iframeHeight:i.height,iframeWidth:i.width,clientHeight:Math.max(s,n||0),clientWidth:Math.max(a,r||0),offsetTop:parseInt(i.top-e.top,10),offsetLeft:parseInt(i.left-e.left,10),scrollTop:t,scrollLeft:o,documentHeight:s,documentWidth:a,windowHeight:n,windowWidth:r})}),f=l("parentInfo",function(){const{iframe:e}=k,{scrollWidth:i,scrollHeight:t}=document.documentElement,{width:o,height:n,offsetLeft:r,offsetTop:s,pageLeft:a,pageTop:l,scale:c}=window.visualViewport;return JSON.stringify({iframe:e.getBoundingClientRect(),document:{scrollWidth:i,scrollHeight:t},viewport:{width:o,height:n,offsetLeft:r,offsetTop:s,pageLeft:a,pageTop:l,scale:c}})}),h=c(u,"PageInfo"),g=c(f,"ParentInfo"),y=d("stopPageInfo"),b=d("stopParentInfo");function v(e){const i=e.getBoundingClientRect();return _(G),{x:Number(i.left)+Number(J.position.x),y:Number(i.top)+Number(J.position.y)}}function w(i){const t=i?v(k.iframe):{x:0,y:0};S(G,`Reposition requested (offset x:%c${t.x}%c y:%c${t.y})`,e.HIGHLIGHT,e.FOREGROUND,e.HIGHLIGHT);const o=((e,i)=>({x:e.width+i.x,y:e.height+i.y}))(k,t),n=window.parentIframe||window.parentIFrame;n?function(e,t){e["scrollTo"+(i?"Offset":"")](t.x,t.y)}(n,o):function(e){J.position=e,z(G)}(o)}function z(e){const{x:i,y:t}=J.position,o=U[e]?.iframe;!1!==I("onScroll",{iframe:o,top:t,left:i,x:i,y:t})?Q(e):K()}function H(e){let i={};if(0===k.width&&0===k.height){const e=a(9).split(":");i={x:e[1],y:e[0]}}else i={x:k.width,y:k.height};I(e,{iframe:k.iframe,screenX:Number(i.x),screenY:Number(i.y),type:k.type})}const I=(e,i)=>Z(G,e,i);function $(){const{height:t,iframe:n,msg:r,type:s,width:l}=k;switch(U[G]?.firstRun&&function(){if(!U[G])return;ce(G,k.mode),U[G].firstRun=!1}(),s){case"close":Y(n);break;case"message":d=a(6),x(G,`onMessage passed: {iframe: %c${k.iframe.id}%c, message: %c${d}%c}`,e.HIGHLIGHT,e.FOREGROUND,e.HIGHLIGHT,e.FOREGROUND),I("onMessage",{iframe:k.iframe,message:JSON.parse(d)});break;case"mouseenter":H("onMouseEnter");break;case"mouseleave":H("onMouseLeave");break;case"autoResize":U[G].autoResize=JSON.parse(a(9));break;case"scrollBy":!function(){const i=k.width,t=k.height,o=window.parentIframe||window.parentIFrame||window;S(G,`scrollBy: x: %c${i}%c y: %c${t}`,e.HIGHLIGHT,e.FOREGROUND,e.HIGHLIGHT),o.scrollBy(i,t)}();break;case"scrollTo":w(!1);break;case"scrollToOffset":w(!0);break;case"pageInfo":h();break;case"parentInfo":g();break;case"pageInfoStop":y();break;case"parentInfoStop":b();break;case"inPageLink":!function(i){const t=i.split("#")[1]||"",o=decodeURIComponent(t);let n=document.getElementById(o)||document.getElementsByName(o)[0];n?function(){const i=v(n);S(G,`Moving to in page link: %c#${t}`,e.HIGHLIGHT),J.position={x:i.x,y:i.y},z(G),window.location.hash=t}():window.top!==window.self?function(){const e=window.parentIframe||window.parentIFrame;e?e.moveToAnchor(t):x(G,`In page link #${t} not found and window.parentIframe not found`)}():x(G,`In page link #${t} not found`)}(a(9));break;case"title":!function(i,t){U[t]?.syncTitle&&(U[t].iframe.title=i,S(t,`Set iframe title attribute: %c${i}`,e.HIGHLIGHT))}(r,G);break;case"reset":ee(k);break;case"init":o(),function(i){try{U[i].sameOrigin=!!U[i]?.iframe?.contentWindow?.iframeChildListener}catch(e){U[i].sameOrigin=!1}x(i,`sameOrigin: %c${U[i].sameOrigin}`,e.HIGHLIGHT)}(G),(c=r)!==i&&(void 0!==c?x(G,`Version mismatch (Child: %c${c}%c !== Parent: %c${i})`,e.HIGHLIGHT,e.FOREGROUND,e.HIGHLIGHT):F(G,"<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")),se=!0,I("onReady",n);break;default:if(0===l&&0===t)return void E(G,`Unsupported message received (${s}), this is likely due to the iframe containing a later version of iframe-resizer than the parent page`);if(0===l||0===t)return void x(G,"Ignoring message with 0 height or width");if(document.hidden)return void x(G,"Page hidden - ignored resize request");o()}var c,d}function T(e){U[e].loaded||(oe("iframe requested init",ne(e),e),D(e,U))}let j=t.data,k={},G=null;"[iFrameResizerChild]Ready"!==j?r===`${j}`.slice(0,13)&&j.slice(13).split(":")[0]in U?(k=function(){const e=j.slice(13).split(":"),i=e[1]?Number(e[1]):0,t=U[e[0]]?.iframe,o=getComputedStyle(t),r={iframe:t,id:e[0],height:i+n(o)+s(o),width:Number(e[2]),type:e[3],msg:e[4]};return e[5]&&(r.mode=e[5]),r}(),G=k.id,G?(A(G,k.type),W(G,function(){!function(e){if(!U[e])throw new Error(`${k.type} No settings for ${e}. Message was: ${j}`)}(G),function(){const e=k.type in{true:1,false:1,undefined:1};return e&&x(G,"Ignoring init message from meta parent page"),e}()||(x(G,`Received: %c${j}`,e.HIGHLIGHT),U[G].loaded=!0,U[G].ready=!0,(null!==k.iframe||(E(G,`The iframe (${k.id}) was not found.`),0))&&function(){const{origin:i,sameOrigin:o}=t;if(o)return!0;let n=U[G]?.checkOrigin;if(n&&"null"!=`${i}`&&!(n.constructor===Array?function(){let t=0,o=!1;for(x(G,`Checking connection is from allowed list of origins: %c${n}`,e.HIGHLIGHT);t<n.length;t++)if(n[t]===i){o=!0;break}return o}():function(){const t=U[G]?.remoteHost;return x(G,`Checking connection is from: %c${t}`,e.HIGHLIGHT),i===t}()))throw new Error(`Unexpected message received from: ${i} for ${k.iframe.id}. Message was: ${t.data}. This error can be disabled by setting the checkOrigin: false option or by providing of array of trusted domains.`);return!0}()&&$())})()):E("","iframeResizer received messageData without id, message was: ",j)):null!==G&&x(G,"Ignored:",j):Object.keys(U).forEach(T)}function Z(e,i,t){let o=null,n=null;if(U[e]){if(o=U[e][i],"function"!=typeof o)throw new TypeError(`${i} on iFrame[${e}] is not a function`);if("onBeforeClose"===i||"onScroll"===i)try{n=o(t)}catch(t){console.error(t),E(e,`Error in ${i} callback`)}else((e,...i)=>{setTimeout(()=>e(...i),0)})(o,t)}return n}function X(e){const{id:i}=e;x(i,"Disconnected from iframe"),delete U[i],delete e.iframeResizer}function Y(i){const{id:t}=i;if(!1!==Z(t,"onBeforeClose",t)){x(t,`Removing iFrame: %c${t}`,e.HIGHLIGHT);try{i.parentNode&&i.remove()}catch(e){E(t,e)}Z(t,"onAfterClose",t),X(i)}else x(t,"Close iframe cancelled by onBeforeClose")}function _(i){null===J.position&&(J.position={x:window.scrollX,y:window.scrollY},x(i,`Get page position: %c${J.position.x}%c, %c${J.position.y}`,e.HIGHLIGHT,e.FOREGROUND,e.HIGHLIGHT))}function K(){J.position=null}function Q(i){null!==J.position&&(window.scrollTo(J.position.x,J.position.y),S(i,`Set page position: %c${J.position.x}%c, %c${J.position.y}`,e.HIGHLIGHT,e.FOREGROUND,e.HIGHLIGHT),K())}function ee(e){x(e.id,"Size reset requested by "+("init"===e.type?"parent page":"child page")),_(e.id),ie(e),oe("reset","reset",e.id)}function ie(i){function t(t){const n=`${i[t]}px`;i.iframe.style[t]=n,S(o,`Set ${t}: %c${n}`,e.HIGHLIGHT)}const{id:o}=i,{sizeHeight:n,sizeWidth:r}=U[o];n&&t("height"),r&&t("width")}G=U;const te=e=>e.split(":").filter((e,i)=>19!==i).join(":");function oe(i,t,o){function n(n){const r=i in c?te(t):t;S(o,n,e.HIGHLIGHT,e.FOREGROUND,e.HIGHLIGHT),S(o,`Message data: %c${r}`,e.HIGHLIGHT)}A(o,i),U[o]&&(U[o]?.postMessageTarget?function(){const{iframe:e,postMessageTarget:i,sameOrigin:s,targetOrigin:a}=U[o];if(s)try{return e.contentWindow.iframeChildListener(r+t),void n(`Sending message to iframe %c${o}%c via sameOrigin`)}catch(e){x(o,"Same domain connection failed. Trying cross domain%c")}n(`Sending message to iframe: %c${o}%c targetOrigin: %c${a}`),i.postMessage(r+t,a)}():E(o,`Iframe(${o}) not found`))}function ne(e){const i=U[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,"",i.logExpand].join(":")}let re=0,se=!1,ae=!1,le=!1;function ce(t,o=-3){if(ae)return;const n=Math.max(U[t].mode,o);if(n>U[t].mode&&(U[t].mode=n),n<0)throw N(t),U[t].vAdvised||F(t||"Parent",`${z(n+2)}${z(2)}`),U[t].vAdvised=!0,z(n+2).replace(/<\/?[a-z][^>]*>|<\/>/gi,"");n>-1&&le||function(i,t){queueMicrotask(()=>console.info(`%ciframe-resizer ${i}`,O||t<1?"font-weight: bold;":e.NORMAL))}(`v${i} (${(e=>g(v[e]))(n)})`,n),n<1&&F("Parent",z(3)),ae=!0}function de(){!1===document.hidden&&(x("document","Trigger event: Visibility change"),function(e,i){const t=e=>U[e]?.autoResize&&!U[e]?.firstRun;Object.keys(U).forEach(function(o){t(o)&&oe(e,i,o)})}("tabVisible","resize"))}const ue=(e=>{let i=!1;return function(){return i?void 0:(i=!0,Reflect.apply(e,this,arguments))}})(()=>{p(window,"message",V),p(document,"visibilitychange",de),window.iframeParentListener=e=>setTimeout(()=>V({data:e,sameOrigin:!0}))});module.exports=i=>r=>{function c(){if(U[w]){const{iframe:e}=U[w],i={close:Y.bind(null,e),disconnect:X.bind(null,e),removeListeners(){F(w,"<rb>Deprecated Method Name</>\n\nThe [removeListeners()</> method has been renamed to [disconnect()</>.\n"),this.disconnect()},resize(){F(w,"<rb>Deprecated Method</>\n \nUse of the <b>resize()</> method from the parent page is deprecated and will be removed in a future version of <i>iframe-resizer</>. As their are no longer any edge cases that require triggering a resize from the parent page, it is recommended to remove this method from your code."),oe.bind(null,"Window resize","resize",w)},moveToAnchor(e){((e,i,t)=>{if(typeof e!==i)throw new TypeError(`${t} is not a ${o=i,o.charAt(0).toUpperCase()+o.slice(1)}`);var o})(e,"string","moveToAnchor(anchor) anchor"),oe("Move to anchor",`moveToAnchor:${e}`,w)},sendMessage(e){oe("message",`message:${e=JSON.stringify(e)}`,w)}};e.iframeResizer=i,e.iFrameResizer=i}}function u(e){const{id:i}=r,{waitForLoad:t}=U[i];p(r,"load",function(){oe(a,`${e}:${se}`,i),U[i].loaded=!0,D(i,U),function(){const e=U[w]?.firstRun,i=U[w]?.heightCalculationMethod in s;!e&&i&&ee({iframe:r,height:0,width:0,type:"init"})}()}),!0!==t&&(oe(l,`${e}:${se}`,i),D(i,U))}function m(e){return e?(("sizeWidth"in e||"sizeHeight"in e||"autoResize"in e)&&F(w,`<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>"${o}"</>, <i>"${n}"</> or <i>"${t}"</>.\n`),e):{}}function h(e){const i=U[e]?.iframe?.title;return""===i||void 0===i}function g(e,i){I(U[w],e)&&(F(w,`<rb>Deprecated option</>\n\nThe <b>${e}</> option has been renamed to <b>${i}</>. Use of the old name will be removed in a future version of <i>iframe-resizer</>.`),U[w][i]=U[w][e],delete U[w][e])}const y=e=>I(e,"onMouseEnter")||I(e,"onMouseLeave");function b(i){var s,a;U[w]={...U[w],iframe:r,firstRun:!0,remoteHost:r?.src.split("/").slice(0,3).join("/"),...q,...m(i),mouseEvents:y(i),mode:H(i),syncTitle:h(w)},g("offset","offsetSize"),g("onClose","onBeforeClose"),g("onClosed","onAfterClose"),A(w,"setup"),function(){const{direction:i}=U[w];switch(i){case o:break;case n:U[w].sizeHeight=!1;case"both":U[w].sizeWidth=!0;break;case t:U[w].sizeWidth=!1,U[w].sizeHeight=!1,U[w].autoResize=!1;break;default:throw new TypeError(w,`Direction value of "${i}" is not valid`)}x(w,`direction: %c${i}`,e.HIGHLIGHT)}(),(s=i?.offsetSize||i?.offset)&&(U[w].direction===o?(U[w].offsetHeight=s,x(w,`Offset height: %c${s}`,e.HIGHLIGHT)):(U[w].offsetWidth=s,x(w,`Offset width: %c${s}`,e.HIGHLIGHT))),function(e){e?.offset&&F(w,"<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</>.")}(i),U[w].warningTimeout||S(w,"warningTimeout:%c disabled",e.HIGHLIGHT),null===U[w].postMessageTarget&&(U[w].postMessageTarget=r.contentWindow),U[w].targetOrigin=!0===U[w].checkOrigin?""===(a=U[w].remoteHost)||null!==a.match(/^(about:blank|javascript:|file:\/\/)/)?"*":a:"*"}const v=()=>"iframeResizer"in r,w=function(e){if(e&&"string"!=typeof e)throw new TypeError("Invalid id for iFrame. Expected String");return""!==e&&e||(e=function(){let e=i?.id||q.id+re++;return null!==document.getElementById(e)&&(e+=re++),e}(),r.id=e,x(e,`Added missing iframe ID: ${e} (${r.src})`)),e}(r.id);if("object"!=typeof i)throw new TypeError("Options is not an object");return function(e){const{search:i}=window.location;i.includes("ifrlog")&&(e.log=d,e.logExpand=!i.includes("ifrlog=collapsed"))}(i),function(e,i){const t=I(i,"log"),o="string"==typeof i.log,n=t?!!o||i.log:q.log;I(i,"logExpand")||(i.logExpand=t&&o?i.log===d:q.logExpand),function(e){-1===e?.log&&(e.log=!1,le=!0)}(i),function({enabled:e,expand:i,iframeId:t}){const o=j({expand:i,label:R(t)});O=e,G[t]||(G[t]={console:o})}({enabled:n,expand:i.logExpand,iframeId:e}),o&&!(i.log in f)&&C(e,'Invalid value for options.log: Accepted values are "expanded" and "collapsed"'),i.log=n}(w,i),W(w,function(e){v()?E(w,`Ignored iframe (${w}), already setup.`):(b(e),function(){if(ae)return;const{mode:e}=U[w];-1!==e&&ce(w,e)}(),ue(),function(){switch(x(w,`Iframe scrolling ${U[w]?.scrolling?"enabled":"disabled"} for ${w}`),r.style.overflow=!1===U[w]?.scrolling?"hidden":"auto",U[w]?.scrolling){case"omit":break;case!0:r.scrolling="yes";break;case!1:r.scrolling="no";break;default:r.scrolling=U[w]?U[w].scrolling:"no"}}(),function(){const{bodyMargin:e}=U[w];"number"!=typeof e&&"0"!==e||(U[w].bodyMargin=`${e}px`)}(),u(ne(w)),c(),x(w,"Setup complete"))})(i),r?.iframeResizer};
|
|
21
21
|
//# sourceMappingURL=index.cjs.js.map
|
package/index.esm.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
* @preserve
|
|
3
3
|
*
|
|
4
|
-
* @module iframe-resizer/core 5.5.3-beta.
|
|
4
|
+
* @module iframe-resizer/core 5.5.3-beta.7 (esm) - 2025-08-19
|
|
5
5
|
*
|
|
6
6
|
* @license GPL-3.0 for non-commercial use only.
|
|
7
7
|
* For commercial use, you must purchase a license from
|
|
@@ -17,5 +17,5 @@
|
|
|
17
17
|
*/
|
|
18
18
|
|
|
19
19
|
|
|
20
|
-
import e,{NORMAL as i,HIGHLIGHT as t,FOREGROUND as o}from"auto-console-group";const n="5.5.3-beta.6",r="none",s="vertical",a="horizontal",l="[iFrameSizer]",c=Object.freeze({max:1,scroll:1,bodyScroll:1,documentElementScroll:1}),d="onload",u="init",f=Object.freeze({[d]:1,[u]:1}),p="expanded",m="collapsed",h=Object.freeze({[p]:1,[m]:1}),g=(e,i,t,o)=>e.addEventListener(i,t,o||!1),y=(e,i,t)=>e.removeEventListener(i,t,!1),b=e=>{if(!e)return"";let i=-559038744,t=1103547984;for(let o,n=0;n<e.length;n++)o=e.codePointAt(n),i=Math.imul(i^o,2246822519),t=Math.imul(t^o,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)},v=e=>e.replace(/[A-Za-z]/g,e=>String.fromCodePoint((e<="Z"?90:122)>=(e=e.codePointAt(0)+19)?e:e-26)),w=["spjluzl","rlf","clyzpvu"],z=["<yi>Puchspk Spjluzl Rlf</><iy><iy>","<yi>Tpzzpun Spjluzl Rlf</><iy><iy>","Aopz spiyhyf pz hchpshisl dpao ivao Jvttlyjphs huk Vwlu-Zvbyjl spjluzlz.<iy><iy><i>Jvttlyjphs Spjluzl</><iy>Mvy jvttlyjphs bzl, <p>pmyhtl-ylzpgly</> ylxbpylz h svd jvza vul aptl spjluzl mll. Mvy tvyl pumvythapvu cpzpa <b>oaawz://pmyhtl-ylzpgly.jvt/wypjpun</>.<iy><iy><i>Vwlu Zvbyjl Spjluzl</><iy>Pm fvb hyl bzpun aopz spiyhyf pu h uvu-jvttlyjphs vwlu zvbyjl wyvqlja aolu fvb jhu bzl pa mvy myll bukly aol alytz vm aol NWS C3 Spjluzl. Av jvumpyt fvb hjjlwa aolzl alytz, wslhzl zla aol <i>spjluzl</> rlf pu <p>pmyhtl-ylzpgly</> vwapvuz av <i>NWSc3</>.<iy><iy>Mvy tvyl pumvythapvu wslhzl zll: <b>oaawz://pmyhtl-ylzpgly.jvt/nws</>","<i>NWSc3 Spjluzl Clyzpvu</><iy><iy>Aopz clyzpvu vm <p>pmyhtl-ylzpgly</> pz ilpun bzlk bukly aol alytz vm aol <i>NWS C3</> spjluzl. Aopz spjluzl hssvdz fvb av bzl <p>pmyhtl-ylzpgly</> pu Vwlu Zvbyjl wyvqljaz, iba pa ylxbpylz fvby wyvqlja av il wbispj, wyvcpkl haaypibapvu huk il spjluzlk bukly clyzpvu 3 vy shaly vm aol NUB Nlulyhs Wbispj Spjluzl.<iy><iy>Pm fvb hyl bzpun aopz spiyhyf pu h uvu-vwlu zvbyjl wyvqlja vy dlizpal, fvb dpss ullk av wbyjohzl h svd jvza vul aptl jvttlyjphs spjluzl.<iy><iy>Mvy tvyl pumvythapvu cpzpa <b>oaawz://pmyhtl-ylzpgly.jvt/wypjpun</>.","<iy><yi>Zvsv spjluzl kvlz uva zbwwvya jyvzz-kvthpu</><iy><iy>Av bzl <p>pmyhtl-ylzpgly</> dpao jyvzz kvthpu pmyhtlz fvb ullk lpaoly aol Wyvmlzzpvuhs vy Ibzpulzz spjluzlz. Mvy klahpsz vu bwnyhkl wypjpun wslhzl jvuahja pumv@pmyhtl-ylzpgly.jvt."],$=["NWSc3","zvsv","wyv","ibzpulzz","vlt"],j=Object.fromEntries(["2cgs7fdf4xb","1c9ctcccr4z","1q2pc4eebgb","ueokt0969w","w2zxchhgqz","1umuxblj2e5"].map((e,i)=>[e,Math.max(0,i-1)])),k=e=>v(z[e]),T=e=>{const i=e[v(w[0])]||e[v(w[1])]||e[v(w[2])];if(!i)return-1;const t=i.split("-");let o=function(e=""){let i=-2;const t=b(v(e));return t in j&&(i=j[t]),i}(t[0]);return 0===o||(e=>e[2]===b(e[0]+e[1]))(t)||(o=-2),o},x=Object.hasOwn||((e,i)=>Object.prototype.hasOwnProperty.call(e,i)),M=e=>e,I=e=>i=>window.chrome?e(i.replaceAll("<br>","\n").replaceAll("<rb>","[31;1m").replaceAll("</>","[m").replaceAll("<b>","[1m").replaceAll("<i>","[3m").replaceAll("<u>","[4m")):e((e=>e.replaceAll("<br>","\n").replaceAll(/<[/a-z]+>/gi,""))(i)),S=(O=e,O?.__esModule?O.default:O);var O;let R={},C=!1;const E=e=>window.top===window.self?`parent(${e})`:`nested parent(${e})`;const A=e=>(i,...t)=>R[i]?.console[e](...t),W=(L="log",(e,...i)=>!0===(e=>R[e]?R[e].log:C)(e)?A(L)(e,...i):null);var L;const N=W,B=A("warn"),H=A("error"),P=A("event"),F=A("purge"),q=A("errorBoundary");const D=(e,...i)=>R[e]?R[e].console.warn(I(M)(...i)):queueMicrotask(()=>console?.warn(I((e=>(...i)=>[`iframeResizer(${e})`,...i].join(" "))(e))(...i))),U=(e=>(i,t="renamed to")=>(o,n,r="",s="")=>e(s,`<rb>Deprecated ${i}(${o.replace("()","")})</>\n\nThe <b>${o}</> ${i.toLowerCase()} has been ${t} <b>${n}</>. ${r}Use of the old ${i.toLowerCase()} will be removed in a future version of <i>iframe-resizer</>.`))(D),J=U("Option");function V(e,i){const{msgTimeout:t,warningTimeout:o}=i[e];o&&(t&&clearTimeout(t),i[e].msgTimeout=setTimeout(function(){if(void 0===i[e])return;const{ready:t,loadErrorShown:o}=i[e];i[e].msgTimeout=void 0,t||o||(i[e].loadErrorShown=!0,function(e,i){const{iframe:t,waitForLoad:o}=i[e],{sandbox:n}=t,r="object"==typeof n&&n.length>0&&!(n.contains("allow-scripts")&&n.contains("allow-same-origin"));P(e,"noResponse"),D(e,`<rb>No response from iframe</>\n \nThe iframe (<i>${e}</>) has not responded within ${i[e].warningTimeout/1e3} seconds. Check <b>@iframe-resizer/child</> package has been loaded in the iframe.\n${o?"\nThe <b>waitForLoad</> option is currently set to <b>'true'</>. If the iframe loads before <i>iframe-resizer</> runs, this option will prevent <i>iframe-resizer</> initialising. To disable this option, set <b>waitForLoad</> to <b>'false'</>. \n":""}${r?"\nThe iframe has the <b>sandbox</> attribute, please ensure it contains both the <i>'allow-same-origin'</> and <i>'allow-scripts'</> values.\n":""}\nThis message can be ignored if everything is working, or you can set the <b>warningTimeout</> option to a higher value or zero to suppress this warning.\n`)}(e,i))},o))}const Z={},X=Object.freeze({autoResize:!0,bodyBackground:null,bodyMargin:null,bodyPadding:null,checkOrigin:!0,direction:s,inPageLinks:!1,heightCalculationMethod:"auto",id:"iFrameResizer",log:!1,logExpand:!1,license:void 0,mouseEvents:!0,offsetHeight:null,offsetWidth:null,postMessageTarget:null,sameDomain:!1,scrolling:!1,sizeHeight:!0,sizeWidth:!1,tolerance:0,waitForLoad:!1,warningTimeout:5e3,widthCalculationMethod:"auto",onBeforeClose:()=>!0,onAfterClose(){},onInit:!1,onMessage:null,onMouseEnter(){},onMouseLeave(){},onReady:e=>{"function"==typeof Z[e.id].onInit&&(J("init()","onReady()","",e.id),Z[e.id].onInit(e))},onResized(){},onScroll:()=>!0}),Y={position:null,version:n};function _(e){function i(){ne(I),te(S),k("onResized",I)}function r(e){if("border-box"!==e.boxSizing)return 0;return(e.paddingTop?parseInt(e.paddingTop,10):0)+(e.paddingBottom?parseInt(e.paddingBottom,10):0)}function s(e){if("border-box"!==e.boxSizing)return 0;return(e.borderTopWidth?parseInt(e.borderTopWidth,10):0)+(e.borderBottomWidth?parseInt(e.borderBottomWidth,10):0)}const a=e=>M.slice(M.indexOf(":")+7+e);const c=(e,i)=>(t,o)=>{const n={};var r,s;r=function(){se(`${t} (${e})`,`${e}:${i()}`,o)},n[s=o]||(r(),n[s]=requestAnimationFrame(()=>{n[s]=null}))},d=(e,i)=>()=>{let t=!1;const o=i=>()=>{Z[l]?t&&t!==i||(e(i,l),t=i,requestAnimationFrame(()=>{t=!1})):a()},n=o("scroll"),r=o("resize window");function s(e,t){W(l,`${e}listeners for send${i}`),t(window,"scroll",n),t(window,"resize",r)}function a(){P(l,`stop${i}`),s("Remove ",y),c.disconnect(),d.disconnect(),y(Z[l].iframe,"load",a)}const l=S,c=new ResizeObserver(o("pageObserver")),d=new ResizeObserver(o("iframeObserver"));Z[l]&&(Z[l][`stop${i}`]=a,g(Z[l].iframe,"load",a),s("Add ",g),c.observe(document.body,{attributes:!0,childList:!0,subtree:!0}),d.observe(Z[l].iframe,{attributes:!0,childList:!1,subtree:!1}))},u=e=>()=>{e in Z[S]&&(Z[S][e](),delete Z[S][e])},f=c("pageInfo",function(){const e=document.body.getBoundingClientRect(),i=I.iframe.getBoundingClientRect(),{scrollY:t,scrollX:o,innerHeight:n,innerWidth:r}=window,{clientHeight:s,clientWidth:a}=document.documentElement;return JSON.stringify({iframeHeight:i.height,iframeWidth:i.width,clientHeight:Math.max(s,n||0),clientWidth:Math.max(a,r||0),offsetTop:parseInt(i.top-e.top,10),offsetLeft:parseInt(i.left-e.left,10),scrollTop:t,scrollLeft:o,documentHeight:s,documentWidth:a,windowHeight:n,windowWidth:r})}),p=c("parentInfo",function(){const{iframe:e}=I,{scrollWidth:i,scrollHeight:t}=document.documentElement,{width:o,height:n,offsetLeft:r,offsetTop:s,pageLeft:a,pageTop:l,scale:c}=window.visualViewport;return JSON.stringify({iframe:e.getBoundingClientRect(),document:{scrollWidth:i,scrollHeight:t},viewport:{width:o,height:n,offsetLeft:r,offsetTop:s,pageLeft:a,pageTop:l,scale:c}})}),m=d(f,"PageInfo"),h=d(p,"ParentInfo"),b=u("stopPageInfo"),v=u("stopParentInfo");function w(e){const i=e.getBoundingClientRect();return ee(S),{x:Number(i.left)+Number(Y.position.x),y:Number(i.top)+Number(Y.position.y)}}function z(e){const i=e?w(I.iframe):{x:0,y:0};N(S,`Reposition requested (offset x:%c${i.x}%c y:%c${i.y})`,t,o,t);const n=((e,i)=>({x:e.width+i.x,y:e.height+i.y}))(I,i),r=window.parentIframe||window.parentIFrame;r?function(i,t){i["scrollTo"+(e?"Offset":"")](t.x,t.y)}(r,n):function(e){Y.position=e,$(S)}(n)}function $(e){const{x:i,y:t}=Y.position,o=Z[e]?.iframe;!1!==k("onScroll",{iframe:o,top:t,left:i,x:i,y:t})?te(e):ie()}function j(e){let i={};if(0===I.width&&0===I.height){const e=a(9).split(":");i={x:e[1],y:e[0]}}else i={x:I.width,y:I.height};k(e,{iframe:I.iframe,screenX:Number(i.x),screenY:Number(i.y),type:I.type})}const k=(e,i)=>G(S,e,i);function T(){const{height:e,iframe:r,msg:s,type:l,width:c}=I;switch(Z[S]?.firstRun&&function(){if(!Z[S])return;fe(S,I.mode),Z[S].firstRun=!1}(),l){case"close":Q(r);break;case"message":u=a(6),W(S,`onMessage passed: {iframe: %c${I.iframe.id}%c, message: %c${u}%c}`,t,o,t,o),k("onMessage",{iframe:I.iframe,message:JSON.parse(u)});break;case"mouseenter":j("onMouseEnter");break;case"mouseleave":j("onMouseLeave");break;case"autoResize":Z[S].autoResize=JSON.parse(a(9));break;case"scrollBy":!function(){const e=I.width,i=I.height,n=window.parentIframe||window.parentIFrame||window;N(S,`scrollBy: x: %c${e}%c y: %c${i}`,t,o,t),n.scrollBy(e,i)}();break;case"scrollTo":z(!1);break;case"scrollToOffset":z(!0);break;case"pageInfo":m();break;case"parentInfo":h();break;case"pageInfoStop":b();break;case"parentInfoStop":v();break;case"inPageLink":!function(e){const i=e.split("#")[1]||"",o=decodeURIComponent(i);let n=document.getElementById(o)||document.getElementsByName(o)[0];n?function(){const e=w(n);N(S,`Moving to in page link: %c#${i}`,t),Y.position={x:e.x,y:e.y},$(S),window.location.hash=i}():window.top!==window.self?function(){const e=window.parentIframe||window.parentIFrame;e?e.moveToAnchor(i):W(S,`In page link #${i} not found and window.parentIframe not found`)}():W(S,`In page link #${i} not found`)}(a(9));break;case"title":!function(e,i){Z[i]?.syncTitle&&(Z[i].iframe.title=e,N(i,`Set iframe title attribute: %c${e}`,t))}(s,S);break;case"reset":oe(I);break;case"init":i(),function(e){try{Z[e].sameOrigin=!!Z[e]?.iframe?.contentWindow?.iframeChildListener}catch(i){Z[e].sameOrigin=!1}W(e,`sameOrigin: %c${Z[e].sameOrigin}`,t)}(S),(d=s)!==n&&(void 0!==d?W(S,`Version mismatch (Child: %c${d}%c !== Parent: %c${n})`,t,o,t):D(S,"<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")),ce=!0,k("onReady",r);break;default:if(0===c&&0===e)return void B(S,`Unsupported message received (${l}), this is likely due to the iframe containing a later version of iframe-resizer than the parent page`);if(0===c||0===e)return void W(S,"Ignoring message with 0 height or width");if(document.hidden)return void W(S,"Page hidden - ignored resize request");i()}var d,u}function x(e){Z[e].loaded||(se("iframe requested init",ae(e),e),V(e,Z))}let M=e.data,I={},S=null;"[iFrameResizerChild]Ready"!==M?l===`${M}`.slice(0,13)&&M.slice(13).split(":")[0]in Z?(I=function(){const e=M.slice(13).split(":"),i=e[1]?Number(e[1]):0,t=Z[e[0]]?.iframe,o=getComputedStyle(t),n={iframe:t,id:e[0],height:i+r(o)+s(o),width:Number(e[2]),type:e[3],msg:e[4]};return e[5]&&(n.mode=e[5]),n}(),S=I.id,S?(P(S,I.type),q(S,function(){!function(e){if(!Z[e])throw new Error(`${I.type} No settings for ${e}. Message was: ${M}`)}(S),function(){const e=I.type in{true:1,false:1,undefined:1};return e&&W(S,"Ignoring init message from meta parent page"),e}()||(W(S,`Received: %c${M}`,t),Z[S].loaded=!0,Z[S].ready=!0,(null!==I.iframe||(B(S,`The iframe (${I.id}) was not found.`),0))&&function(){const{origin:i,sameOrigin:o}=e;if(o)return!0;let n=Z[S]?.checkOrigin;if(n&&"null"!=`${i}`&&!(n.constructor===Array?function(){let e=0,o=!1;for(W(S,`Checking connection is from allowed list of origins: %c${n}`,t);e<n.length;e++)if(n[e]===i){o=!0;break}return o}():function(){const e=Z[S]?.remoteHost;return W(S,`Checking connection is from: %c${e}`,t),i===e}()))throw new Error(`Unexpected message received from: ${i} for ${I.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}()&&T())})()):B("","iframeResizer received messageData without id, message was: ",M)):null!==S&&W(S,"Ignored:",M):Object.keys(Z).forEach(x)}function G(e,i,t){let o=null,n=null;if(Z[e]){if(o=Z[e][i],"function"!=typeof o)throw new TypeError(`${i} on iFrame[${e}] is not a function`);if("onBeforeClose"===i||"onScroll"===i)try{n=o(t)}catch(t){console.error(t),B(e,`Error in ${i} callback`)}else((e,...i)=>{setTimeout(()=>e(...i),0)})(o,t)}return n}function K(e){const{id:i}=e;W(i,"Disconnected from iframe"),delete Z[i],delete e.iframeResizer}function Q(e){const{id:i}=e;if(!1!==G(i,"onBeforeClose",i)){W(i,`Removing iFrame: %c${i}`,t);try{e.parentNode&&e.remove()}catch(e){B(i,e)}G(i,"onAfterClose",i),K(e)}else W(i,"Close iframe cancelled by onBeforeClose")}function ee(e){null===Y.position&&(Y.position={x:window.scrollX,y:window.scrollY},W(e,`Get page position: %c${Y.position.x}%c, %c${Y.position.y}`,t,o,t))}function ie(){Y.position=null}function te(e){null!==Y.position&&(window.scrollTo(Y.position.x,Y.position.y),N(e,`Set page position: %c${Y.position.x}%c, %c${Y.position.y}`,t,o,t),ie())}function oe(e){W(e.id,"Size reset requested by "+("init"===e.type?"parent page":"child page")),ee(e.id),ne(e),se("reset","reset",e.id)}function ne(e){function i(i){const n=`${e[i]}px`;e.iframe.style[i]=n,N(o,`Set ${i}: %c${n}`,t)}const{id:o}=e,{sizeHeight:n,sizeWidth:r}=Z[o];n&&i("height"),r&&i("width")}R=Z;const re=e=>e.split(":").filter((e,i)=>19!==i).join(":");function se(e,i,n){function r(r){const s=e in f?re(i):i;N(n,r,t,o,t),N(n,`Message data: %c${s}`,t)}P(n,e),Z[n]&&(Z[n]?.postMessageTarget?function(){const{iframe:e,postMessageTarget:t,sameOrigin:o,targetOrigin:s}=Z[n];if(o)try{return e.contentWindow.iframeChildListener(l+i),void r(`Sending message to iframe %c${n}%c via sameOrigin`)}catch(e){W(n,"Same domain connection failed. Trying cross domain%c")}r(`Sending message to iframe: %c${n}%c targetOrigin: %c${s}`),t.postMessage(l+i,s)}():B(n,`Iframe(${n}) not found`))}function ae(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,Y.version,i.mode,"",i.logExpand].join(":")}let le=0,ce=!1,de=!1,ue=!1;function fe(e,t=-3){if(de)return;const o=Math.max(Z[e].mode,t);if(o>Z[e].mode&&(Z[e].mode=o),o<0)throw F(e),Z[e].vAdvised||D(e||"Parent",`${k(o+2)}${k(2)}`),Z[e].vAdvised=!0,k(o+2).replace(/<\/?[a-z][^>]*>|<\/>/gi,"");o>-1&&ue||function(e,t){queueMicrotask(()=>console.info(`%ciframe-resizer ${e}`,C||t<1?"font-weight: bold;":i))}(`v${n} (${(e=>v($[e]))(o)})`,o),o<1&&D("Parent",k(3)),de=!0}const pe=e=>i=>{function o(){if(Z[w]){const{iframe:e}=Z[w],i={close:Q.bind(null,e),disconnect:K.bind(null,e),removeListeners(){D(w,"<rb>Deprecated Method Name</>\n\nThe [removeListeners()</> method has been renamed to [disconnect()</>.\n"),this.disconnect()},resize(){D(w,"<rb>Deprecated Method</>\n \nUse of the <b>resize()</> method from the parent page is deprecated and will be removed in a future version of <i>iframe-resizer</>. As their are no longer any edge cases that require triggering a resize from the parent page, it is recommended to remove this method from your code."),se.bind(null,"Window resize","resize",w)},moveToAnchor(e){((e,i,t)=>{if(typeof e!==i)throw new TypeError(`${t} is not a ${o=i,o.charAt(0).toUpperCase()+o.slice(1)}`);var o})(e,"string","moveToAnchor(anchor) anchor"),se("Move to anchor",`moveToAnchor:${e}`,w)},sendMessage(e){se("message",`message:${e=JSON.stringify(e)}`,w)}};e.iframeResizer=i,e.iFrameResizer=i}}function n(e){const{id:t}=i,{waitForLoad:o}=Z[t];g(i,"load",function(){se(d,`${e}:${ce}`,t),Z[t].loaded=!0,V(t,Z),function(){const e=Z[w]?.firstRun,t=Z[w]?.heightCalculationMethod in c;!e&&t&&oe({iframe:i,height:0,width:0,type:"init"})}()}),!0!==o&&(se(u,`${e}:${ce}`,t),V(t,Z))}function l(e){return e?(("sizeWidth"in e||"sizeHeight"in e||"autoResize"in e)&&D(w,`<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>"${s}"</>, <i>"${a}"</> or <i>"${r}"</>.\n`),e):{}}function f(e){const i=Z[e]?.iframe?.title;return""===i||void 0===i}function m(e,i){x(Z[w],e)&&(D(w,`<rb>Deprecated option</>\n\nThe <b>${e}</> option has been renamed to <b>${i}</>. Use of the old name will be removed in a future version of <i>iframe-resizer</>.`),Z[w][i]=Z[w][e],delete Z[w][e])}const y=e=>x(e,"onMouseEnter")||x(e,"onMouseLeave");function b(e){var o,n;Z[w]={...Z[w],iframe:i,firstRun:!0,remoteHost:i?.src.split("/").slice(0,3).join("/"),...X,...l(e),mouseEvents:y(e),mode:T(e),syncTitle:f(w)},m("offset","offsetSize"),m("onClose","onBeforeClose"),m("onClosed","onAfterClose"),P(w,"setup"),function(){const{direction:e}=Z[w];switch(e){case s:break;case a:Z[w].sizeHeight=!1;case"both":Z[w].sizeWidth=!0;break;case r:Z[w].sizeWidth=!1,Z[w].sizeHeight=!1,Z[w].autoResize=!1;break;default:throw new TypeError(w,`Direction value of "${e}" is not valid`)}W(w,`direction: %c${e}`,t)}(),(o=e?.offsetSize||e?.offset)&&(Z[w].direction===s?(Z[w].offsetHeight=o,W(w,`Offset height: %c${o}`,t)):(Z[w].offsetWidth=o,W(w,`Offset width: %c${o}`,t))),function(e){e?.offset&&D(w,"<rb>Deprecated option</>\n\n The <b>offset</> option has been renamed to <b>offsetSize</>. Use of the old name will be removed in a future version of <i>iframe-resizer</>.")}(e),Z[w].warningTimeout||N(w,"warningTimeout:%c disabled",t),null===Z[w].postMessageTarget&&(Z[w].postMessageTarget=i.contentWindow),Z[w].targetOrigin=!0===Z[w].checkOrigin?""===(n=Z[w].remoteHost)||null!==n.match(/^(about:blank|javascript:|file:\/\/)/)?"*":n:"*"}const v=()=>"iframeResizer"in i,w=function(t){if(t&&"string"!=typeof t)throw new TypeError("Invalid id for iFrame. Expected String");return""!==t&&t||(t=function(){let i=e?.id||X.id+le++;return null!==document.getElementById(i)&&(i+=le++),i}(),i.id=t,W(t,`Added missing iframe ID: ${t} (${i.src})`)),t}(i.id);if("object"!=typeof e)throw new TypeError("Options is not an object");return function(e){const{search:i}=window.location;i.includes("ifrlog")&&(e.log=p,e.logExpand=!i.includes("ifrlog=collapsed"))}(e),function(e,i){const t=x(i,"log"),o="string"==typeof i.log,n=t?!!o||i.log:X.log;x(i,"logExpand")||(i.logExpand=t&&o?i.log===p:X.logExpand),function(e){-1===e?.log&&(e.log=!1,ue=!0)}(i),function({enabled:e,expand:i,iframeId:t}){const o=S({expand:i,label:E(t)});C=e,R[t]||(R[t]={console:o})}({enabled:n,expand:i.logExpand,iframeId:e}),o&&!(i.log in h)&&H(e,'Invalid value for options.log: Accepted values are "expanded" and "collapsed"'),i.log=n}(w,e),q(w,function(e){v()?B(w,`Ignored iframe (${w}), already setup.`):(b(e),function(){if(de)return;const{mode:e}=Z[w];-1!==e&&fe(w,e)}(),he(),function(){switch(W(w,`Iframe scrolling ${Z[w]?.scrolling?"enabled":"disabled"} for ${w}`),i.style.overflow=!1===Z[w]?.scrolling?"hidden":"auto",Z[w]?.scrolling){case"omit":break;case!0:i.scrolling="yes";break;case!1:i.scrolling="no";break;default:i.scrolling=Z[w]?Z[w].scrolling:"no"}}(),function(){const{bodyMargin:e}=Z[w];"number"!=typeof e&&"0"!==e||(Z[w].bodyMargin=`${e}px`)}(),n(ae(w)),o(),W(w,"Setup complete"))})(e),i?.iframeResizer};function me(){!1===document.hidden&&(W("document","Trigger event: Visibility change"),function(e,i){const t=e=>Z[e]?.autoResize&&!Z[e]?.firstRun;Object.keys(Z).forEach(function(o){t(o)&&se(e,i,o)})}("tabVisible","resize"))}const he=(e=>{let i=!1;return function(){return i?void 0:(i=!0,Reflect.apply(e,this,arguments))}})(()=>{g(window,"message",_),g(document,"visibilitychange",me),window.iframeParentListener=e=>setTimeout(()=>_({data:e,sameOrigin:!0}))});export{pe as default};
|
|
20
|
+
import e,{NORMAL as i,HIGHLIGHT as t,FOREGROUND as o}from"auto-console-group";const n="5.5.3-beta.7",r="none",s="vertical",a="horizontal",l="[iFrameSizer]",c=Object.freeze({max:1,scroll:1,bodyScroll:1,documentElementScroll:1}),d="onload",u="init",f=Object.freeze({[d]:1,[u]:1}),p="expanded",m="collapsed",h=Object.freeze({[p]:1,[m]:1}),g=(e,i,t,o)=>e.addEventListener(i,t,o||!1),y=(e,i,t)=>e.removeEventListener(i,t,!1),b=e=>{if(!e)return"";let i=-559038744,t=1103547984;for(let o,n=0;n<e.length;n++)o=e.codePointAt(n),i=Math.imul(i^o,2246822519),t=Math.imul(t^o,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)},v=e=>e.replace(/[A-Za-z]/g,e=>String.fromCodePoint((e<="Z"?90:122)>=(e=e.codePointAt(0)+19)?e:e-26)),w=["spjluzl","rlf","clyzpvu"],z=["<yi>Puchspk Spjluzl Rlf</><iy><iy>","<yi>Tpzzpun Spjluzl Rlf</><iy><iy>","Aopz spiyhyf pz hchpshisl dpao ivao Jvttlyjphs huk Vwlu-Zvbyjl spjluzlz.<iy><iy><i>Jvttlyjphs Spjluzl</><iy>Mvy jvttlyjphs bzl, <p>pmyhtl-ylzpgly</> ylxbpylz h svd jvza vul aptl spjluzl mll. Mvy tvyl pumvythapvu cpzpa <b>oaawz://pmyhtl-ylzpgly.jvt/wypjpun</>.<iy><iy><i>Vwlu Zvbyjl Spjluzl</><iy>Pm fvb hyl bzpun aopz spiyhyf pu h uvu-jvttlyjphs vwlu zvbyjl wyvqlja aolu fvb jhu bzl pa mvy myll bukly aol alytz vm aol NWS C3 Spjluzl. Av jvumpyt fvb hjjlwa aolzl alytz, wslhzl zla aol <i>spjluzl</> rlf pu <p>pmyhtl-ylzpgly</> vwapvuz av <i>NWSc3</>.<iy><iy>Mvy tvyl pumvythapvu wslhzl zll: <b>oaawz://pmyhtl-ylzpgly.jvt/nws</>","<i>NWSc3 Spjluzl Clyzpvu</><iy><iy>Aopz clyzpvu vm <p>pmyhtl-ylzpgly</> pz ilpun bzlk bukly aol alytz vm aol <i>NWS C3</> spjluzl. Aopz spjluzl hssvdz fvb av bzl <p>pmyhtl-ylzpgly</> pu Vwlu Zvbyjl wyvqljaz, iba pa ylxbpylz fvby wyvqlja av il wbispj, wyvcpkl haaypibapvu huk il spjluzlk bukly clyzpvu 3 vy shaly vm aol NUB Nlulyhs Wbispj Spjluzl.<iy><iy>Pm fvb hyl bzpun aopz spiyhyf pu h uvu-vwlu zvbyjl wyvqlja vy dlizpal, fvb dpss ullk av wbyjohzl h svd jvza vul aptl jvttlyjphs spjluzl.<iy><iy>Mvy tvyl pumvythapvu cpzpa <b>oaawz://pmyhtl-ylzpgly.jvt/wypjpun</>.","<iy><yi>Zvsv spjluzl kvlz uva zbwwvya jyvzz-kvthpu</><iy><iy>Av bzl <p>pmyhtl-ylzpgly</> dpao jyvzz kvthpu pmyhtlz fvb ullk lpaoly aol Wyvmlzzpvuhs vy Ibzpulzz spjluzlz. Mvy klahpsz vu bwnyhkl wypjpun wslhzl jvuahja pumv@pmyhtl-ylzpgly.jvt."],$=["NWSc3","zvsv","wyv","ibzpulzz","vlt"],j=Object.fromEntries(["2cgs7fdf4xb","1c9ctcccr4z","1q2pc4eebgb","ueokt0969w","w2zxchhgqz","1umuxblj2e5"].map((e,i)=>[e,Math.max(0,i-1)])),k=e=>v(z[e]),T=e=>{const i=e[v(w[0])]||e[v(w[1])]||e[v(w[2])];if(!i)return-1;const t=i.split("-");let o=function(e=""){let i=-2;const t=b(v(e));return t in j&&(i=j[t]),i}(t[0]);return 0===o||(e=>e[2]===b(e[0]+e[1]))(t)||(o=-2),o},x=Object.hasOwn||((e,i)=>Object.prototype.hasOwnProperty.call(e,i)),M=e=>e,I=e=>i=>window.chrome?e(i.replaceAll("<br>","\n").replaceAll("<rb>","[31;1m").replaceAll("</>","[m").replaceAll("<b>","[1m").replaceAll("<i>","[3m").replaceAll("<u>","[4m")):e((e=>e.replaceAll("<br>","\n").replaceAll(/<[/a-z]+>/gi,""))(i)),S=(O=e,O?.__esModule?O.default:O);var O;let R={},C=!1;const E=e=>window.top===window.self?`parent(${e})`:`nested parent(${e})`;const A=e=>(i,...t)=>R[i]?.console[e](...t),W=(L="log",(e,...i)=>!0===(e=>R[e]?R[e].log:C)(e)?A(L)(e,...i):null);var L;const N=W,B=A("warn"),H=A("error"),P=A("event"),F=A("purge"),q=A("errorBoundary");const D=(e,...i)=>R[e]?R[e].console.warn(I(M)(...i)):queueMicrotask(()=>console?.warn(I((e=>(...i)=>[`iframeResizer(${e})`,...i].join(" "))(e))(...i))),U=(e=>(i,t="renamed to")=>(o,n,r="",s="")=>e(s,`<rb>Deprecated ${i}(${o.replace("()","")})</>\n\nThe <b>${o}</> ${i.toLowerCase()} has been ${t} <b>${n}</>. ${r}Use of the old ${i.toLowerCase()} will be removed in a future version of <i>iframe-resizer</>.`))(D),J=U("Option");function V(e,i){const{msgTimeout:t,warningTimeout:o}=i[e];o&&(t&&clearTimeout(t),i[e].msgTimeout=setTimeout(function(){if(void 0===i[e])return;const{ready:t,loadErrorShown:o}=i[e];i[e].msgTimeout=void 0,t||o||(i[e].loadErrorShown=!0,function(e,i){const{iframe:t,waitForLoad:o}=i[e],{sandbox:n}=t,r="object"==typeof n&&n.length>0&&!(n.contains("allow-scripts")&&n.contains("allow-same-origin"));P(e,"noResponse"),D(e,`<rb>No response from iframe</>\n \nThe iframe (<i>${e}</>) has not responded within ${i[e].warningTimeout/1e3} seconds. Check <b>@iframe-resizer/child</> package has been loaded in the iframe.\n${o?"\nThe <b>waitForLoad</> option is currently set to <b>'true'</>. If the iframe loads before <i>iframe-resizer</> runs, this option will prevent <i>iframe-resizer</> initialising. To disable this option, set <b>waitForLoad</> to <b>'false'</>. \n":""}${r?"\nThe iframe has the <b>sandbox</> attribute, please ensure it contains both the <i>'allow-same-origin'</> and <i>'allow-scripts'</> values.\n":""}\nThis message can be ignored if everything is working, or you can set the <b>warningTimeout</> option to a higher value or zero to suppress this warning.\n`)}(e,i))},o))}const Z={},X=Object.freeze({autoResize:!0,bodyBackground:null,bodyMargin:null,bodyPadding:null,checkOrigin:!0,direction:s,inPageLinks:!1,heightCalculationMethod:"auto",id:"iFrameResizer",log:!1,logExpand:!1,license:void 0,mouseEvents:!0,offsetHeight:null,offsetWidth:null,postMessageTarget:null,sameDomain:!1,scrolling:!1,sizeHeight:!0,sizeWidth:!1,tolerance:0,waitForLoad:!1,warningTimeout:5e3,widthCalculationMethod:"auto",onBeforeClose:()=>!0,onAfterClose(){},onInit:!1,onMessage:null,onMouseEnter(){},onMouseLeave(){},onReady:e=>{"function"==typeof Z[e.id].onInit&&(J("init()","onReady()","",e.id),Z[e.id].onInit(e))},onResized(){},onScroll:()=>!0}),Y={position:null,version:n};function _(e){function i(){ne(I),te(S),k("onResized",I)}function r(e){if("border-box"!==e.boxSizing)return 0;return(e.paddingTop?parseInt(e.paddingTop,10):0)+(e.paddingBottom?parseInt(e.paddingBottom,10):0)}function s(e){if("border-box"!==e.boxSizing)return 0;return(e.borderTopWidth?parseInt(e.borderTopWidth,10):0)+(e.borderBottomWidth?parseInt(e.borderBottomWidth,10):0)}const a=e=>M.slice(M.indexOf(":")+7+e);const c=(e,i)=>(t,o)=>{const n={};var r,s;r=function(){se(`${t} (${e})`,`${e}:${i()}`,o)},n[s=o]||(r(),n[s]=requestAnimationFrame(()=>{n[s]=null}))},d=(e,i)=>()=>{let t=!1;const o=i=>()=>{Z[l]?t&&t!==i||(e(i,l),t=i,requestAnimationFrame(()=>{t=!1})):a()},n=o("scroll"),r=o("resize window");function s(e,t){W(l,`${e}listeners for send${i}`),t(window,"scroll",n),t(window,"resize",r)}function a(){P(l,`stop${i}`),s("Remove ",y),c.disconnect(),d.disconnect(),y(Z[l].iframe,"load",a)}const l=S,c=new ResizeObserver(o("pageObserver")),d=new ResizeObserver(o("iframeObserver"));Z[l]&&(Z[l][`stop${i}`]=a,g(Z[l].iframe,"load",a),s("Add ",g),c.observe(document.body,{attributes:!0,childList:!0,subtree:!0}),d.observe(Z[l].iframe,{attributes:!0,childList:!1,subtree:!1}))},u=e=>()=>{e in Z[S]&&(Z[S][e](),delete Z[S][e])},f=c("pageInfo",function(){const e=document.body.getBoundingClientRect(),i=I.iframe.getBoundingClientRect(),{scrollY:t,scrollX:o,innerHeight:n,innerWidth:r}=window,{clientHeight:s,clientWidth:a}=document.documentElement;return JSON.stringify({iframeHeight:i.height,iframeWidth:i.width,clientHeight:Math.max(s,n||0),clientWidth:Math.max(a,r||0),offsetTop:parseInt(i.top-e.top,10),offsetLeft:parseInt(i.left-e.left,10),scrollTop:t,scrollLeft:o,documentHeight:s,documentWidth:a,windowHeight:n,windowWidth:r})}),p=c("parentInfo",function(){const{iframe:e}=I,{scrollWidth:i,scrollHeight:t}=document.documentElement,{width:o,height:n,offsetLeft:r,offsetTop:s,pageLeft:a,pageTop:l,scale:c}=window.visualViewport;return JSON.stringify({iframe:e.getBoundingClientRect(),document:{scrollWidth:i,scrollHeight:t},viewport:{width:o,height:n,offsetLeft:r,offsetTop:s,pageLeft:a,pageTop:l,scale:c}})}),m=d(f,"PageInfo"),h=d(p,"ParentInfo"),b=u("stopPageInfo"),v=u("stopParentInfo");function w(e){const i=e.getBoundingClientRect();return ee(S),{x:Number(i.left)+Number(Y.position.x),y:Number(i.top)+Number(Y.position.y)}}function z(e){const i=e?w(I.iframe):{x:0,y:0};N(S,`Reposition requested (offset x:%c${i.x}%c y:%c${i.y})`,t,o,t);const n=((e,i)=>({x:e.width+i.x,y:e.height+i.y}))(I,i),r=window.parentIframe||window.parentIFrame;r?function(i,t){i["scrollTo"+(e?"Offset":"")](t.x,t.y)}(r,n):function(e){Y.position=e,$(S)}(n)}function $(e){const{x:i,y:t}=Y.position,o=Z[e]?.iframe;!1!==k("onScroll",{iframe:o,top:t,left:i,x:i,y:t})?te(e):ie()}function j(e){let i={};if(0===I.width&&0===I.height){const e=a(9).split(":");i={x:e[1],y:e[0]}}else i={x:I.width,y:I.height};k(e,{iframe:I.iframe,screenX:Number(i.x),screenY:Number(i.y),type:I.type})}const k=(e,i)=>G(S,e,i);function T(){const{height:e,iframe:r,msg:s,type:l,width:c}=I;switch(Z[S]?.firstRun&&function(){if(!Z[S])return;fe(S,I.mode),Z[S].firstRun=!1}(),l){case"close":Q(r);break;case"message":u=a(6),W(S,`onMessage passed: {iframe: %c${I.iframe.id}%c, message: %c${u}%c}`,t,o,t,o),k("onMessage",{iframe:I.iframe,message:JSON.parse(u)});break;case"mouseenter":j("onMouseEnter");break;case"mouseleave":j("onMouseLeave");break;case"autoResize":Z[S].autoResize=JSON.parse(a(9));break;case"scrollBy":!function(){const e=I.width,i=I.height,n=window.parentIframe||window.parentIFrame||window;N(S,`scrollBy: x: %c${e}%c y: %c${i}`,t,o,t),n.scrollBy(e,i)}();break;case"scrollTo":z(!1);break;case"scrollToOffset":z(!0);break;case"pageInfo":m();break;case"parentInfo":h();break;case"pageInfoStop":b();break;case"parentInfoStop":v();break;case"inPageLink":!function(e){const i=e.split("#")[1]||"",o=decodeURIComponent(i);let n=document.getElementById(o)||document.getElementsByName(o)[0];n?function(){const e=w(n);N(S,`Moving to in page link: %c#${i}`,t),Y.position={x:e.x,y:e.y},$(S),window.location.hash=i}():window.top!==window.self?function(){const e=window.parentIframe||window.parentIFrame;e?e.moveToAnchor(i):W(S,`In page link #${i} not found and window.parentIframe not found`)}():W(S,`In page link #${i} not found`)}(a(9));break;case"title":!function(e,i){Z[i]?.syncTitle&&(Z[i].iframe.title=e,N(i,`Set iframe title attribute: %c${e}`,t))}(s,S);break;case"reset":oe(I);break;case"init":i(),function(e){try{Z[e].sameOrigin=!!Z[e]?.iframe?.contentWindow?.iframeChildListener}catch(i){Z[e].sameOrigin=!1}W(e,`sameOrigin: %c${Z[e].sameOrigin}`,t)}(S),(d=s)!==n&&(void 0!==d?W(S,`Version mismatch (Child: %c${d}%c !== Parent: %c${n})`,t,o,t):D(S,"<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")),ce=!0,k("onReady",r);break;default:if(0===c&&0===e)return void B(S,`Unsupported message received (${l}), this is likely due to the iframe containing a later version of iframe-resizer than the parent page`);if(0===c||0===e)return void W(S,"Ignoring message with 0 height or width");if(document.hidden)return void W(S,"Page hidden - ignored resize request");i()}var d,u}function x(e){Z[e].loaded||(se("iframe requested init",ae(e),e),V(e,Z))}let M=e.data,I={},S=null;"[iFrameResizerChild]Ready"!==M?l===`${M}`.slice(0,13)&&M.slice(13).split(":")[0]in Z?(I=function(){const e=M.slice(13).split(":"),i=e[1]?Number(e[1]):0,t=Z[e[0]]?.iframe,o=getComputedStyle(t),n={iframe:t,id:e[0],height:i+r(o)+s(o),width:Number(e[2]),type:e[3],msg:e[4]};return e[5]&&(n.mode=e[5]),n}(),S=I.id,S?(P(S,I.type),q(S,function(){!function(e){if(!Z[e])throw new Error(`${I.type} No settings for ${e}. Message was: ${M}`)}(S),function(){const e=I.type in{true:1,false:1,undefined:1};return e&&W(S,"Ignoring init message from meta parent page"),e}()||(W(S,`Received: %c${M}`,t),Z[S].loaded=!0,Z[S].ready=!0,(null!==I.iframe||(B(S,`The iframe (${I.id}) was not found.`),0))&&function(){const{origin:i,sameOrigin:o}=e;if(o)return!0;let n=Z[S]?.checkOrigin;if(n&&"null"!=`${i}`&&!(n.constructor===Array?function(){let e=0,o=!1;for(W(S,`Checking connection is from allowed list of origins: %c${n}`,t);e<n.length;e++)if(n[e]===i){o=!0;break}return o}():function(){const e=Z[S]?.remoteHost;return W(S,`Checking connection is from: %c${e}`,t),i===e}()))throw new Error(`Unexpected message received from: ${i} for ${I.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}()&&T())})()):B("","iframeResizer received messageData without id, message was: ",M)):null!==S&&W(S,"Ignored:",M):Object.keys(Z).forEach(x)}function G(e,i,t){let o=null,n=null;if(Z[e]){if(o=Z[e][i],"function"!=typeof o)throw new TypeError(`${i} on iFrame[${e}] is not a function`);if("onBeforeClose"===i||"onScroll"===i)try{n=o(t)}catch(t){console.error(t),B(e,`Error in ${i} callback`)}else((e,...i)=>{setTimeout(()=>e(...i),0)})(o,t)}return n}function K(e){const{id:i}=e;W(i,"Disconnected from iframe"),delete Z[i],delete e.iframeResizer}function Q(e){const{id:i}=e;if(!1!==G(i,"onBeforeClose",i)){W(i,`Removing iFrame: %c${i}`,t);try{e.parentNode&&e.remove()}catch(e){B(i,e)}G(i,"onAfterClose",i),K(e)}else W(i,"Close iframe cancelled by onBeforeClose")}function ee(e){null===Y.position&&(Y.position={x:window.scrollX,y:window.scrollY},W(e,`Get page position: %c${Y.position.x}%c, %c${Y.position.y}`,t,o,t))}function ie(){Y.position=null}function te(e){null!==Y.position&&(window.scrollTo(Y.position.x,Y.position.y),N(e,`Set page position: %c${Y.position.x}%c, %c${Y.position.y}`,t,o,t),ie())}function oe(e){W(e.id,"Size reset requested by "+("init"===e.type?"parent page":"child page")),ee(e.id),ne(e),se("reset","reset",e.id)}function ne(e){function i(i){const n=`${e[i]}px`;e.iframe.style[i]=n,N(o,`Set ${i}: %c${n}`,t)}const{id:o}=e,{sizeHeight:n,sizeWidth:r}=Z[o];n&&i("height"),r&&i("width")}R=Z;const re=e=>e.split(":").filter((e,i)=>19!==i).join(":");function se(e,i,n){function r(r){const s=e in f?re(i):i;N(n,r,t,o,t),N(n,`Message data: %c${s}`,t)}P(n,e),Z[n]&&(Z[n]?.postMessageTarget?function(){const{iframe:e,postMessageTarget:t,sameOrigin:o,targetOrigin:s}=Z[n];if(o)try{return e.contentWindow.iframeChildListener(l+i),void r(`Sending message to iframe %c${n}%c via sameOrigin`)}catch(e){W(n,"Same domain connection failed. Trying cross domain%c")}r(`Sending message to iframe: %c${n}%c targetOrigin: %c${s}`),t.postMessage(l+i,s)}():B(n,`Iframe(${n}) not found`))}function ae(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,Y.version,i.mode,"",i.logExpand].join(":")}let le=0,ce=!1,de=!1,ue=!1;function fe(e,t=-3){if(de)return;const o=Math.max(Z[e].mode,t);if(o>Z[e].mode&&(Z[e].mode=o),o<0)throw F(e),Z[e].vAdvised||D(e||"Parent",`${k(o+2)}${k(2)}`),Z[e].vAdvised=!0,k(o+2).replace(/<\/?[a-z][^>]*>|<\/>/gi,"");o>-1&&ue||function(e,t){queueMicrotask(()=>console.info(`%ciframe-resizer ${e}`,C||t<1?"font-weight: bold;":i))}(`v${n} (${(e=>v($[e]))(o)})`,o),o<1&&D("Parent",k(3)),de=!0}const pe=e=>i=>{function o(){if(Z[w]){const{iframe:e}=Z[w],i={close:Q.bind(null,e),disconnect:K.bind(null,e),removeListeners(){D(w,"<rb>Deprecated Method Name</>\n\nThe [removeListeners()</> method has been renamed to [disconnect()</>.\n"),this.disconnect()},resize(){D(w,"<rb>Deprecated Method</>\n \nUse of the <b>resize()</> method from the parent page is deprecated and will be removed in a future version of <i>iframe-resizer</>. As their are no longer any edge cases that require triggering a resize from the parent page, it is recommended to remove this method from your code."),se.bind(null,"Window resize","resize",w)},moveToAnchor(e){((e,i,t)=>{if(typeof e!==i)throw new TypeError(`${t} is not a ${o=i,o.charAt(0).toUpperCase()+o.slice(1)}`);var o})(e,"string","moveToAnchor(anchor) anchor"),se("Move to anchor",`moveToAnchor:${e}`,w)},sendMessage(e){se("message",`message:${e=JSON.stringify(e)}`,w)}};e.iframeResizer=i,e.iFrameResizer=i}}function n(e){const{id:t}=i,{waitForLoad:o}=Z[t];g(i,"load",function(){se(d,`${e}:${ce}`,t),Z[t].loaded=!0,V(t,Z),function(){const e=Z[w]?.firstRun,t=Z[w]?.heightCalculationMethod in c;!e&&t&&oe({iframe:i,height:0,width:0,type:"init"})}()}),!0!==o&&(se(u,`${e}:${ce}`,t),V(t,Z))}function l(e){return e?(("sizeWidth"in e||"sizeHeight"in e||"autoResize"in e)&&D(w,`<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>"${s}"</>, <i>"${a}"</> or <i>"${r}"</>.\n`),e):{}}function f(e){const i=Z[e]?.iframe?.title;return""===i||void 0===i}function m(e,i){x(Z[w],e)&&(D(w,`<rb>Deprecated option</>\n\nThe <b>${e}</> option has been renamed to <b>${i}</>. Use of the old name will be removed in a future version of <i>iframe-resizer</>.`),Z[w][i]=Z[w][e],delete Z[w][e])}const y=e=>x(e,"onMouseEnter")||x(e,"onMouseLeave");function b(e){var o,n;Z[w]={...Z[w],iframe:i,firstRun:!0,remoteHost:i?.src.split("/").slice(0,3).join("/"),...X,...l(e),mouseEvents:y(e),mode:T(e),syncTitle:f(w)},m("offset","offsetSize"),m("onClose","onBeforeClose"),m("onClosed","onAfterClose"),P(w,"setup"),function(){const{direction:e}=Z[w];switch(e){case s:break;case a:Z[w].sizeHeight=!1;case"both":Z[w].sizeWidth=!0;break;case r:Z[w].sizeWidth=!1,Z[w].sizeHeight=!1,Z[w].autoResize=!1;break;default:throw new TypeError(w,`Direction value of "${e}" is not valid`)}W(w,`direction: %c${e}`,t)}(),(o=e?.offsetSize||e?.offset)&&(Z[w].direction===s?(Z[w].offsetHeight=o,W(w,`Offset height: %c${o}`,t)):(Z[w].offsetWidth=o,W(w,`Offset width: %c${o}`,t))),function(e){e?.offset&&D(w,"<rb>Deprecated option</>\n\n The <b>offset</> option has been renamed to <b>offsetSize</>. Use of the old name will be removed in a future version of <i>iframe-resizer</>.")}(e),Z[w].warningTimeout||N(w,"warningTimeout:%c disabled",t),null===Z[w].postMessageTarget&&(Z[w].postMessageTarget=i.contentWindow),Z[w].targetOrigin=!0===Z[w].checkOrigin?""===(n=Z[w].remoteHost)||null!==n.match(/^(about:blank|javascript:|file:\/\/)/)?"*":n:"*"}const v=()=>"iframeResizer"in i,w=function(t){if(t&&"string"!=typeof t)throw new TypeError("Invalid id for iFrame. Expected String");return""!==t&&t||(t=function(){let i=e?.id||X.id+le++;return null!==document.getElementById(i)&&(i+=le++),i}(),i.id=t,W(t,`Added missing iframe ID: ${t} (${i.src})`)),t}(i.id);if("object"!=typeof e)throw new TypeError("Options is not an object");return function(e){const{search:i}=window.location;i.includes("ifrlog")&&(e.log=p,e.logExpand=!i.includes("ifrlog=collapsed"))}(e),function(e,i){const t=x(i,"log"),o="string"==typeof i.log,n=t?!!o||i.log:X.log;x(i,"logExpand")||(i.logExpand=t&&o?i.log===p:X.logExpand),function(e){-1===e?.log&&(e.log=!1,ue=!0)}(i),function({enabled:e,expand:i,iframeId:t}){const o=S({expand:i,label:E(t)});C=e,R[t]||(R[t]={console:o})}({enabled:n,expand:i.logExpand,iframeId:e}),o&&!(i.log in h)&&H(e,'Invalid value for options.log: Accepted values are "expanded" and "collapsed"'),i.log=n}(w,e),q(w,function(e){v()?B(w,`Ignored iframe (${w}), already setup.`):(b(e),function(){if(de)return;const{mode:e}=Z[w];-1!==e&&fe(w,e)}(),he(),function(){switch(W(w,`Iframe scrolling ${Z[w]?.scrolling?"enabled":"disabled"} for ${w}`),i.style.overflow=!1===Z[w]?.scrolling?"hidden":"auto",Z[w]?.scrolling){case"omit":break;case!0:i.scrolling="yes";break;case!1:i.scrolling="no";break;default:i.scrolling=Z[w]?Z[w].scrolling:"no"}}(),function(){const{bodyMargin:e}=Z[w];"number"!=typeof e&&"0"!==e||(Z[w].bodyMargin=`${e}px`)}(),n(ae(w)),o(),W(w,"Setup complete"))})(e),i?.iframeResizer};function me(){!1===document.hidden&&(W("document","Trigger event: Visibility change"),function(e,i){const t=e=>Z[e]?.autoResize&&!Z[e]?.firstRun;Object.keys(Z).forEach(function(o){t(o)&&se(e,i,o)})}("tabVisible","resize"))}const he=(e=>{let i=!1;return function(){return i?void 0:(i=!0,Reflect.apply(e,this,arguments))}})(()=>{g(window,"message",_),g(document,"visibilitychange",me),window.iframeParentListener=e=>setTimeout(()=>_({data:e,sameOrigin:!0}))});export{pe as default};
|
|
21
21
|
//# sourceMappingURL=index.esm.js.map
|
package/index.umd.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
* @preserve
|
|
3
3
|
*
|
|
4
|
-
* @module iframe-resizer/core 5.5.3-beta.
|
|
4
|
+
* @module iframe-resizer/core 5.5.3-beta.7 (umd) - 2025-08-19
|
|
5
5
|
*
|
|
6
6
|
* @license GPL-3.0 for non-commercial use only.
|
|
7
7
|
* For commercial use, you must purchase a license from
|
|
@@ -17,5 +17,5 @@
|
|
|
17
17
|
*/
|
|
18
18
|
|
|
19
19
|
|
|
20
|
-
!function(e,i){"object"==typeof exports&&"undefined"!=typeof module?module.exports=i(require("auto-console-group")):"function"==typeof define&&define.amd?define(["auto-console-group"],i):(e="undefined"!=typeof globalThis?globalThis:e||self).createResizer=i(e.acg)}(this,function(e){"use strict";const i="5.5.3-beta.6",t="none",o="vertical",n="horizontal",r="[iFrameSizer]",s=Object.freeze({max:1,scroll:1,bodyScroll:1,documentElementScroll:1}),a="onload",l="init",c=Object.freeze({[a]:1,[l]:1}),d="expanded",u="collapsed",f=Object.freeze({[d]:1,[u]:1}),p=(e,i,t,o)=>e.addEventListener(i,t,o||!1),m=(e,i,t)=>e.removeEventListener(i,t,!1),h=e=>{if(!e)return"";let i=-559038744,t=1103547984;for(let o,n=0;n<e.length;n++)o=e.codePointAt(n),i=Math.imul(i^o,2246822519),t=Math.imul(t^o,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)},g=e=>e.replace(/[A-Za-z]/g,e=>String.fromCodePoint((e<="Z"?90:122)>=(e=e.codePointAt(0)+19)?e:e-26)),y=["spjluzl","rlf","clyzpvu"],b=["<yi>Puchspk Spjluzl Rlf</><iy><iy>","<yi>Tpzzpun Spjluzl Rlf</><iy><iy>","Aopz spiyhyf pz hchpshisl dpao ivao Jvttlyjphs huk Vwlu-Zvbyjl spjluzlz.<iy><iy><i>Jvttlyjphs Spjluzl</><iy>Mvy jvttlyjphs bzl, <p>pmyhtl-ylzpgly</> ylxbpylz h svd jvza vul aptl spjluzl mll. Mvy tvyl pumvythapvu cpzpa <b>oaawz://pmyhtl-ylzpgly.jvt/wypjpun</>.<iy><iy><i>Vwlu Zvbyjl Spjluzl</><iy>Pm fvb hyl bzpun aopz spiyhyf pu h uvu-jvttlyjphs vwlu zvbyjl wyvqlja aolu fvb jhu bzl pa mvy myll bukly aol alytz vm aol NWS C3 Spjluzl. Av jvumpyt fvb hjjlwa aolzl alytz, wslhzl zla aol <i>spjluzl</> rlf pu <p>pmyhtl-ylzpgly</> vwapvuz av <i>NWSc3</>.<iy><iy>Mvy tvyl pumvythapvu wslhzl zll: <b>oaawz://pmyhtl-ylzpgly.jvt/nws</>","<i>NWSc3 Spjluzl Clyzpvu</><iy><iy>Aopz clyzpvu vm <p>pmyhtl-ylzpgly</> pz ilpun bzlk bukly aol alytz vm aol <i>NWS C3</> spjluzl. Aopz spjluzl hssvdz fvb av bzl <p>pmyhtl-ylzpgly</> pu Vwlu Zvbyjl wyvqljaz, iba pa ylxbpylz fvby wyvqlja av il wbispj, wyvcpkl haaypibapvu huk il spjluzlk bukly clyzpvu 3 vy shaly vm aol NUB Nlulyhs Wbispj Spjluzl.<iy><iy>Pm fvb hyl bzpun aopz spiyhyf pu h uvu-vwlu zvbyjl wyvqlja vy dlizpal, fvb dpss ullk av wbyjohzl h svd jvza vul aptl jvttlyjphs spjluzl.<iy><iy>Mvy tvyl pumvythapvu cpzpa <b>oaawz://pmyhtl-ylzpgly.jvt/wypjpun</>.","<iy><yi>Zvsv spjluzl kvlz uva zbwwvya jyvzz-kvthpu</><iy><iy>Av bzl <p>pmyhtl-ylzpgly</> dpao jyvzz kvthpu pmyhtlz fvb ullk lpaoly aol Wyvmlzzpvuhs vy Ibzpulzz spjluzlz. Mvy klahpsz vu bwnyhkl wypjpun wslhzl jvuahja pumv@pmyhtl-ylzpgly.jvt."],v=["NWSc3","zvsv","wyv","ibzpulzz","vlt"],w=Object.fromEntries(["2cgs7fdf4xb","1c9ctcccr4z","1q2pc4eebgb","ueokt0969w","w2zxchhgqz","1umuxblj2e5"].map((e,i)=>[e,Math.max(0,i-1)])),z=e=>g(b[e]),H=e=>{const i=e[g(y[0])]||e[g(y[1])]||e[g(y[2])];if(!i)return-1;const t=i.split("-");let o=function(e=""){let i=-2;const t=h(g(e));return t in w&&(i=w[t]),i}(t[0]);return 0===o||(e=>e[2]===h(e[0]+e[1]))(t)||(o=-2),o},I=Object.hasOwn||((e,i)=>Object.prototype.hasOwnProperty.call(e,i)),$=e=>e,T=e=>i=>window.chrome?e(i.replaceAll("<br>","\n").replaceAll("<rb>","[31;1m").replaceAll("</>","[m").replaceAll("<b>","[1m").replaceAll("<i>","[3m").replaceAll("<u>","[4m")):e((e=>e.replaceAll("<br>","\n").replaceAll(/<[/a-z]+>/gi,""))(i)),j=(k=e,k?.__esModule?k.default:k);var k;let G={},R=!1;const O=e=>window.top===window.self?`parent(${e})`:`nested parent(${e})`;const L=e=>(i,...t)=>G[i]?.console[e](...t),x=(M="log",(e,...i)=>!0===(e=>G[e]?G[e].log:R)(e)?L(M)(e,...i):null);var M;const S=x,E=L("warn"),C=L("error"),A=L("event"),N=L("purge"),W=L("errorBoundary");const F=(e,...i)=>G[e]?G[e].console.warn(T($)(...i)):queueMicrotask(()=>console?.warn(T((e=>(...i)=>[`iframeResizer(${e})`,...i].join(" "))(e))(...i))),B=(e=>(i,t="renamed to")=>(o,n,r="",s="")=>e(s,`<rb>Deprecated ${i}(${o.replace("()","")})</>\n\nThe <b>${o}</> ${i.toLowerCase()} has been ${t} <b>${n}</>. ${r}Use of the old ${i.toLowerCase()} will be removed in a future version of <i>iframe-resizer</>.`))(F),P=B("Option");function D(e,i){const{msgTimeout:t,warningTimeout:o}=i[e];o&&(t&&clearTimeout(t),i[e].msgTimeout=setTimeout(function(){if(void 0===i[e])return;const{ready:t,loadErrorShown:o}=i[e];i[e].msgTimeout=void 0,t||o||(i[e].loadErrorShown=!0,function(e,i){const{iframe:t,waitForLoad:o}=i[e],{sandbox:n}=t,r="object"==typeof n&&n.length>0&&!(n.contains("allow-scripts")&&n.contains("allow-same-origin"));A(e,"noResponse"),F(e,`<rb>No response from iframe</>\n \nThe iframe (<i>${e}</>) has not responded within ${i[e].warningTimeout/1e3} seconds. Check <b>@iframe-resizer/child</> package has been loaded in the iframe.\n${o?"\nThe <b>waitForLoad</> option is currently set to <b>'true'</>. If the iframe loads before <i>iframe-resizer</> runs, this option will prevent <i>iframe-resizer</> initialising. To disable this option, set <b>waitForLoad</> to <b>'false'</>. \n":""}${r?"\nThe iframe has the <b>sandbox</> attribute, please ensure it contains both the <i>'allow-same-origin'</> and <i>'allow-scripts'</> values.\n":""}\nThis message can be ignored if everything is working, or you can set the <b>warningTimeout</> option to a higher value or zero to suppress this warning.\n`)}(e,i))},o))}const U={},q=Object.freeze({autoResize:!0,bodyBackground:null,bodyMargin:null,bodyPadding:null,checkOrigin:!0,direction:o,inPageLinks:!1,heightCalculationMethod:"auto",id:"iFrameResizer",log:!1,logExpand:!1,license:void 0,mouseEvents:!0,offsetHeight:null,offsetWidth:null,postMessageTarget:null,sameDomain:!1,scrolling:!1,sizeHeight:!0,sizeWidth:!1,tolerance:0,waitForLoad:!1,warningTimeout:5e3,widthCalculationMethod:"auto",onBeforeClose:()=>!0,onAfterClose(){},onInit:!1,onMessage:null,onMouseEnter(){},onMouseLeave(){},onReady:e=>{"function"==typeof U[e.id].onInit&&(P("init()","onReady()","",e.id),U[e.id].onInit(e))},onResized(){},onScroll:()=>!0}),J={position:null,version:i};function V(t){function o(){ie(k),Q(G),I("onResized",k)}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 s(e){if("border-box"!==e.boxSizing)return 0;return(e.borderTopWidth?parseInt(e.borderTopWidth,10):0)+(e.borderBottomWidth?parseInt(e.borderBottomWidth,10):0)}const a=e=>j.slice(j.indexOf(":")+7+e);const l=(e,i)=>(t,o)=>{const n={};var r,s;r=function(){oe(`${t} (${e})`,`${e}:${i()}`,o)},n[s=o]||(r(),n[s]=requestAnimationFrame(()=>{n[s]=null}))},c=(e,i)=>()=>{let t=!1;const o=i=>()=>{U[l]?t&&t!==i||(e(i,l),t=i,requestAnimationFrame(()=>{t=!1})):a()},n=o("scroll"),r=o("resize window");function s(e,t){x(l,`${e}listeners for send${i}`),t(window,"scroll",n),t(window,"resize",r)}function a(){A(l,`stop${i}`),s("Remove ",m),c.disconnect(),d.disconnect(),m(U[l].iframe,"load",a)}const l=G,c=new ResizeObserver(o("pageObserver")),d=new ResizeObserver(o("iframeObserver"));U[l]&&(U[l][`stop${i}`]=a,p(U[l].iframe,"load",a),s("Add ",p),c.observe(document.body,{attributes:!0,childList:!0,subtree:!0}),d.observe(U[l].iframe,{attributes:!0,childList:!1,subtree:!1}))},d=e=>()=>{e in U[G]&&(U[G][e](),delete U[G][e])},u=l("pageInfo",function(){const e=document.body.getBoundingClientRect(),i=k.iframe.getBoundingClientRect(),{scrollY:t,scrollX:o,innerHeight:n,innerWidth:r}=window,{clientHeight:s,clientWidth:a}=document.documentElement;return JSON.stringify({iframeHeight:i.height,iframeWidth:i.width,clientHeight:Math.max(s,n||0),clientWidth:Math.max(a,r||0),offsetTop:parseInt(i.top-e.top,10),offsetLeft:parseInt(i.left-e.left,10),scrollTop:t,scrollLeft:o,documentHeight:s,documentWidth:a,windowHeight:n,windowWidth:r})}),f=l("parentInfo",function(){const{iframe:e}=k,{scrollWidth:i,scrollHeight:t}=document.documentElement,{width:o,height:n,offsetLeft:r,offsetTop:s,pageLeft:a,pageTop:l,scale:c}=window.visualViewport;return JSON.stringify({iframe:e.getBoundingClientRect(),document:{scrollWidth:i,scrollHeight:t},viewport:{width:o,height:n,offsetLeft:r,offsetTop:s,pageLeft:a,pageTop:l,scale:c}})}),h=c(u,"PageInfo"),g=c(f,"ParentInfo"),y=d("stopPageInfo"),b=d("stopParentInfo");function v(e){const i=e.getBoundingClientRect();return _(G),{x:Number(i.left)+Number(J.position.x),y:Number(i.top)+Number(J.position.y)}}function w(i){const t=i?v(k.iframe):{x:0,y:0};S(G,`Reposition requested (offset x:%c${t.x}%c y:%c${t.y})`,e.HIGHLIGHT,e.FOREGROUND,e.HIGHLIGHT);const o=((e,i)=>({x:e.width+i.x,y:e.height+i.y}))(k,t),n=window.parentIframe||window.parentIFrame;n?function(e,t){e["scrollTo"+(i?"Offset":"")](t.x,t.y)}(n,o):function(e){J.position=e,z(G)}(o)}function z(e){const{x:i,y:t}=J.position,o=U[e]?.iframe;!1!==I("onScroll",{iframe:o,top:t,left:i,x:i,y:t})?Q(e):K()}function H(e){let i={};if(0===k.width&&0===k.height){const e=a(9).split(":");i={x:e[1],y:e[0]}}else i={x:k.width,y:k.height};I(e,{iframe:k.iframe,screenX:Number(i.x),screenY:Number(i.y),type:k.type})}const I=(e,i)=>Z(G,e,i);function $(){const{height:t,iframe:n,msg:r,type:s,width:l}=k;switch(U[G]?.firstRun&&function(){if(!U[G])return;ce(G,k.mode),U[G].firstRun=!1}(),s){case"close":Y(n);break;case"message":d=a(6),x(G,`onMessage passed: {iframe: %c${k.iframe.id}%c, message: %c${d}%c}`,e.HIGHLIGHT,e.FOREGROUND,e.HIGHLIGHT,e.FOREGROUND),I("onMessage",{iframe:k.iframe,message:JSON.parse(d)});break;case"mouseenter":H("onMouseEnter");break;case"mouseleave":H("onMouseLeave");break;case"autoResize":U[G].autoResize=JSON.parse(a(9));break;case"scrollBy":!function(){const i=k.width,t=k.height,o=window.parentIframe||window.parentIFrame||window;S(G,`scrollBy: x: %c${i}%c y: %c${t}`,e.HIGHLIGHT,e.FOREGROUND,e.HIGHLIGHT),o.scrollBy(i,t)}();break;case"scrollTo":w(!1);break;case"scrollToOffset":w(!0);break;case"pageInfo":h();break;case"parentInfo":g();break;case"pageInfoStop":y();break;case"parentInfoStop":b();break;case"inPageLink":!function(i){const t=i.split("#")[1]||"",o=decodeURIComponent(t);let n=document.getElementById(o)||document.getElementsByName(o)[0];n?function(){const i=v(n);S(G,`Moving to in page link: %c#${t}`,e.HIGHLIGHT),J.position={x:i.x,y:i.y},z(G),window.location.hash=t}():window.top!==window.self?function(){const e=window.parentIframe||window.parentIFrame;e?e.moveToAnchor(t):x(G,`In page link #${t} not found and window.parentIframe not found`)}():x(G,`In page link #${t} not found`)}(a(9));break;case"title":!function(i,t){U[t]?.syncTitle&&(U[t].iframe.title=i,S(t,`Set iframe title attribute: %c${i}`,e.HIGHLIGHT))}(r,G);break;case"reset":ee(k);break;case"init":o(),function(i){try{U[i].sameOrigin=!!U[i]?.iframe?.contentWindow?.iframeChildListener}catch(e){U[i].sameOrigin=!1}x(i,`sameOrigin: %c${U[i].sameOrigin}`,e.HIGHLIGHT)}(G),(c=r)!==i&&(void 0!==c?x(G,`Version mismatch (Child: %c${c}%c !== Parent: %c${i})`,e.HIGHLIGHT,e.FOREGROUND,e.HIGHLIGHT):F(G,"<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")),se=!0,I("onReady",n);break;default:if(0===l&&0===t)return void E(G,`Unsupported message received (${s}), this is likely due to the iframe containing a later version of iframe-resizer than the parent page`);if(0===l||0===t)return void x(G,"Ignoring message with 0 height or width");if(document.hidden)return void x(G,"Page hidden - ignored resize request");o()}var c,d}function T(e){U[e].loaded||(oe("iframe requested init",ne(e),e),D(e,U))}let j=t.data,k={},G=null;"[iFrameResizerChild]Ready"!==j?r===`${j}`.slice(0,13)&&j.slice(13).split(":")[0]in U?(k=function(){const e=j.slice(13).split(":"),i=e[1]?Number(e[1]):0,t=U[e[0]]?.iframe,o=getComputedStyle(t),r={iframe:t,id:e[0],height:i+n(o)+s(o),width:Number(e[2]),type:e[3],msg:e[4]};return e[5]&&(r.mode=e[5]),r}(),G=k.id,G?(A(G,k.type),W(G,function(){!function(e){if(!U[e])throw new Error(`${k.type} No settings for ${e}. Message was: ${j}`)}(G),function(){const e=k.type in{true:1,false:1,undefined:1};return e&&x(G,"Ignoring init message from meta parent page"),e}()||(x(G,`Received: %c${j}`,e.HIGHLIGHT),U[G].loaded=!0,U[G].ready=!0,(null!==k.iframe||(E(G,`The iframe (${k.id}) was not found.`),0))&&function(){const{origin:i,sameOrigin:o}=t;if(o)return!0;let n=U[G]?.checkOrigin;if(n&&"null"!=`${i}`&&!(n.constructor===Array?function(){let t=0,o=!1;for(x(G,`Checking connection is from allowed list of origins: %c${n}`,e.HIGHLIGHT);t<n.length;t++)if(n[t]===i){o=!0;break}return o}():function(){const t=U[G]?.remoteHost;return x(G,`Checking connection is from: %c${t}`,e.HIGHLIGHT),i===t}()))throw new Error(`Unexpected message received from: ${i} for ${k.iframe.id}. Message was: ${t.data}. This error can be disabled by setting the checkOrigin: false option or by providing of array of trusted domains.`);return!0}()&&$())})()):E("","iframeResizer received messageData without id, message was: ",j)):null!==G&&x(G,"Ignored:",j):Object.keys(U).forEach(T)}function Z(e,i,t){let o=null,n=null;if(U[e]){if(o=U[e][i],"function"!=typeof o)throw new TypeError(`${i} on iFrame[${e}] is not a function`);if("onBeforeClose"===i||"onScroll"===i)try{n=o(t)}catch(t){console.error(t),E(e,`Error in ${i} callback`)}else((e,...i)=>{setTimeout(()=>e(...i),0)})(o,t)}return n}function X(e){const{id:i}=e;x(i,"Disconnected from iframe"),delete U[i],delete e.iframeResizer}function Y(i){const{id:t}=i;if(!1!==Z(t,"onBeforeClose",t)){x(t,`Removing iFrame: %c${t}`,e.HIGHLIGHT);try{i.parentNode&&i.remove()}catch(e){E(t,e)}Z(t,"onAfterClose",t),X(i)}else x(t,"Close iframe cancelled by onBeforeClose")}function _(i){null===J.position&&(J.position={x:window.scrollX,y:window.scrollY},x(i,`Get page position: %c${J.position.x}%c, %c${J.position.y}`,e.HIGHLIGHT,e.FOREGROUND,e.HIGHLIGHT))}function K(){J.position=null}function Q(i){null!==J.position&&(window.scrollTo(J.position.x,J.position.y),S(i,`Set page position: %c${J.position.x}%c, %c${J.position.y}`,e.HIGHLIGHT,e.FOREGROUND,e.HIGHLIGHT),K())}function ee(e){x(e.id,"Size reset requested by "+("init"===e.type?"parent page":"child page")),_(e.id),ie(e),oe("reset","reset",e.id)}function ie(i){function t(t){const n=`${i[t]}px`;i.iframe.style[t]=n,S(o,`Set ${t}: %c${n}`,e.HIGHLIGHT)}const{id:o}=i,{sizeHeight:n,sizeWidth:r}=U[o];n&&t("height"),r&&t("width")}G=U;const te=e=>e.split(":").filter((e,i)=>19!==i).join(":");function oe(i,t,o){function n(n){const r=i in c?te(t):t;S(o,n,e.HIGHLIGHT,e.FOREGROUND,e.HIGHLIGHT),S(o,`Message data: %c${r}`,e.HIGHLIGHT)}A(o,i),U[o]&&(U[o]?.postMessageTarget?function(){const{iframe:e,postMessageTarget:i,sameOrigin:s,targetOrigin:a}=U[o];if(s)try{return e.contentWindow.iframeChildListener(r+t),void n(`Sending message to iframe %c${o}%c via sameOrigin`)}catch(e){x(o,"Same domain connection failed. Trying cross domain%c")}n(`Sending message to iframe: %c${o}%c targetOrigin: %c${a}`),i.postMessage(r+t,a)}():E(o,`Iframe(${o}) not found`))}function ne(e){const i=U[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,"",i.logExpand].join(":")}let re=0,se=!1,ae=!1,le=!1;function ce(t,o=-3){if(ae)return;const n=Math.max(U[t].mode,o);if(n>U[t].mode&&(U[t].mode=n),n<0)throw N(t),U[t].vAdvised||F(t||"Parent",`${z(n+2)}${z(2)}`),U[t].vAdvised=!0,z(n+2).replace(/<\/?[a-z][^>]*>|<\/>/gi,"");n>-1&&le||function(i,t){queueMicrotask(()=>console.info(`%ciframe-resizer ${i}`,R||t<1?"font-weight: bold;":e.NORMAL))}(`v${i} (${(e=>g(v[e]))(n)})`,n),n<1&&F("Parent",z(3)),ae=!0}function de(){!1===document.hidden&&(x("document","Trigger event: Visibility change"),function(e,i){const t=e=>U[e]?.autoResize&&!U[e]?.firstRun;Object.keys(U).forEach(function(o){t(o)&&oe(e,i,o)})}("tabVisible","resize"))}const ue=(e=>{let i=!1;return function(){return i?void 0:(i=!0,Reflect.apply(e,this,arguments))}})(()=>{p(window,"message",V),p(document,"visibilitychange",de),window.iframeParentListener=e=>setTimeout(()=>V({data:e,sameOrigin:!0}))});return i=>r=>{function c(){if(U[w]){const{iframe:e}=U[w],i={close:Y.bind(null,e),disconnect:X.bind(null,e),removeListeners(){F(w,"<rb>Deprecated Method Name</>\n\nThe [removeListeners()</> method has been renamed to [disconnect()</>.\n"),this.disconnect()},resize(){F(w,"<rb>Deprecated Method</>\n \nUse of the <b>resize()</> method from the parent page is deprecated and will be removed in a future version of <i>iframe-resizer</>. As their are no longer any edge cases that require triggering a resize from the parent page, it is recommended to remove this method from your code."),oe.bind(null,"Window resize","resize",w)},moveToAnchor(e){((e,i,t)=>{if(typeof e!==i)throw new TypeError(`${t} is not a ${o=i,o.charAt(0).toUpperCase()+o.slice(1)}`);var o})(e,"string","moveToAnchor(anchor) anchor"),oe("Move to anchor",`moveToAnchor:${e}`,w)},sendMessage(e){oe("message",`message:${e=JSON.stringify(e)}`,w)}};e.iframeResizer=i,e.iFrameResizer=i}}function u(e){const{id:i}=r,{waitForLoad:t}=U[i];p(r,"load",function(){oe(a,`${e}:${se}`,i),U[i].loaded=!0,D(i,U),function(){const e=U[w]?.firstRun,i=U[w]?.heightCalculationMethod in s;!e&&i&&ee({iframe:r,height:0,width:0,type:"init"})}()}),!0!==t&&(oe(l,`${e}:${se}`,i),D(i,U))}function m(e){return e?(("sizeWidth"in e||"sizeHeight"in e||"autoResize"in e)&&F(w,`<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>"${o}"</>, <i>"${n}"</> or <i>"${t}"</>.\n`),e):{}}function h(e){const i=U[e]?.iframe?.title;return""===i||void 0===i}function g(e,i){I(U[w],e)&&(F(w,`<rb>Deprecated option</>\n\nThe <b>${e}</> option has been renamed to <b>${i}</>. Use of the old name will be removed in a future version of <i>iframe-resizer</>.`),U[w][i]=U[w][e],delete U[w][e])}const y=e=>I(e,"onMouseEnter")||I(e,"onMouseLeave");function b(i){var s,a;U[w]={...U[w],iframe:r,firstRun:!0,remoteHost:r?.src.split("/").slice(0,3).join("/"),...q,...m(i),mouseEvents:y(i),mode:H(i),syncTitle:h(w)},g("offset","offsetSize"),g("onClose","onBeforeClose"),g("onClosed","onAfterClose"),A(w,"setup"),function(){const{direction:i}=U[w];switch(i){case o:break;case n:U[w].sizeHeight=!1;case"both":U[w].sizeWidth=!0;break;case t:U[w].sizeWidth=!1,U[w].sizeHeight=!1,U[w].autoResize=!1;break;default:throw new TypeError(w,`Direction value of "${i}" is not valid`)}x(w,`direction: %c${i}`,e.HIGHLIGHT)}(),(s=i?.offsetSize||i?.offset)&&(U[w].direction===o?(U[w].offsetHeight=s,x(w,`Offset height: %c${s}`,e.HIGHLIGHT)):(U[w].offsetWidth=s,x(w,`Offset width: %c${s}`,e.HIGHLIGHT))),function(e){e?.offset&&F(w,"<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</>.")}(i),U[w].warningTimeout||S(w,"warningTimeout:%c disabled",e.HIGHLIGHT),null===U[w].postMessageTarget&&(U[w].postMessageTarget=r.contentWindow),U[w].targetOrigin=!0===U[w].checkOrigin?""===(a=U[w].remoteHost)||null!==a.match(/^(about:blank|javascript:|file:\/\/)/)?"*":a:"*"}const v=()=>"iframeResizer"in r,w=function(e){if(e&&"string"!=typeof e)throw new TypeError("Invalid id for iFrame. Expected String");return""!==e&&e||(e=function(){let e=i?.id||q.id+re++;return null!==document.getElementById(e)&&(e+=re++),e}(),r.id=e,x(e,`Added missing iframe ID: ${e} (${r.src})`)),e}(r.id);if("object"!=typeof i)throw new TypeError("Options is not an object");return function(e){const{search:i}=window.location;i.includes("ifrlog")&&(e.log=d,e.logExpand=!i.includes("ifrlog=collapsed"))}(i),function(e,i){const t=I(i,"log"),o="string"==typeof i.log,n=t?!!o||i.log:q.log;I(i,"logExpand")||(i.logExpand=t&&o?i.log===d:q.logExpand),function(e){-1===e?.log&&(e.log=!1,le=!0)}(i),function({enabled:e,expand:i,iframeId:t}){const o=j({expand:i,label:O(t)});R=e,G[t]||(G[t]={console:o})}({enabled:n,expand:i.logExpand,iframeId:e}),o&&!(i.log in f)&&C(e,'Invalid value for options.log: Accepted values are "expanded" and "collapsed"'),i.log=n}(w,i),W(w,function(e){v()?E(w,`Ignored iframe (${w}), already setup.`):(b(e),function(){if(ae)return;const{mode:e}=U[w];-1!==e&&ce(w,e)}(),ue(),function(){switch(x(w,`Iframe scrolling ${U[w]?.scrolling?"enabled":"disabled"} for ${w}`),r.style.overflow=!1===U[w]?.scrolling?"hidden":"auto",U[w]?.scrolling){case"omit":break;case!0:r.scrolling="yes";break;case!1:r.scrolling="no";break;default:r.scrolling=U[w]?U[w].scrolling:"no"}}(),function(){const{bodyMargin:e}=U[w];"number"!=typeof e&&"0"!==e||(U[w].bodyMargin=`${e}px`)}(),u(ne(w)),c(),x(w,"Setup complete"))})(i),r?.iframeResizer}});
|
|
20
|
+
!function(e,i){"object"==typeof exports&&"undefined"!=typeof module?module.exports=i(require("auto-console-group")):"function"==typeof define&&define.amd?define(["auto-console-group"],i):(e="undefined"!=typeof globalThis?globalThis:e||self).createResizer=i(e.acg)}(this,function(e){"use strict";const i="5.5.3-beta.7",t="none",o="vertical",n="horizontal",r="[iFrameSizer]",s=Object.freeze({max:1,scroll:1,bodyScroll:1,documentElementScroll:1}),a="onload",l="init",c=Object.freeze({[a]:1,[l]:1}),d="expanded",u="collapsed",f=Object.freeze({[d]:1,[u]:1}),p=(e,i,t,o)=>e.addEventListener(i,t,o||!1),m=(e,i,t)=>e.removeEventListener(i,t,!1),h=e=>{if(!e)return"";let i=-559038744,t=1103547984;for(let o,n=0;n<e.length;n++)o=e.codePointAt(n),i=Math.imul(i^o,2246822519),t=Math.imul(t^o,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)},g=e=>e.replace(/[A-Za-z]/g,e=>String.fromCodePoint((e<="Z"?90:122)>=(e=e.codePointAt(0)+19)?e:e-26)),y=["spjluzl","rlf","clyzpvu"],b=["<yi>Puchspk Spjluzl Rlf</><iy><iy>","<yi>Tpzzpun Spjluzl Rlf</><iy><iy>","Aopz spiyhyf pz hchpshisl dpao ivao Jvttlyjphs huk Vwlu-Zvbyjl spjluzlz.<iy><iy><i>Jvttlyjphs Spjluzl</><iy>Mvy jvttlyjphs bzl, <p>pmyhtl-ylzpgly</> ylxbpylz h svd jvza vul aptl spjluzl mll. Mvy tvyl pumvythapvu cpzpa <b>oaawz://pmyhtl-ylzpgly.jvt/wypjpun</>.<iy><iy><i>Vwlu Zvbyjl Spjluzl</><iy>Pm fvb hyl bzpun aopz spiyhyf pu h uvu-jvttlyjphs vwlu zvbyjl wyvqlja aolu fvb jhu bzl pa mvy myll bukly aol alytz vm aol NWS C3 Spjluzl. Av jvumpyt fvb hjjlwa aolzl alytz, wslhzl zla aol <i>spjluzl</> rlf pu <p>pmyhtl-ylzpgly</> vwapvuz av <i>NWSc3</>.<iy><iy>Mvy tvyl pumvythapvu wslhzl zll: <b>oaawz://pmyhtl-ylzpgly.jvt/nws</>","<i>NWSc3 Spjluzl Clyzpvu</><iy><iy>Aopz clyzpvu vm <p>pmyhtl-ylzpgly</> pz ilpun bzlk bukly aol alytz vm aol <i>NWS C3</> spjluzl. Aopz spjluzl hssvdz fvb av bzl <p>pmyhtl-ylzpgly</> pu Vwlu Zvbyjl wyvqljaz, iba pa ylxbpylz fvby wyvqlja av il wbispj, wyvcpkl haaypibapvu huk il spjluzlk bukly clyzpvu 3 vy shaly vm aol NUB Nlulyhs Wbispj Spjluzl.<iy><iy>Pm fvb hyl bzpun aopz spiyhyf pu h uvu-vwlu zvbyjl wyvqlja vy dlizpal, fvb dpss ullk av wbyjohzl h svd jvza vul aptl jvttlyjphs spjluzl.<iy><iy>Mvy tvyl pumvythapvu cpzpa <b>oaawz://pmyhtl-ylzpgly.jvt/wypjpun</>.","<iy><yi>Zvsv spjluzl kvlz uva zbwwvya jyvzz-kvthpu</><iy><iy>Av bzl <p>pmyhtl-ylzpgly</> dpao jyvzz kvthpu pmyhtlz fvb ullk lpaoly aol Wyvmlzzpvuhs vy Ibzpulzz spjluzlz. Mvy klahpsz vu bwnyhkl wypjpun wslhzl jvuahja pumv@pmyhtl-ylzpgly.jvt."],v=["NWSc3","zvsv","wyv","ibzpulzz","vlt"],w=Object.fromEntries(["2cgs7fdf4xb","1c9ctcccr4z","1q2pc4eebgb","ueokt0969w","w2zxchhgqz","1umuxblj2e5"].map((e,i)=>[e,Math.max(0,i-1)])),z=e=>g(b[e]),H=e=>{const i=e[g(y[0])]||e[g(y[1])]||e[g(y[2])];if(!i)return-1;const t=i.split("-");let o=function(e=""){let i=-2;const t=h(g(e));return t in w&&(i=w[t]),i}(t[0]);return 0===o||(e=>e[2]===h(e[0]+e[1]))(t)||(o=-2),o},I=Object.hasOwn||((e,i)=>Object.prototype.hasOwnProperty.call(e,i)),$=e=>e,T=e=>i=>window.chrome?e(i.replaceAll("<br>","\n").replaceAll("<rb>","[31;1m").replaceAll("</>","[m").replaceAll("<b>","[1m").replaceAll("<i>","[3m").replaceAll("<u>","[4m")):e((e=>e.replaceAll("<br>","\n").replaceAll(/<[/a-z]+>/gi,""))(i)),j=(k=e,k?.__esModule?k.default:k);var k;let G={},R=!1;const O=e=>window.top===window.self?`parent(${e})`:`nested parent(${e})`;const L=e=>(i,...t)=>G[i]?.console[e](...t),x=(M="log",(e,...i)=>!0===(e=>G[e]?G[e].log:R)(e)?L(M)(e,...i):null);var M;const S=x,E=L("warn"),C=L("error"),A=L("event"),N=L("purge"),W=L("errorBoundary");const F=(e,...i)=>G[e]?G[e].console.warn(T($)(...i)):queueMicrotask(()=>console?.warn(T((e=>(...i)=>[`iframeResizer(${e})`,...i].join(" "))(e))(...i))),B=(e=>(i,t="renamed to")=>(o,n,r="",s="")=>e(s,`<rb>Deprecated ${i}(${o.replace("()","")})</>\n\nThe <b>${o}</> ${i.toLowerCase()} has been ${t} <b>${n}</>. ${r}Use of the old ${i.toLowerCase()} will be removed in a future version of <i>iframe-resizer</>.`))(F),P=B("Option");function D(e,i){const{msgTimeout:t,warningTimeout:o}=i[e];o&&(t&&clearTimeout(t),i[e].msgTimeout=setTimeout(function(){if(void 0===i[e])return;const{ready:t,loadErrorShown:o}=i[e];i[e].msgTimeout=void 0,t||o||(i[e].loadErrorShown=!0,function(e,i){const{iframe:t,waitForLoad:o}=i[e],{sandbox:n}=t,r="object"==typeof n&&n.length>0&&!(n.contains("allow-scripts")&&n.contains("allow-same-origin"));A(e,"noResponse"),F(e,`<rb>No response from iframe</>\n \nThe iframe (<i>${e}</>) has not responded within ${i[e].warningTimeout/1e3} seconds. Check <b>@iframe-resizer/child</> package has been loaded in the iframe.\n${o?"\nThe <b>waitForLoad</> option is currently set to <b>'true'</>. If the iframe loads before <i>iframe-resizer</> runs, this option will prevent <i>iframe-resizer</> initialising. To disable this option, set <b>waitForLoad</> to <b>'false'</>. \n":""}${r?"\nThe iframe has the <b>sandbox</> attribute, please ensure it contains both the <i>'allow-same-origin'</> and <i>'allow-scripts'</> values.\n":""}\nThis message can be ignored if everything is working, or you can set the <b>warningTimeout</> option to a higher value or zero to suppress this warning.\n`)}(e,i))},o))}const U={},q=Object.freeze({autoResize:!0,bodyBackground:null,bodyMargin:null,bodyPadding:null,checkOrigin:!0,direction:o,inPageLinks:!1,heightCalculationMethod:"auto",id:"iFrameResizer",log:!1,logExpand:!1,license:void 0,mouseEvents:!0,offsetHeight:null,offsetWidth:null,postMessageTarget:null,sameDomain:!1,scrolling:!1,sizeHeight:!0,sizeWidth:!1,tolerance:0,waitForLoad:!1,warningTimeout:5e3,widthCalculationMethod:"auto",onBeforeClose:()=>!0,onAfterClose(){},onInit:!1,onMessage:null,onMouseEnter(){},onMouseLeave(){},onReady:e=>{"function"==typeof U[e.id].onInit&&(P("init()","onReady()","",e.id),U[e.id].onInit(e))},onResized(){},onScroll:()=>!0}),J={position:null,version:i};function V(t){function o(){ie(k),Q(G),I("onResized",k)}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 s(e){if("border-box"!==e.boxSizing)return 0;return(e.borderTopWidth?parseInt(e.borderTopWidth,10):0)+(e.borderBottomWidth?parseInt(e.borderBottomWidth,10):0)}const a=e=>j.slice(j.indexOf(":")+7+e);const l=(e,i)=>(t,o)=>{const n={};var r,s;r=function(){oe(`${t} (${e})`,`${e}:${i()}`,o)},n[s=o]||(r(),n[s]=requestAnimationFrame(()=>{n[s]=null}))},c=(e,i)=>()=>{let t=!1;const o=i=>()=>{U[l]?t&&t!==i||(e(i,l),t=i,requestAnimationFrame(()=>{t=!1})):a()},n=o("scroll"),r=o("resize window");function s(e,t){x(l,`${e}listeners for send${i}`),t(window,"scroll",n),t(window,"resize",r)}function a(){A(l,`stop${i}`),s("Remove ",m),c.disconnect(),d.disconnect(),m(U[l].iframe,"load",a)}const l=G,c=new ResizeObserver(o("pageObserver")),d=new ResizeObserver(o("iframeObserver"));U[l]&&(U[l][`stop${i}`]=a,p(U[l].iframe,"load",a),s("Add ",p),c.observe(document.body,{attributes:!0,childList:!0,subtree:!0}),d.observe(U[l].iframe,{attributes:!0,childList:!1,subtree:!1}))},d=e=>()=>{e in U[G]&&(U[G][e](),delete U[G][e])},u=l("pageInfo",function(){const e=document.body.getBoundingClientRect(),i=k.iframe.getBoundingClientRect(),{scrollY:t,scrollX:o,innerHeight:n,innerWidth:r}=window,{clientHeight:s,clientWidth:a}=document.documentElement;return JSON.stringify({iframeHeight:i.height,iframeWidth:i.width,clientHeight:Math.max(s,n||0),clientWidth:Math.max(a,r||0),offsetTop:parseInt(i.top-e.top,10),offsetLeft:parseInt(i.left-e.left,10),scrollTop:t,scrollLeft:o,documentHeight:s,documentWidth:a,windowHeight:n,windowWidth:r})}),f=l("parentInfo",function(){const{iframe:e}=k,{scrollWidth:i,scrollHeight:t}=document.documentElement,{width:o,height:n,offsetLeft:r,offsetTop:s,pageLeft:a,pageTop:l,scale:c}=window.visualViewport;return JSON.stringify({iframe:e.getBoundingClientRect(),document:{scrollWidth:i,scrollHeight:t},viewport:{width:o,height:n,offsetLeft:r,offsetTop:s,pageLeft:a,pageTop:l,scale:c}})}),h=c(u,"PageInfo"),g=c(f,"ParentInfo"),y=d("stopPageInfo"),b=d("stopParentInfo");function v(e){const i=e.getBoundingClientRect();return _(G),{x:Number(i.left)+Number(J.position.x),y:Number(i.top)+Number(J.position.y)}}function w(i){const t=i?v(k.iframe):{x:0,y:0};S(G,`Reposition requested (offset x:%c${t.x}%c y:%c${t.y})`,e.HIGHLIGHT,e.FOREGROUND,e.HIGHLIGHT);const o=((e,i)=>({x:e.width+i.x,y:e.height+i.y}))(k,t),n=window.parentIframe||window.parentIFrame;n?function(e,t){e["scrollTo"+(i?"Offset":"")](t.x,t.y)}(n,o):function(e){J.position=e,z(G)}(o)}function z(e){const{x:i,y:t}=J.position,o=U[e]?.iframe;!1!==I("onScroll",{iframe:o,top:t,left:i,x:i,y:t})?Q(e):K()}function H(e){let i={};if(0===k.width&&0===k.height){const e=a(9).split(":");i={x:e[1],y:e[0]}}else i={x:k.width,y:k.height};I(e,{iframe:k.iframe,screenX:Number(i.x),screenY:Number(i.y),type:k.type})}const I=(e,i)=>Z(G,e,i);function $(){const{height:t,iframe:n,msg:r,type:s,width:l}=k;switch(U[G]?.firstRun&&function(){if(!U[G])return;ce(G,k.mode),U[G].firstRun=!1}(),s){case"close":Y(n);break;case"message":d=a(6),x(G,`onMessage passed: {iframe: %c${k.iframe.id}%c, message: %c${d}%c}`,e.HIGHLIGHT,e.FOREGROUND,e.HIGHLIGHT,e.FOREGROUND),I("onMessage",{iframe:k.iframe,message:JSON.parse(d)});break;case"mouseenter":H("onMouseEnter");break;case"mouseleave":H("onMouseLeave");break;case"autoResize":U[G].autoResize=JSON.parse(a(9));break;case"scrollBy":!function(){const i=k.width,t=k.height,o=window.parentIframe||window.parentIFrame||window;S(G,`scrollBy: x: %c${i}%c y: %c${t}`,e.HIGHLIGHT,e.FOREGROUND,e.HIGHLIGHT),o.scrollBy(i,t)}();break;case"scrollTo":w(!1);break;case"scrollToOffset":w(!0);break;case"pageInfo":h();break;case"parentInfo":g();break;case"pageInfoStop":y();break;case"parentInfoStop":b();break;case"inPageLink":!function(i){const t=i.split("#")[1]||"",o=decodeURIComponent(t);let n=document.getElementById(o)||document.getElementsByName(o)[0];n?function(){const i=v(n);S(G,`Moving to in page link: %c#${t}`,e.HIGHLIGHT),J.position={x:i.x,y:i.y},z(G),window.location.hash=t}():window.top!==window.self?function(){const e=window.parentIframe||window.parentIFrame;e?e.moveToAnchor(t):x(G,`In page link #${t} not found and window.parentIframe not found`)}():x(G,`In page link #${t} not found`)}(a(9));break;case"title":!function(i,t){U[t]?.syncTitle&&(U[t].iframe.title=i,S(t,`Set iframe title attribute: %c${i}`,e.HIGHLIGHT))}(r,G);break;case"reset":ee(k);break;case"init":o(),function(i){try{U[i].sameOrigin=!!U[i]?.iframe?.contentWindow?.iframeChildListener}catch(e){U[i].sameOrigin=!1}x(i,`sameOrigin: %c${U[i].sameOrigin}`,e.HIGHLIGHT)}(G),(c=r)!==i&&(void 0!==c?x(G,`Version mismatch (Child: %c${c}%c !== Parent: %c${i})`,e.HIGHLIGHT,e.FOREGROUND,e.HIGHLIGHT):F(G,"<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")),se=!0,I("onReady",n);break;default:if(0===l&&0===t)return void E(G,`Unsupported message received (${s}), this is likely due to the iframe containing a later version of iframe-resizer than the parent page`);if(0===l||0===t)return void x(G,"Ignoring message with 0 height or width");if(document.hidden)return void x(G,"Page hidden - ignored resize request");o()}var c,d}function T(e){U[e].loaded||(oe("iframe requested init",ne(e),e),D(e,U))}let j=t.data,k={},G=null;"[iFrameResizerChild]Ready"!==j?r===`${j}`.slice(0,13)&&j.slice(13).split(":")[0]in U?(k=function(){const e=j.slice(13).split(":"),i=e[1]?Number(e[1]):0,t=U[e[0]]?.iframe,o=getComputedStyle(t),r={iframe:t,id:e[0],height:i+n(o)+s(o),width:Number(e[2]),type:e[3],msg:e[4]};return e[5]&&(r.mode=e[5]),r}(),G=k.id,G?(A(G,k.type),W(G,function(){!function(e){if(!U[e])throw new Error(`${k.type} No settings for ${e}. Message was: ${j}`)}(G),function(){const e=k.type in{true:1,false:1,undefined:1};return e&&x(G,"Ignoring init message from meta parent page"),e}()||(x(G,`Received: %c${j}`,e.HIGHLIGHT),U[G].loaded=!0,U[G].ready=!0,(null!==k.iframe||(E(G,`The iframe (${k.id}) was not found.`),0))&&function(){const{origin:i,sameOrigin:o}=t;if(o)return!0;let n=U[G]?.checkOrigin;if(n&&"null"!=`${i}`&&!(n.constructor===Array?function(){let t=0,o=!1;for(x(G,`Checking connection is from allowed list of origins: %c${n}`,e.HIGHLIGHT);t<n.length;t++)if(n[t]===i){o=!0;break}return o}():function(){const t=U[G]?.remoteHost;return x(G,`Checking connection is from: %c${t}`,e.HIGHLIGHT),i===t}()))throw new Error(`Unexpected message received from: ${i} for ${k.iframe.id}. Message was: ${t.data}. This error can be disabled by setting the checkOrigin: false option or by providing of array of trusted domains.`);return!0}()&&$())})()):E("","iframeResizer received messageData without id, message was: ",j)):null!==G&&x(G,"Ignored:",j):Object.keys(U).forEach(T)}function Z(e,i,t){let o=null,n=null;if(U[e]){if(o=U[e][i],"function"!=typeof o)throw new TypeError(`${i} on iFrame[${e}] is not a function`);if("onBeforeClose"===i||"onScroll"===i)try{n=o(t)}catch(t){console.error(t),E(e,`Error in ${i} callback`)}else((e,...i)=>{setTimeout(()=>e(...i),0)})(o,t)}return n}function X(e){const{id:i}=e;x(i,"Disconnected from iframe"),delete U[i],delete e.iframeResizer}function Y(i){const{id:t}=i;if(!1!==Z(t,"onBeforeClose",t)){x(t,`Removing iFrame: %c${t}`,e.HIGHLIGHT);try{i.parentNode&&i.remove()}catch(e){E(t,e)}Z(t,"onAfterClose",t),X(i)}else x(t,"Close iframe cancelled by onBeforeClose")}function _(i){null===J.position&&(J.position={x:window.scrollX,y:window.scrollY},x(i,`Get page position: %c${J.position.x}%c, %c${J.position.y}`,e.HIGHLIGHT,e.FOREGROUND,e.HIGHLIGHT))}function K(){J.position=null}function Q(i){null!==J.position&&(window.scrollTo(J.position.x,J.position.y),S(i,`Set page position: %c${J.position.x}%c, %c${J.position.y}`,e.HIGHLIGHT,e.FOREGROUND,e.HIGHLIGHT),K())}function ee(e){x(e.id,"Size reset requested by "+("init"===e.type?"parent page":"child page")),_(e.id),ie(e),oe("reset","reset",e.id)}function ie(i){function t(t){const n=`${i[t]}px`;i.iframe.style[t]=n,S(o,`Set ${t}: %c${n}`,e.HIGHLIGHT)}const{id:o}=i,{sizeHeight:n,sizeWidth:r}=U[o];n&&t("height"),r&&t("width")}G=U;const te=e=>e.split(":").filter((e,i)=>19!==i).join(":");function oe(i,t,o){function n(n){const r=i in c?te(t):t;S(o,n,e.HIGHLIGHT,e.FOREGROUND,e.HIGHLIGHT),S(o,`Message data: %c${r}`,e.HIGHLIGHT)}A(o,i),U[o]&&(U[o]?.postMessageTarget?function(){const{iframe:e,postMessageTarget:i,sameOrigin:s,targetOrigin:a}=U[o];if(s)try{return e.contentWindow.iframeChildListener(r+t),void n(`Sending message to iframe %c${o}%c via sameOrigin`)}catch(e){x(o,"Same domain connection failed. Trying cross domain%c")}n(`Sending message to iframe: %c${o}%c targetOrigin: %c${a}`),i.postMessage(r+t,a)}():E(o,`Iframe(${o}) not found`))}function ne(e){const i=U[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,"",i.logExpand].join(":")}let re=0,se=!1,ae=!1,le=!1;function ce(t,o=-3){if(ae)return;const n=Math.max(U[t].mode,o);if(n>U[t].mode&&(U[t].mode=n),n<0)throw N(t),U[t].vAdvised||F(t||"Parent",`${z(n+2)}${z(2)}`),U[t].vAdvised=!0,z(n+2).replace(/<\/?[a-z][^>]*>|<\/>/gi,"");n>-1&&le||function(i,t){queueMicrotask(()=>console.info(`%ciframe-resizer ${i}`,R||t<1?"font-weight: bold;":e.NORMAL))}(`v${i} (${(e=>g(v[e]))(n)})`,n),n<1&&F("Parent",z(3)),ae=!0}function de(){!1===document.hidden&&(x("document","Trigger event: Visibility change"),function(e,i){const t=e=>U[e]?.autoResize&&!U[e]?.firstRun;Object.keys(U).forEach(function(o){t(o)&&oe(e,i,o)})}("tabVisible","resize"))}const ue=(e=>{let i=!1;return function(){return i?void 0:(i=!0,Reflect.apply(e,this,arguments))}})(()=>{p(window,"message",V),p(document,"visibilitychange",de),window.iframeParentListener=e=>setTimeout(()=>V({data:e,sameOrigin:!0}))});return i=>r=>{function c(){if(U[w]){const{iframe:e}=U[w],i={close:Y.bind(null,e),disconnect:X.bind(null,e),removeListeners(){F(w,"<rb>Deprecated Method Name</>\n\nThe [removeListeners()</> method has been renamed to [disconnect()</>.\n"),this.disconnect()},resize(){F(w,"<rb>Deprecated Method</>\n \nUse of the <b>resize()</> method from the parent page is deprecated and will be removed in a future version of <i>iframe-resizer</>. As their are no longer any edge cases that require triggering a resize from the parent page, it is recommended to remove this method from your code."),oe.bind(null,"Window resize","resize",w)},moveToAnchor(e){((e,i,t)=>{if(typeof e!==i)throw new TypeError(`${t} is not a ${o=i,o.charAt(0).toUpperCase()+o.slice(1)}`);var o})(e,"string","moveToAnchor(anchor) anchor"),oe("Move to anchor",`moveToAnchor:${e}`,w)},sendMessage(e){oe("message",`message:${e=JSON.stringify(e)}`,w)}};e.iframeResizer=i,e.iFrameResizer=i}}function u(e){const{id:i}=r,{waitForLoad:t}=U[i];p(r,"load",function(){oe(a,`${e}:${se}`,i),U[i].loaded=!0,D(i,U),function(){const e=U[w]?.firstRun,i=U[w]?.heightCalculationMethod in s;!e&&i&&ee({iframe:r,height:0,width:0,type:"init"})}()}),!0!==t&&(oe(l,`${e}:${se}`,i),D(i,U))}function m(e){return e?(("sizeWidth"in e||"sizeHeight"in e||"autoResize"in e)&&F(w,`<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>"${o}"</>, <i>"${n}"</> or <i>"${t}"</>.\n`),e):{}}function h(e){const i=U[e]?.iframe?.title;return""===i||void 0===i}function g(e,i){I(U[w],e)&&(F(w,`<rb>Deprecated option</>\n\nThe <b>${e}</> option has been renamed to <b>${i}</>. Use of the old name will be removed in a future version of <i>iframe-resizer</>.`),U[w][i]=U[w][e],delete U[w][e])}const y=e=>I(e,"onMouseEnter")||I(e,"onMouseLeave");function b(i){var s,a;U[w]={...U[w],iframe:r,firstRun:!0,remoteHost:r?.src.split("/").slice(0,3).join("/"),...q,...m(i),mouseEvents:y(i),mode:H(i),syncTitle:h(w)},g("offset","offsetSize"),g("onClose","onBeforeClose"),g("onClosed","onAfterClose"),A(w,"setup"),function(){const{direction:i}=U[w];switch(i){case o:break;case n:U[w].sizeHeight=!1;case"both":U[w].sizeWidth=!0;break;case t:U[w].sizeWidth=!1,U[w].sizeHeight=!1,U[w].autoResize=!1;break;default:throw new TypeError(w,`Direction value of "${i}" is not valid`)}x(w,`direction: %c${i}`,e.HIGHLIGHT)}(),(s=i?.offsetSize||i?.offset)&&(U[w].direction===o?(U[w].offsetHeight=s,x(w,`Offset height: %c${s}`,e.HIGHLIGHT)):(U[w].offsetWidth=s,x(w,`Offset width: %c${s}`,e.HIGHLIGHT))),function(e){e?.offset&&F(w,"<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</>.")}(i),U[w].warningTimeout||S(w,"warningTimeout:%c disabled",e.HIGHLIGHT),null===U[w].postMessageTarget&&(U[w].postMessageTarget=r.contentWindow),U[w].targetOrigin=!0===U[w].checkOrigin?""===(a=U[w].remoteHost)||null!==a.match(/^(about:blank|javascript:|file:\/\/)/)?"*":a:"*"}const v=()=>"iframeResizer"in r,w=function(e){if(e&&"string"!=typeof e)throw new TypeError("Invalid id for iFrame. Expected String");return""!==e&&e||(e=function(){let e=i?.id||q.id+re++;return null!==document.getElementById(e)&&(e+=re++),e}(),r.id=e,x(e,`Added missing iframe ID: ${e} (${r.src})`)),e}(r.id);if("object"!=typeof i)throw new TypeError("Options is not an object");return function(e){const{search:i}=window.location;i.includes("ifrlog")&&(e.log=d,e.logExpand=!i.includes("ifrlog=collapsed"))}(i),function(e,i){const t=I(i,"log"),o="string"==typeof i.log,n=t?!!o||i.log:q.log;I(i,"logExpand")||(i.logExpand=t&&o?i.log===d:q.logExpand),function(e){-1===e?.log&&(e.log=!1,le=!0)}(i),function({enabled:e,expand:i,iframeId:t}){const o=j({expand:i,label:O(t)});R=e,G[t]||(G[t]={console:o})}({enabled:n,expand:i.logExpand,iframeId:e}),o&&!(i.log in f)&&C(e,'Invalid value for options.log: Accepted values are "expanded" and "collapsed"'),i.log=n}(w,i),W(w,function(e){v()?E(w,`Ignored iframe (${w}), already setup.`):(b(e),function(){if(ae)return;const{mode:e}=U[w];-1!==e&&ce(w,e)}(),ue(),function(){switch(x(w,`Iframe scrolling ${U[w]?.scrolling?"enabled":"disabled"} for ${w}`),r.style.overflow=!1===U[w]?.scrolling?"hidden":"auto",U[w]?.scrolling){case"omit":break;case!0:r.scrolling="yes";break;case!1:r.scrolling="no";break;default:r.scrolling=U[w]?U[w].scrolling:"no"}}(),function(){const{bodyMargin:e}=U[w];"number"!=typeof e&&"0"!==e||(U[w].bodyMargin=`${e}px`)}(),u(ne(w)),c(),x(w,"Setup complete"))})(i),r?.iframeResizer}});
|
|
21
21
|
//# sourceMappingURL=index.umd.js.map
|