@iframe-resizer/core 6.0.0-beta.1 → 6.0.0-beta.11
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 +2 -2
- package/index.cjs.js +20 -34
- package/index.cjs.js.map +1 -1
- package/index.d.ts +158 -3
- package/index.esm.js +20 -1070
- package/index.esm.js.map +1 -1
- package/index.umd.js +20 -37
- package/index.umd.js.map +1 -1
- package/package.json +3 -4
- package/types.d.ts +0 -130
package/README.md
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
This package is part of the __[iframe-resizer](https://iframe-resizer.com)__ library, which automatically resizes the height and width of both same-origin and cross-origin iframes to match their content. It also includes a range of features designed to address common issues associated with using iframes.
|
|
8
8
|
|
|
9
9
|
|
|
10
|
-
__For more information, visit [iframe-resizer.com](https://iframe-resizer.com).__
|
|
10
|
+
__For more information, please visit [iframe-resizer.com](https://iframe-resizer.com).__
|
|
11
11
|
|
|
12
12
|
## Install
|
|
13
13
|
|
|
@@ -25,4 +25,4 @@ yarn add @iframe-resizer/core
|
|
|
25
25
|
|
|
26
26
|
---
|
|
27
27
|
|
|
28
|
-
_iframe-resizer version 6.0.0-beta.
|
|
28
|
+
_iframe-resizer version 6.0.0-beta.11 2026-04-21 - 20:15:22.823Z_
|
package/index.cjs.js
CHANGED
|
@@ -1,35 +1,21 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
`);return}u(e,`Version mismatch (Child: %c${t}%c !== Parent: %c${N})`,r.HIGHLIGHT,r.FOREGROUND,r.HIGHLIGHT)}}function T(e,t,n){if(!i[e])return null;const o=i[e][t];if(typeof o!==Ie)throw new TypeError(`${t} on iframe[${e}] is not a function`);if(t!=="onBeforeClose"&&t!=="onScroll")return Lt(o,n);try{return o(n)}catch(s){return console.error(s),w(e,`Error in ${t} callback`),null}}function yn(e,t){const{id:n,iframe:o}=e;u(n,`onMessage passed: {iframe: %c${n}%c, message: %c${t}%c}`,r.HIGHLIGHT,r.FOREGROUND,r.HIGHLIGHT,r.FOREGROUND),T(n,"onMessage",{iframe:o,message:JSON.parse(t)})}function P(e,t){const{lastMessage:n}=i[e];return n.slice(n.indexOf($)+It+t)}function ce(e,t){const{id:n,iframe:o,height:s,type:a,width:c}=t;let l={x:0,y:0};if(c===0&&s===0){const f=P(n,9).split($);l={x:f[1],y:f[0]}}else l={x:c,y:s};T(n,e,{iframe:o,screenX:Number(l.x),screenY:Number(l.y),type:a})}const p={position:null,version:N};function je(){p.position=null}const bn=()=>p.position;function vn(e){p.position=e}function Ge(e){return p.position===null&&(p.position={x:window.scrollX,y:window.scrollY}),u(e,`Get page position: %c${p.position.x}%c, %c${p.position.y}`,r.HIGHLIGHT,r.FOREGROUND,r.HIGHLIGHT),p.position}function Ae(e){p.position!==null&&(window.scrollTo(p.position.x,p.position.y),y(e,`Set page position: %c${p.position.x}%c, %c${p.position.y}`,r.HIGHLIGHT,r.FOREGROUND,r.HIGHLIGHT),je())}function ae(e,t){const{id:n}=t,o=`${t[e]}px`;i[n].iframe.style[e]=o,y(n,`Set ${e}: %c${o}`,r.HIGHLIGHT)}function Pe(e){const{id:t}=e,{sizeHeight:n,sizeWidth:o}=i[t];n&&ae(pt,e),o&&ae(gt,e)}function le(e){const{id:t}=e;Pe(e),Ae(t),T(t,"onResized",e)}function Ne(e){const{id:t}=e;u(t,"Disconnected from iframe"),delete i[t],delete e.iframeResizer}function Ce(e){const{id:t}=e;if(T(t,"onBeforeClose",t)===!1){u(t,"Close iframe cancelled by onBeforeClose");return}u(t,`Removing iFrame: %c${t}`,r.HIGHLIGHT);try{e.parentNode&&e.remove()}catch(n){w(t,n)}T(t,"onAfterClose",t),Ne(e)}function xe(e){const{id:t,type:n}=e;u(t,`Size reset requested by ${n===M?"parent page":"child page"}`),Ge(t),Pe(e),E(W,W,t)}const _e=(e,t)=>{const n={};return(o,s)=>{const{iframe:a}=i[s];function c(f,h){n[h]||(f(),n[h]=requestAnimationFrame(()=>{n[h]=null}))}function l(){E(`${o} (${e})`,`${e}:${t(a)}`,s)}c(l,s)}},Fe=e=>t=>{e in i[t]&&(i[t][e](),delete i[t][e])},De=((e,t)=>n=>{let o=!1;const s=d=>()=>{i[n]?(!o||o===d)&&(e(d,n),o=d,requestAnimationFrame(()=>{o=!1})):g()},a=s(oe),c=s("resize window"),l=new ResizeObserver(s("pageObserver")),f=new ResizeObserver(s("iframeObserver"));function h(d,z){u(n,`${d}listeners for send${t}`),z(window,oe,a),z(window,J,c)}function g(){b(n,`stop${t}`),h("Remove ",re),l.disconnect(),f.disconnect(),i[n]&&re(i[n].iframe,B,g)}function L(){h("Add ",G),l.observe(document.body),f.observe(i[n].iframe)}i[n]&&(i[n][`stop${t}`]=g,G(i[n].iframe,B,g),L())});function wn(e){const t=document.body.getBoundingClientRect(),n=e.getBoundingClientRect(),{scrollY:o,scrollX:s,innerHeight:a,innerWidth:c}=window,{clientHeight:l,clientWidth:f}=document.documentElement;return JSON.stringify({iframeHeight:n.height,iframeWidth:n.width,clientHeight:Math.max(l,a||0),clientWidth:Math.max(f,c||0),offsetTop:Math.trunc(n.top-t.top),offsetLeft:Math.trunc(n.left-t.left),scrollTop:o,scrollLeft:s,documentHeight:l,documentWidth:f,windowHeight:a,windowWidth:c})}const zn=_e(ve,wn),In=De(zn,"PageInfo"),En=Fe("stopPageInfo");function Tn(e){const{scrollWidth:t,scrollHeight:n}=document.documentElement,{width:o,height:s,offsetLeft:a,offsetTop:c,pageLeft:l,pageTop:f,scale:h}=window.visualViewport;return JSON.stringify({iframe:e.getBoundingClientRect(),document:{scrollWidth:t,scrollHeight:n},viewport:{width:o,height:s,offsetLeft:a,offsetTop:c,pageLeft:l,pageTop:f,scale:h}})}const On=_e(we,Tn),Ln=De(On,"ParentInfo"),Hn=Fe("stopParentInfo");function Be(e){const t=e.getBoundingClientRect(),n=Ge(e.id);return{x:Number(t.left)+Number(n.x),y:Number(t.top)+Number(n.y)}}function We(e){const{x:t,y:n}=bn(),o=i[e]?.iframe;if(T(e,"onScroll",{iframe:o,top:n,left:t,x:t,y:n})===!1){je();return}Ae(e)}function kn(e){const{id:t,height:n,width:o}=e,s=window.parentIframe||window.parentIFrame||window;y(t,`scrollBy: x: %c${o}%c y: %c${n}`,r.HIGHLIGHT,r.FOREGROUND,r.HIGHLIGHT),s.scrollBy(o,n)}const Ue=e=>t=>{const{id:n,iframe:o,height:s,width:a}=t;function c(d){vn(d),We(n)}function l(d,z){d[`scrollTo${e?"Offset":""}`](z.x,z.y)}const f=d=>({x:a+d.x,y:s+d.y}),h=e?Be(o):{x:0,y:0},g=f(h),L=window.parentIframe||window.parentIFrame;y(n,`Reposition requested (offset x:%c${h.x}%c y:%c${h.y})`,r.HIGHLIGHT,r.FOREGROUND,r.HIGHLIGHT),L?l(L,g):c(g)},Mn=Ue(!1),Sn=Ue(!0);function $n(e,t,n){const{x:o,y:s}=Be(n);y(e,`Moving to in page link: %c#${t}`,r.HIGHLIGHT),p.position={x:o,y:s},We(e),window.location.hash=t}function Rn(e,t){const n=window.parentIframe||window.parentIFrame;if(!n){u(e,`In page link #${t} not found`);return}n.moveToAnchor(t)}function jn(e,t){const n=t.split("#")[1]||"",o=decodeURIComponent(n),s=document.getElementById(o)||document.getElementsByName(o)[0];if(s){$n(e,n,s);return}if(window.top===window.self){u(e,`In page link #${n} not found`);return}Rn(e,n)}function Gn(e){const t=i[e]?.iframe?.title;return t===""||t===void 0}function An(e,t){i[e]?.syncTitle&&(i[e].iframe.title=t,y(e,`Set iframe title attribute: %c${t}`,r.HIGHLIGHT))}const _=e=>{if(!e)return"";let t=-559038744,n=1103547984;for(let o,s=0;s<e.length;s++)o=e.codePointAt(s),t=Math.imul(t^o,2246822519),n=Math.imul(n^o,3266489917);return t^=Math.imul(t^n>>>15,1935289751),n^=Math.imul(n^t>>>15,3405138345),t^=n>>>16,n^=t>>>16,(2097152*(n>>>0)+(t>>>11)).toString(36)},v=e=>e.replace(/[A-Za-z]/g,t=>String.fromCodePoint((t<="Z"?90:122)>=(t=t.codePointAt(0)+19)?t:t-26)),Pn=new Date,Ve=e=>new Set(Array.from({length:9},e)),Nn=e=>[e[0],...e.slice(1).map(t=>`${t} - lewpylk`),`${e[4]} - lewpylk`,...e.slice(1)],S=["spjluzl","rlf","clyzpvu","rlf2","nlaMbssFlhy"],Cn=["<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.","Pu whnl spurpun ylxbpylz h Wyvmlzzpvuhs vy Ibzpulzz spjluzl. Wslhzl zll <b>oaawz://pmyhtl-ylzpgly.jvt/wypjpun</> mvy tvyl klahpsz.","<yi>Clyzpvu 5 rlf klaljalk</><iy><iy>Av bwnyhkl av <i>Clyzpvu 6</> vm <p>pmyhtl-ylzpgly</> fvb jhu bzl aol mpyza 11 johyhjalyz vm fvb spjlujl rlf av nla h 60% kpzjvbua ha <ii>oaaw://pmyhtl-ylzpgly.jvt</>.","<yi>Clyzpvu 5 rlf klaljalk</><iy><iy>Av bwnyhkl av clyzpvu 6 vm<p>pmyhtl-ylzpgly</> wslhzl kvdusvhk aol shalza rlf myvt sltvu-zxbllgf.jvt.","<yi>VLT rlf lewpylk</><iy><iy>Wslhzl kvdusvhk aol shalza rlf myvt sltvu-zxbllgf.jvt."],xn=Nn(["NWSc3","zvsv","wyv","ibzpulzz","VLT"]),ue=Object.fromEntries(["2cgs7fdf4xb","1c9ctcccr4z","1q2pc4eebgb","ueokt0969w","w2zxchhgqz","1umuxblj2e5","1foobarqaz","2b5sdlfhbev","zo4ui3arjo","oclbb4thgl","igb1wzrjqr"].map((e,t)=>[e,Math.max(0,t-1)])),qe=Pn[v(S[4])](),_n=Ve((e,t)=>_(`${qe+t}`)),Fn=Ve((e,t)=>_(`${qe-++t}`)),Dn=e=>_n.has(e)?9:Fn.has(e)?5:-2,I=e=>v(Cn[e]),Bn=e=>v(xn[e]),Wn=e=>{const t=e[v(S[0])]||e[v(S[1])]||e[v(S[2])]||e[v(S[3])];if(!t)return-1;const n=t.split("-");let o=(function(s="",a=""){let c=-2;const l=_(v(s));return l in ue&&(c=ue[l]),c===9?Dn(a):c})(...n);return o===0||(s=>s[2]===_(s[0]+s[1]))(n)||(o=-2),o};let Z=!1,Ze=!1;function Je(e,t=-3){if(Z)return;const n=Math.max(i[e].mode,t);if(n>i[e].mode&&(i[e].mode=n),n<0)throw Ut(e),i[e].vAdvised||m(e||"Parent",`${I(n+2)}${I(2)}`),i[e].vAdvised=!0,I(n+2).replace(/<\/?[a-z][^>]*>|<\/>/gi,"");switch(n>5&&Ze||qt(`v${N} (${Bn(n)})`,n),n){case 1:case 2:case 3:m(e,I(6));break;case 4:m(e,I(7));break;case 5:m(e,I(8));break;default:n<1&&m("Parent",I(3))}Z=!0}function Un(e){if(Z)return;const{mode:t}=i[e];t>5&&Je(e,t)}function Vn(e){e?.log===-1&&(e.log=!1,Ze=!0)}function qn(e,t){i[e]&&(u(e,`First run for ${e}`),Je(e,t===void 0?void 0:Number(t)),i[e].firstRun=!1)}function Zn(e){const{height:t,id:n,iframe:o,mode:s,message:a,type:c,width:l}=e,{lastMessage:f}=i[n];switch(i[n]?.firstRun&&qn(n,s),u(n,`Received: %c${f}`,r.HIGHLIGHT),c){case me:i[n].autoResize=JSON.parse(P(n,9));break;case tt:y(n,"Ready state reset"),i[n].initialised=!1;break;case nt:Ce(o);break;case ot:jn(n,P(n,9));break;case M:le(e),dn(n),mn(n,a),i[n].initialised=!0,T(n,"onReady",o);break;case R:yn(e,P(n,6));break;case st:ce("onMouseEnter",e);break;case rt:ce("onMouseLeave",e);break;case ve:In(n);break;case we:Ln(n);break;case ct:En(n);break;case at:Hn(n);break;case W:xe(e);break;case lt:kn(e);break;case ut:Mn(e);break;case ft:Sn(e);break;case ht:An(n,a);break;default:if(l===0&&t===0){w(n,`Unsupported message received (${c}), this is likely due to the iframe containing a later version of iframe-resizer than the parent page`);return}if(l===0||t===0){u(n,"Ignoring message with 0 height or width");return}if(document.hidden){u(n,"Page hidden - ignored resize request");return}le(e)}}const Jn=e=>({initChild:t,postMessageTarget:n})=>{e===n&&t()},Yn=e=>Object.values(i).forEach(Jn(e));function fe(e){const t=e.data;if(t===et){Yn(e.source);return}if(!pn(t)){if(typeof t!==Y)return;b(U,"ignoredMessage"),Bt(U,t);return}const n=ln(t),{id:o,type:s}=n;switch(b(o,s),!0){case!i[o]:throw new Error(`${s} No settings for ${o}. Message was: ${t}`);case!fn(n):case gn(n):case!hn(n,e):return;default:i[o].lastMessage=e.data,Re(o,Zn)(n)}}const Xn=Ht(()=>{G(window,R,fe),G(document,"visibilitychange",rn),window.iframeParentListener=e=>setTimeout(()=>fe({data:e,sameOrigin:!0}))}),he={};function Kn(e){if(he[e]===!0)return!1;const t=document.querySelectorAll(`iframe#${CSS.escape(e)}`);if(t.length<=1)return!0;he[e]=!0;const n=Array.from(t).flatMap(o=>[A,o,A]);return m(e,`<rb>Duplicate ID attributes detected</>
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
The iframe (<i>${e}</>) has not responded within ${t[e].warningTimeout/1e3} seconds. Check <b>@iframe-resizer/child</> package has been loaded in the iframe.
|
|
21
|
-
${n&&l?`
|
|
22
|
-
The <b>checkOrigin</> option is currently enabled. If the iframe redirects away from <i>${l}</>, then the connection to the iframe may be blocked by the browser. To disable this option, set <b>checkOrigin</> to <bb>false</> or an array of allowed origins. See <u>https://iframe-resizer.com/checkorigin</> for more information.
|
|
23
|
-
`:""}${c&&!a?`
|
|
24
|
-
The <b>waitForLoad</> option is currently set to <bb>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 <bb>false</>.
|
|
25
|
-
`:""}${uo(s)?`
|
|
26
|
-
The iframe has the <b>sandbox</> attribute, please ensure it contains both the <bb>allow-same-origin</> and <bb>allow-scripts</> values.
|
|
27
|
-
`:""}
|
|
28
|
-
This message can be ignored if everything is working, or you can set the <b>warningTimeout</> option to a higher value or zero to suppress this warning.
|
|
29
|
-
`)}function ho(e,t){function n(){if(t[e]===void 0)return;const{initialised:a,loadErrorShown:c}=t[e];if(t[e].msgTimeout=void 0,a){t[e].initialisedFirstPage=!0;return}c||(t[e].loadErrorShown=!0,fo(e,t))}const{msgTimeout:o,warningTimeout:s}=t[e];s&&(o&&clearTimeout(o),t[e].msgTimeout=setTimeout(n,s))}const po=1,go=e=>e.loading===it,mo=e=>e===M;function yo(e){i[e]?.heightCalculationMethod in Et&&xe({id:e,iframe:i[e].iframe,height:ne,width:ne,type:M})}function bo(e,t){G(e,B,()=>setTimeout(t,po))}const vo=e=>{const{src:t,srcdoc:n}=e;return!n&&(t==null||t===""||t==="about:blank")};function wo(e,t){const{iframe:n,waitForLoad:o}=i[e];if(o!==!0){if(vo(n)){setTimeout(()=>{b(e,"noContent"),y(e,"No content detected in the iframe, delaying initialisation")});return}setTimeout(t)}}function zo(e,t){const n=s=>()=>{if(!i[e])return;const{firstRun:a,iframe:c}=i[e];E(s,t,e),mo(s)&&go(c)||ho(e,i),a||yo(e)},{iframe:o}=i[e];i[e].initChild=n(ye),bo(o,n(be)),wo(e,n(M))}function Io(e,t){return t?(("sizeWidth"in t||"sizeHeight"in t||me in t)&&m(e,`<rb>Deprecated Option</>
|
|
30
|
-
|
|
31
|
-
The <b>sizeWidth</>, <b>sizeHeight</> and <b>autoResize</> options have been replaced with new <b>direction</> option which expects values of <bb>${F}</>, <bb>${Oe}</>, <bb>${Te}</> or <bb>${Ee}</>.
|
|
32
|
-
`),t):{}}function Eo(e){i[e].warningTimeout||y(e,"warningTimeout:%c disabled",r.HIGHLIGHT)}function To(e,{offset:t,offsetSize:n}){const o=n||t;o&&(i[e].direction===F?(i[e].offsetHeight=o,u(e,`Offset height: %c${o}`,r.HIGHLIGHT)):(i[e].offsetWidth=o,u(e,`Offset width: %c${o}`,r.HIGHLIGHT)))}function Oo(e){const{direction:t}=i[e];switch(t){case F:break;case Oe:i[e].sizeHeight=!1;case Te:i[e].sizeWidth=!0;break;case Ee:i[e].sizeWidth=!1,i[e].sizeHeight=!1,i[e].autoResize=!1;break;default:throw new TypeError(`Direction value of "${t}" is not valid`)}u(e,`direction: %c${t}`,r.HIGHLIGHT)}const pe=e=>e===""||e.match(/^(about:blank|javascript:|file:\/\/)/)!==null?"*":e;function Lo(e){const{checkOrigin:t,remoteHost:n}=i[e];Array.isArray(t)&&t.length===0&&w(e,"checkOrigin is an empty array — no messages will be sent to the iframe"),i[e].targetOrigin=Array.isArray(t)?t.map(pe):[t===!1?"*":pe(n)]}function Ho(e){const{id:t}=e;i[t].postMessageTarget===null&&(i[t].postMessageTarget=e.contentWindow)}function D(e,t,n){j(i[e],t)&&(m(e,`<rb>Deprecated option</>
|
|
33
|
-
|
|
34
|
-
The <b>${t}</> option has been renamed to <b>${n}</>. ${Le}`),i[e][n]=i[e][t],delete i[e][t])}function ko(e){D(e,dt,mt),D(e,"onClose","onBeforeClose"),D(e,"onClosed","onAfterClose")}const Mo=e=>j(e,"onMouseEnter")||j(e,"onMouseLeave");function So(e,t){const{id:n}=e;i[n]={...i[n],iframe:e,remoteHost:e?.src.split("/").slice(0,3).join("/"),...x,...Io(n,t),mouseEvents:Mo(t),mode:Wn(t),syncTitle:Gn(n)},ko(n),Oo(n),To(n,t),Eo(n),Ho(e),Lo(n)}const $o="yes",ge="no";function Ro(e){const{id:t}=e;switch(u(t,`Iframe scrolling ${i[t]?.scrolling?"enabled":"disabled"} for ${t}`),e.style.overflow=i[t]?.scrolling===!1?yt:V,i[t]?.scrolling){case zt:break;case!0:e.scrolling=$o;break;case!1:e.scrolling=ge;break;default:e.scrolling=i[t]?.scrolling||ge}}function jo(e,t,n){So(t,n),u(e,`src: %c${t.srcdoc||t.src}`,r.HIGHLIGHT),Un(e),Ro(t),ao(e),zo(e,ro(e)),to(e),u(e,"Setup complete")}function Go(e,t){const{id:n}=e;b(n,"setup"),Kn(n)&&jo(n,e,t),Vt(n)}function Ao(e,t){t.log===X?t.log=!1:t.log===K?t.log=k:t.log===Q&&(t.log=H);const n=j(t,"log"),o=ee(t.log),s=n?o?!0:t.log:x.log;j(t,"logExpand")||(t.logExpand=n&&o?t.log===H:x.logExpand),Vn(t),Dt({enabled:s,expand:t.logExpand,iframeId:e}),o&&!(t.log in Tt)&&Wt(e,`Invalid value for options.log: Accepted values are "${H}" and "${k}"`),t.log=s}function Po(e){if(!He(e))throw new TypeError("Options is not an object");return Xn(),tn(e),t=>{const n=en(t,e);return de in t?(b(n,"alreadySetup"),w(n,`Ignored iframe (${n}), already setup.`)):(Ao(n,e),Re(n,Go)(t,e)),t?.iframeResizer}}exports.LOG_COLLAPSED=K;exports.LOG_DISABLED=X;exports.LOG_EXPANDED=Q;exports.default=Po;
|
|
1
|
+
/*!
|
|
2
|
+
* @preserve
|
|
3
|
+
*
|
|
4
|
+
* @module iframe-resizer/core 6.0.0-beta.11 (esm) - 2026-04-21
|
|
5
|
+
*
|
|
6
|
+
* @license GPL-3.0-only For use with GPL compliant sites (fully published front & backend source code)
|
|
7
|
+
* Alternatively for commercial use, you can purchase a license from
|
|
8
|
+
* https://iframe-resizer.com/pricing
|
|
9
|
+
*
|
|
10
|
+
* @description Keep same and cross domain iframes sized to their content
|
|
11
|
+
*
|
|
12
|
+
* @author David J. Bradshaw <info@iframe-resizer.com>
|
|
13
|
+
*
|
|
14
|
+
* @see {@link https://iframe-resizer.com}
|
|
15
|
+
*
|
|
16
|
+
* @copyright (c) 2013 - 2026, David J. Bradshaw. All rights reserved.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("@iframe-resizer/common"),n=require("@iframe-resizer/common/consts"),t=require("auto-console-group"),i={},o=e.esModuleInterop(t);let r=!0;const s=o({expand:!1,label:n.PARENT}),a=e=>window.top===window.self?`parent(${e})`:`nested parent(${e})`;const c=e=>(n,...t)=>i[n]?i[n].console[e](...t):s[e](...t),d=e=>(n,...t)=>!0===(e=>i[e]?i[e].log:r)(n)?c(e)(n,...t):null,l=d("log"),f=l,u=d("debug"),g=c("warn"),m=c("error"),h=c("event"),p=c("purge"),E=c("endAutoGroup"),I=c("errorBoundary");const b=e.createFormatAdvise(e.id),O=(t,...o)=>i[t]?i[t].console.warn(...o.map(b)):queueMicrotask(()=>{const i=e.createFormatAdvise((e=>(...t)=>[`${n.LABEL}(${e})`,...t].join(" "))(t));console?.warn(...o.map(i))}),T=e.deprecate(O);T("Function"),T("Method"),T("Option");const w=Object.freeze({autoResize:!0,bodyBackground:null,bodyMargin:null,bodyPadding:null,checkOrigin:!0,direction:n.VERTICAL,firstRun:!0,inPageLinks:!1,heightCalculationMethod:n.AUTO,id:"iframeResizer",log:!1,logExpand:!1,license:void 0,mouseEvents:!0,offsetHeight:null,offsetWidth:null,postMessageTarget:null,sameOrigin:!0,scrolling:!1,sizeHeight:!0,sizeWidth:!1,tolerance:0,waitForLoad:!1,warningTimeout:5e3,widthCalculationMethod:n.AUTO,onBeforeClose:()=>!0,onAfterClose(){},onMessage(){console.warn("","onMessage function not defined")},onMouseEnter(){},onMouseLeave(){},onReady(){},onResized(){},onScroll:()=>!0});let L=0;function H(n,t){let{id:i}=n;if(i&&!e.isString(i))throw new TypeError("Invalid id for iframe. Expected String");return i&&""!==i||(i=function(e){const n=e?.id||w.id+L++;return null===document.getElementById(n)?n:`${n}${L++}`}(t),n.id=i,h(i,"assignId"),l(i,`Added missing iframe ID: ${i} (${n.src})`)),i}function S(e,o,r){function s(i){const s=e in n.INIT_EVENTS?(e=>e.split(n.SEPARATOR).filter((e,n)=>19!==n).join(n.SEPARATOR))(o):o;f(r,i,t.HIGHLIGHT,t.FOREGROUND,t.HIGHLIGHT),f(r,`Message data: %c${s}`,t.HIGHLIGHT)}const{iframe:a,postMessageTarget:c,sameOrigin:d,targetOrigin:u}=i[r];if(d)try{return a.contentWindow.iframeChildListener(n.MESSAGE_ID+o),void s(`Sending message to iframe %c${r}%c via same origin%c`)}catch(m){e in n.INIT_EVENTS?(i[r].sameOrigin=!1,l(r,"New iframe does not support same origin")):g(r,"Same origin messaging failed, falling back to postMessage")}s(`Sending message to iframe: %c${r}%c targetOrigin: %c${u.join(", ")}`);for(const t of u)c.postMessage(n.MESSAGE_ID+o,t)}function y(e,n,t){h(t,e),i[t]?.postMessageTarget?S(e,n,t):g(t,"Iframe not found")}function R(){var e,t;!0!==document.hidden&&(e="tabVisible",t=n.RESIZE,Object.values(i).filter(({autoResize:e,firstRun:n})=>e&&!n).forEach(({iframe:n})=>y(e,t,n.id)))}function G(e){const t=e.slice(n.MESSAGE_ID_LENGTH).split(":"),o=t[1]?Number(t[1]):0,r=i[t[0]]?.iframe,s=r?getComputedStyle(r):null,a=s?function(e){return"border-box"!==e.boxSizing?0:(e.paddingTop?parseInt(e.paddingTop,10):0)+(e.paddingBottom?parseInt(e.paddingBottom,10):0)}(s)+function(e){return"border-box"!==e.boxSizing?0:(e.borderTopWidth?parseInt(e.borderTopWidth,10):0)+(e.borderBottomWidth?parseInt(e.borderBottomWidth,10):0)}(s):0,c={iframe:r,id:t[0],height:o+a,width:Number(t[2]),type:t[3],message:t[4]};return t[5]&&(c.mode=t[5]),c}const A={true:1,false:1,undefined:1};function N(t,o,r){if(!i[t])return null;const s=i[t][o];if(typeof s!==n.FUNCTION)throw new TypeError(`${o} on iframe[${t}] is not a function`);if("onBeforeClose"!==o&&"onScroll"!==o)return e.isolateUserCode(s,r);try{return s(r)}catch(a){return console.error(a),g(t,`Error in ${o} callback`),null}}function $(e,t){const{lastMessage:o}=i[e];return o.slice(o.indexOf(n.SEPARATOR)+n.MESSAGE_HEADER_LENGTH+t)}function v(e,t){const{id:i,iframe:o,height:r,type:s,width:a}=t;let c={x:0,y:0};if(0===a&&0===r){const e=$(i,9).split(n.SEPARATOR);c={x:e[1],y:e[0]}}else c={x:a,y:r};N(i,e,{iframe:o,screenX:Number(c.x),screenY:Number(c.y),type:s})}const M={position:null,version:n.VERSION};function D(){M.position=null}function _(e){return null===M.position&&(M.position={x:window.scrollX,y:window.scrollY}),l(e,`Get page position: %c${M.position.x}%c, %c${M.position.y}`,t.HIGHLIGHT,t.FOREGROUND,t.HIGHLIGHT),M.position}function P(e){null!==M.position&&(window.scrollTo(M.position.x,M.position.y),f(e,`Set page position: %c${M.position.x}%c, %c${M.position.y}`,t.HIGHLIGHT,t.FOREGROUND,t.HIGHLIGHT),D())}function k(e,n){const{id:o}=n,r=`${n[e]}px`;i[o].iframe.style[e]=r,f(o,`Set ${e}: %c${r}`,t.HIGHLIGHT)}function C(e){const{id:t}=e,{sizeHeight:o,sizeWidth:r}=i[t];o&&k(n.HEIGHT,e),r&&k(n.WIDTH,e)}function x(e){const{id:n}=e;C(e),P(n),N(n,"onResized",e)}function z(e){const{id:n}=e;l(n,"Disconnected from iframe"),delete i[n],delete e.iframeResizer}function F(e){const{id:n}=e;if(!1!==N(n,"onBeforeClose",n)){l(n,`Removing iframe: %c${n}`,t.HIGHLIGHT);try{e.parentNode&&e.remove()}catch(i){g(n,i)}N(n,"onAfterClose",n),z(e)}else l(n,"Close iframe cancelled by onBeforeClose")}function B(e){const{id:t,type:i}=e;l(t,"Size reset requested by "+(i===n.INIT?"parent page":"child page")),_(t),C(e),y(n.RESET,n.RESET,t)}const W=(e,n)=>{const t={};return(o,r)=>{const{iframe:s}=i[r];var a,c;a=function(){y(`${o} (${e})`,`${e}:${n(s)}`,r)},t[c=r]||(a(),t[c]=requestAnimationFrame(()=>{t[c]=null}))}},U=e=>n=>{e in i[n]&&(i[n][e](),delete i[n][e])},V=(t,o)=>r=>{let s=!1;const a=e=>()=>{i[r]?s&&s!==e||(t(e,r),s=e,requestAnimationFrame(()=>{s=!1})):m()},c=a(n.SCROLL),d=a("resize window"),f=new ResizeObserver(a("pageObserver")),u=new ResizeObserver(a("iframeObserver"));function g(e,t){l(r,`${e}listeners for send${o}`),t(window,n.SCROLL,c),t(window,n.RESIZE,d)}function m(){h(r,`stop${o}`),g("Remove ",e.removeEventListener),f.disconnect(),u.disconnect(),i[r]&&e.removeEventListener(i[r].iframe,n.LOAD,m)}i[r]&&(i[r][`stop${o}`]=m,e.addEventListener(i[r].iframe,n.LOAD,m),g("Add ",e.addEventListener),f.observe(document.body),u.observe(i[r].iframe))};const j=V(W(n.PAGE_INFO,function(e){const n=document.body.getBoundingClientRect(),t=e.getBoundingClientRect(),{scrollY:i,scrollX:o,innerHeight:r,innerWidth:s}=window,{clientHeight:a,clientWidth:c}=document.documentElement;return JSON.stringify({iframeHeight:t.height,iframeWidth:t.width,clientHeight:Math.max(a,r||0),clientWidth:Math.max(c,s||0),offsetTop:Math.trunc(t.top-n.top),offsetLeft:Math.trunc(t.left-n.left),scrollTop:i,scrollLeft:o,documentHeight:a,documentWidth:c,windowHeight:r,windowWidth:s})}),"PageInfo"),q=U("stopPageInfo");const X=V(W(n.PARENT_INFO,function(e){const{scrollWidth:n,scrollHeight:t}=document.documentElement,i="undefined"!=typeof window&&window.visualViewport?window.visualViewport:{},{width:o=0,height:r=0,offsetLeft:s=0,offsetTop:a=0,pageLeft:c=0,pageTop:d=0,scale:l=1}=i;return JSON.stringify({iframe:e.getBoundingClientRect(),document:{scrollWidth:n,scrollHeight:t},viewport:{width:o,height:r,offsetLeft:s,offsetTop:a,pageLeft:c,pageTop:d,scale:l}})}),"ParentInfo"),Z=U("stopParentInfo");function J(e){const n=e.getBoundingClientRect(),t=_(e.id);return{x:Number(n.left)+Number(t.x),y:Number(n.top)+Number(t.y)}}function Y(e){const{x:n,y:t}=M.position,o=i[e]?.iframe;!1!==N(e,"onScroll",{iframe:o,top:t,left:n,x:n,y:t})?P(e):D()}const K=e=>n=>{const{id:i,iframe:o,height:r,width:s}=n;const a=e?J(o):{x:0,y:0},c={x:s+(d=a).x,y:r+d.y};var d;const l=window.parentIframe||window.parentIFrame;var u;f(i,`Reposition requested (offset x:%c${a.x}%c y:%c${a.y})`,t.HIGHLIGHT,t.FOREGROUND,t.HIGHLIGHT),l?(u=c,l["scrollTo"+(e?"Offset":"")](u.x,u.y)):function(e){var n;n=e,M.position=n,Y(i)}(c)},Q=K(!1),ee=K(!0);function ne(e,n){const i=n.split("#")[1]||"",o=decodeURIComponent(i),r=document.getElementById(o)||document.getElementsByName(o)[0];r?function(e,n,i){const{x:o,y:r}=J(i);f(e,`Moving to in page link: %c#${n}`,t.HIGHLIGHT),M.position={x:o,y:r},Y(e),window.location.hash=n}(e,i,r):window.top!==window.self?function(e,n){const t=window.parentIframe||window.parentIFrame;t?t.moveToAnchor(n):l(e,`In page link #${n} not found`)}(e,i):l(e,`In page link #${i} not found`)}function te(e){const n=i[e]?.iframe?.title;return""===n||void 0===n}let ie=!1,oe=!1;function re(o,s=-3){if(ie)return;const a=Math.max(i[o].mode,s);if(a>i[o].mode&&(i[o].mode=a),a<0)throw p(o),i[o].vAdvised||O(o||"Parent",`${e.getModeData(a+2)}${e.getModeData(2)}`),i[o].vAdvised=!0,e.getModeData(a+2).replace(/<\/?[a-z][^>]*>|<\/>/gi,"");switch(a>5&&oe||function(e,i){queueMicrotask(()=>console.info(`%ciframe-resizer ${e}`,r||i<1?n.BOLD:t.NORMAL))}(`v${n.VERSION} (${e.getModeLabel(a)})`,a),a){case 1:case 2:case 3:O("Parent",e.getModeData(6));break;case 4:O("Parent",e.getModeData(7));break;case 5:O("Parent",e.getModeData(8));break;default:a<1&&O("Parent",e.getModeData(3))}ie=!0}function se(e){const{height:o,id:r,iframe:s,mode:a,message:c,type:d,width:u}=e,{lastMessage:m}=i[r];switch(i[r]?.firstRun&&function(e,n){i[e]&&(l(e,`First run for ${e}`),re(e,void 0===n?void 0:Number(n)),i[e].firstRun=!1)}(r,a),l(r,`Received: %c${m}`,t.HIGHLIGHT),d){case n.AUTO_RESIZE:i[r].autoResize=JSON.parse($(r,9));break;case n.BEFORE_UNLOAD:f(r,"Ready state reset"),i[r].initialised=!1;break;case n.CLOSE:F(s);break;case n.IN_PAGE_LINK:ne(r,$(r,9));break;case n.INIT:x(e),function(e){try{i[e].sameOrigin=!!i[e]?.iframe?.contentWindow?.iframeChildListener}catch(n){i[e].sameOrigin=!1}l(e,`sameOrigin: %c${i[e].sameOrigin}`,t.HIGHLIGHT)}(r),function(e,o){i[e]&&(i[e].childVersion=o),o!==n.VERSION&&(void 0!==o?l(e,`Version mismatch (Child: %c${o}%c !== Parent: %c${n.VERSION})`,t.HIGHLIGHT,t.FOREGROUND,t.HIGHLIGHT):O(e,"<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"))}(r,c),i[r].initialised=!0,N(r,"onReady",s);break;case n.MESSAGE:!function(e,n){const{id:i,iframe:o}=e;l(i,`onMessage passed: {iframe: %c${i}%c, message: %c${n}%c}`,t.HIGHLIGHT,t.FOREGROUND,t.HIGHLIGHT,t.FOREGROUND),N(i,"onMessage",{iframe:o,message:JSON.parse(n)})}(e,$(r,6));break;case n.MOUSE_ENTER:v("onMouseEnter",e);break;case n.MOUSE_LEAVE:v("onMouseLeave",e);break;case n.PAGE_INFO:j(r);break;case n.PARENT_INFO:X(r);break;case n.PAGE_INFO_STOP:q(r);break;case n.PARENT_INFO_STOP:Z(r);break;case n.RESET:B(e);break;case n.SCROLL_BY:!function(e){const{id:n,height:i,width:o}=e,r=window.parentIframe||window.parentIFrame||window;f(n,`scrollBy: x: %c${o}%c y: %c${i}`,t.HIGHLIGHT,t.FOREGROUND,t.HIGHLIGHT),r.scrollBy(o,i)}(e);break;case n.SCROLL_TO:Q(e);break;case n.SCROLL_TO_OFFSET:ee(e);break;case n.TITLE:!function(e,n){i[e]?.syncTitle&&(i[e].iframe.title=n,f(e,`Set iframe title attribute: %c${n}`,t.HIGHLIGHT))}(r,c);break;default:if(0===u&&0===o)return void g(r,`Unsupported message received (${d}), this is likely due to the iframe containing a later version of iframe-resizer than the parent page`);if(0===u||0===o)return void l(r,"Ignoring message with 0 height or width");if(document.hidden)return void l(r,"Page hidden - ignored resize request");x(e)}}function ae(o){const r=o.data;if(r===n.CHILD_READY_MESSAGE)return s=o.source,void Object.values(i).forEach((e=>({initChild:n,postMessageTarget:t})=>{e===t&&n()})(s));var s,a;if(a=r,n.MESSAGE_ID!==`${a}`.slice(0,n.MESSAGE_ID_LENGTH)||!(a.slice(n.MESSAGE_ID_LENGTH).split(":")[0]in i)){if(typeof r!==n.STRING)return;return h(n.PARENT,"ignoredMessage"),void u(n.PARENT,r)}const c=G(r),{id:d,type:f}=c;switch(h(d,f),!0){case!i[d]:throw new Error(`${f} No settings for ${d}. Message was: ${r}`);case!function(n){const{id:i,message:o,iframe:r}=n,s=e.isIframe(r);return s||(l(i,`Received: %c${o}`,t.HIGHLIGHT),g(i,"The target iframe was not found.")),s}(c):case function(e){const{id:n,type:t}=e,i=t in A;return i&&l(n,"Ignoring init message from meta parent page"),i}(c):case!function(e,n){const{id:o}=e,{data:r,origin:s}=n;if("sameOrigin"in n&&n.sameOrigin)return!0;const a=i[o]?.checkOrigin;if(a&&"null"!=`${s}`&&!(a.constructor===Array?function(){l(o,`Checking connection is from allowed list of origins: %c${a}`,t.HIGHLIGHT);for(const e of a)if(e===s)return!0;return!1}():function(){const e=i[o]?.remoteHost;return l(o,`Checking connection is from: %c${e}`,t.HIGHLIGHT),s===e}()))throw new Error(`Unexpected message received from: ${s} for ${o}. Message was: ${r}. This error can be disabled by setting the checkOrigin: false option or by providing an array of trusted domains.`);return!0}(c,o):return;default:i[d].lastMessage=o.data,I(d,se)(c)}}const ce=e.once(()=>{e.addEventListener(window,n.MESSAGE,ae),e.addEventListener(document,"visibilitychange",R),window.iframeParentListener=e=>setTimeout(()=>ae({data:e,sameOrigin:!0}))}),de={};const le="8",fe="32",ue=n.CHILD,ge=!0;function me(e,t){const{checkOrigin:i,iframe:{src:o,sandbox:r},initialisedFirstPage:s,waitForLoad:a}=t[e],c=(e=>{try{return new URL(e).origin}catch(n){return null}})(o);h(e,"noResponse"),O(e,`<rb>No response from iframe</>\n\nThe iframe (<i>${e}</>) has not responded within ${t[e].warningTimeout/1e3} seconds. Check <b>@iframe-resizer/child</> package has been loaded in the iframe.\n${i&&c?`\nThe <b>checkOrigin</> option is currently enabled. If the iframe redirects away from <i>${c}</>, then the connection to the iframe may be blocked by the browser. To disable this option, set <b>checkOrigin</> to <bb>false</> or an array of allowed origins. See <u>https://iframe-resizer.com/checkorigin</> for more information.\n`:""}${a&&!s?"\nThe <b>waitForLoad</> option is currently set to <bb>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 <bb>false</>.\n":""}${(e=>typeof e===n.OBJECT&&e.length>0&&!(e.contains("allow-scripts")&&e.contains("allow-same-origin")))(r)?"\nThe iframe has the <b>sandbox</> attribute, please ensure it contains both the <bb>allow-same-origin</> and <bb>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`)}function he(t,o){const r=e=>()=>{if(!i[t])return;const{firstRun:r,iframe:s}=i[t];r&&(i[t].sameOrigin=!0),y(e,o,t),(e=>e===n.INIT)(e)&&(e=>e.loading===n.LAZY)(s)||function(e,n){const{msgTimeout:t,warningTimeout:i}=n[e];i&&(t&&clearTimeout(t),n[e].msgTimeout=setTimeout(function(){if(void 0===n[e])return;const{initialised:t,loadErrorShown:i}=n[e];n[e].msgTimeout=void 0,t?n[e].initialisedFirstPage=!0:i||(n[e].loadErrorShown=!0,me(e,n))},i))}(t,i),r||function(e){i[e]?.heightCalculationMethod in n.RESET_REQUIRED_METHODS&&B({id:e,iframe:i[e].iframe,height:n.MIN_SIZE,width:n.MIN_SIZE,type:n.INIT})}(t)},{iframe:s}=i[t];i[t].initChild=r(n.INIT_FROM_IFRAME),function(t,i){e.addEventListener(t,n.LOAD,()=>setTimeout(i,1))}(s,r(n.ONLOAD)),function(e,n){const{iframe:t,waitForLoad:o}=i[e];!0!==o&&((e=>{const{src:n,srcdoc:t}=e;return!t&&(null==n||""===n||"about:blank"===n)})(t)?setTimeout(()=>{h(e,"noContent"),f(e,"No content detected in the iframe, delaying initialisation")}):setTimeout(n))}(t,r(n.INIT))}function pe(e,t){return t?(("sizeWidth"in t||"sizeHeight"in t||n.AUTO_RESIZE in t)&&O(e,`<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 <bb>${n.VERTICAL}</>, <bb>${n.HORIZONTAL}</>, <bb>${n.BOTH}</> or <bb>${n.NONE}</>.\n`),t):{}}const Ee=e=>""===e||null!==e.match(/^(about:blank|javascript:|file:\/\/)/)?"*":e;function Ie(t,o,r){e.hasOwn(i[t],o)&&(O(t,`<rb>Deprecated option</>\n\nThe <b>${o}</> option has been renamed to <b>${r}</>. ${n.REMOVED_NEXT_VERSION}`),i[t][r]=i[t][o],delete i[t][o])}const be=n=>e.hasOwn(n,"onMouseEnter")||e.hasOwn(n,"onMouseLeave");function Oe(o,r){const{id:s}=o;i[s]={...i[s],iframe:o,remoteHost:o?.src.split("/").slice(0,3).join("/"),...w,...pe(s,r),mouseEvents:be(r),mode:e.setMode(r),syncTitle:te(s)},function(e){Ie(e,n.OFFSET,n.OFFSET_SIZE),Ie(e,"onClose","onBeforeClose"),Ie(e,"onClosed","onAfterClose")}(s),function(e){const{direction:o}=i[e];switch(o){case n.VERTICAL:break;case n.HORIZONTAL:i[e].sizeHeight=!1;case n.BOTH:i[e].sizeWidth=!0;break;case n.NONE:i[e].sizeWidth=!1,i[e].sizeHeight=!1,i[e].autoResize=!1;break;default:throw new TypeError(`Direction value of "${o}" is not valid`)}l(e,`direction: %c${o}`,t.HIGHLIGHT)}(s),function(e,{offset:o,offsetSize:r}){const s=r||o;s&&(i[e].direction===n.VERTICAL?(i[e].offsetHeight=s,l(e,`Offset height: %c${s}`,t.HIGHLIGHT)):(i[e].offsetWidth=s,l(e,`Offset width: %c${s}`,t.HIGHLIGHT)))}(s,r),function(e){i[e].warningTimeout||f(e,"warningTimeout:%c disabled",t.HIGHLIGHT)}(s),function(e){const{id:n}=e;null===i[n].postMessageTarget&&(i[n].postMessageTarget=e.contentWindow)}(o),function(e){const{checkOrigin:n,remoteHost:t}=i[e];Array.isArray(n)&&0===n.length&&g(e,"checkOrigin is an empty array — no messages will be sent to the iframe"),i[e].targetOrigin=Array.isArray(n)?n.map(Ee):[!1===n?"*":Ee(t)]}(s)}function Te(o,r,s){Oe(r,s),l(o,`src: %c${r.srcdoc||r.src}`,t.HIGHLIGHT),function(e){if(ie)return;const{mode:n}=i[e];n>5&&re(e,n)}(o),function(e){const{id:t}=e;switch(l(t,`Iframe scrolling ${i[t]?.scrolling?"enabled":"disabled"} for ${t}`),e.style.overflow=!1===i[t]?.scrolling?n.HIDDEN:n.AUTO,i[t]?.scrolling){case n.OMIT:break;case!0:e.scrolling="yes";break;case!1:e.scrolling="no";break;default:e.scrolling=i[t]?.scrolling||"no"}}(r),function(e){const{bodyMargin:t}=i[e];typeof t!==n.NUMBER&&"0"!==t||(i[e].bodyMargin=`${t}px`)}(o),he(o,function(e){const{autoResize:t,bodyBackground:o,bodyMargin:r,bodyPadding:s,heightCalculationMethod:a,inPageLinks:c,license:d,log:l,logExpand:f,mouseEvents:u,offsetHeight:g,offsetWidth:m,mode:h,sizeHeight:p,sizeWidth:E,tolerance:I,widthCalculationMethod:b}=i[e];return[e,le,E,l,fe,ge,t,r,a,o,s,I,c,ue,b,u,g,m,p,d,M.version,h,"",f].join(n.SEPARATOR)}(o)),function(t){if(i[t]){const{iframe:o}=i[t];o.iframeResizer={close:F.bind(null,o),disconnect:z.bind(null,o),getVersion:()=>({child:i[t]?.childVersion||"legacy",parent:n.VERSION}),moveToAnchor(i){e.typeAssert(i,n.STRING,"moveToAnchor(anchor) anchor"),y("Move to anchor",`moveToAnchor:${i}`,t)},sendMessage(e){e=JSON.stringify(e),y(n.MESSAGE,`${n.MESSAGE}:${e}`,t)}}}}(o),l(o,"Setup complete")}function we(e,t){const{id:i}=e;h(i,"setup"),function(e){if(!0===de[e])return!1;const t=document.querySelectorAll(`iframe#${CSS.escape(e)}`);if(t.length<=1)return!0;de[e]=!0;const i=Array.from(t).flatMap(e=>[n.NEW_LINE,e,n.NEW_LINE]);return O(e,`<rb>Duplicate ID attributes detected</>\n\nThe <b>${e}</> ID is not unique. Having multiple iframes on the same page with the same ID causes problems with communication between the iframe and parent page. Please ensure that the ID of each iframe has a unique value.\n\nFound <bb>${t.length}</> iframes with the <b>${e}</> ID:`,...i,n.NEW_LINE),!1}(i)&&Te(i,e,t),E(i)}function Le(t,s){s.log===n.LOG_DISABLED?s.log=!1:s.log===n.LOG_COLLAPSED?s.log=n.COLLAPSE:s.log===n.LOG_EXPANDED&&(s.log=n.EXPAND);const c=e.hasOwn(s,"log"),d=e.isString(s.log),l=c?!!d||s.log:w.log;e.hasOwn(s,"logExpand")||(s.logExpand=c&&d?s.log===n.EXPAND:w.logExpand),function(e){-1===e?.log&&(e.log=!1,oe=!0)}(s),function({enabled:e,expand:n,iframeId:t}){const s=o({expand:n,label:a(t)});r=e,i[t]||(i[t]={console:s})}({enabled:l,expand:s.logExpand,iframeId:t}),d&&!(s.log in n.LOG_OPTIONS)&&m(t,`Invalid value for options.log: Accepted values are "${n.EXPAND}" and "${n.COLLAPSE}"`),s.log=l}Object.defineProperty(exports,"LOG_COLLAPSED",{enumerable:!0,get:()=>n.LOG_COLLAPSED}),Object.defineProperty(exports,"LOG_DISABLED",{enumerable:!0,get:()=>n.LOG_DISABLED}),Object.defineProperty(exports,"LOG_EXPANDED",{enumerable:!0,get:()=>n.LOG_EXPANDED}),exports.default=function(t){if(!e.isObject(t))throw new TypeError("Options is not an object");return ce(),function(e){const{search:t}=window.location;if(t.includes("ifrlog"))switch(new URLSearchParams(t).get("ifrlog")){case String(n.LOG_DISABLED):e.log=!1;break;case n.EXPAND:case String(n.LOG_EXPANDED):e.log=n.EXPAND;break;case n.COLLAPSE:case String(n.LOG_COLLAPSED):default:e.log=n.COLLAPSE}}(t),e=>{const i=H(e,t);return n.LABEL in e?(h(i,"alreadySetup"),g(i,`Ignored iframe (${i}), already setup.`)):(Le(i,t),I(i,we)(e,t)),e.iframeResizer}};
|
|
35
21
|
//# sourceMappingURL=index.cjs.js.map
|