@iframe-resizer/core 5.5.9 → 6.0.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +2 -2
- package/README.md +1 -1
- package/index.cjs.js +35 -20
- package/index.cjs.js.map +1 -0
- package/index.d.ts +3 -0
- package/index.esm.js +1071 -20
- package/index.esm.js.map +1 -0
- package/index.umd.js +38 -20
- package/index.umd.js.map +1 -0
- package/package.json +2 -1
- package/types.d.ts +130 -0
package/index.esm.js
CHANGED
|
@@ -1,20 +1,1071 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
import e,{NORMAL as t,HIGHLIGHT as i,FOREGROUND as n}from"auto-console-group";const o="5.5.9",r="iframeResizer",a=":",s="autoResize",l="init",c="iframeReady",u="load",d="message",f="onload",p="pageInfo",h="parentInfo",m="reset",g="resize",y="scroll",b="\n",v="child",w="parent",z="string",$="object",j="function",k="auto",T="none",x="both",M="vertical",S="horizontal",I="[iFrameSizer]",O=Object.freeze({max:1,scroll:1,bodyScroll:1,documentElementScroll:1}),R=Object.freeze({[f]:1,[l]:1,[c]:1}),C="expanded",W="collapsed",E=Object.freeze({[C]:1,[W]:1}),L="Use of the old name will be removed in a future version of <i>iframe-resizer</>.",A=(e,t,i,n)=>e.addEventListener(t,i,n||!1),N=(e,t,i)=>e.removeEventListener(t,i,!1),P=e=>{if(!e)return"";let t=-559038744,i=1103547984;for(let n,o=0;o<e.length;o++)n=e.codePointAt(o),t=Math.imul(t^n,2246822519),i=Math.imul(i^n,3266489917);return t^=Math.imul(t^i>>>15,1935289751),i^=Math.imul(i^t>>>15,3405138345),t^=i>>>16,i^=t>>>16,(2097152*(i>>>0)+(t>>>11)).toString(36)},B=e=>e.replace(/[A-Za-z]/g,e=>String.fromCodePoint((e<="Z"?90:122)>=(e=e.codePointAt(0)+19)?e:e-26)),H=["spjluzl","rlf","clyzpvu"],F=["<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."],q=["NWSc3","zvsv","wyv","ibzpulzz","vlt"],D=Object.fromEntries(["2cgs7fdf4xb","1c9ctcccr4z","1q2pc4eebgb","ueokt0969w","w2zxchhgqz","1umuxblj2e5","2b5sdlfhbev","zo4ui3arjo","oclbb4thgl"].map((e,t)=>[e,Math.max(0,t-1)])),U=e=>B(F[e]),J=e=>{const t=e[B(H[0])]||e[B(H[1])]||e[B(H[2])];if(!t)return-1;const i=t.split("-");let n=function(e=""){let t=-2;const i=P(B(e));return i in D&&(t=D[i]),t>4?t-4:t}(i[0]);return 0===n||(e=>e[2]===P(e[0]+e[1]))(i)||(n=-2),n},Z=Object.hasOwn||((e,t)=>Object.prototype.hasOwnProperty.call(e,t)),V={br:"\n",rb:"[31;1m",bb:"[34;1m",b:"[1m",i:"[3m",u:"[4m","/":"[m"},X=Object.keys(V),Y=new RegExp(`<(${X.join("|")})>`,"gi"),_=(e,t)=>V[t]??"",G=e=>t=>e(typeof t===z?window.chrome?t.replace(Y,_):(e=>e.replaceAll("<br>",b).replaceAll(/<\/?[^>]+>/gi,""))(t):t),K={},Q=(ee=e,ee?.__esModule?ee.default:ee);var ee;let te=!0;const ie=Q({expand:!1,label:w}),ne=e=>window.top===window.self?`parent(${e})`:`nested parent(${e})`;const oe=e=>(t,...i)=>K[t]?K[t].console[e](...i):ie[e](...i);var re;const ae=(re="log",(e,...t)=>!0===(e=>K[e]?K[e].log:te)(e)?oe(re)(e,...t):null),se=oe("warn"),le=oe("error"),ce=oe("event"),ue=oe("purge"),de=oe("endAutoGroup"),fe=oe("errorBoundary");const pe=G(e=>e),he=(e,...t)=>K[e]?K[e].console.warn(...t.map(pe)):queueMicrotask(()=>{const i=G((e=>(...t)=>[`${r}(${e})`,...t].join(" "))(e));console?.warn(...t.map(i))}),me=(e=>(t,i="renamed to")=>(n,o,r="",a="")=>e(a,`<rb>Deprecated ${t}(${n.replace("()","")})</>\n\nThe <b>${n}</> ${t.toLowerCase()} has been ${i} <b>${o}</>. ${r}Use of the old ${t.toLowerCase()} will be removed in a future version of <i>iframe-resizer</>.`))(he),ge=me("Option");function ye(e){const{checkOrigin:t,iframe:{id:i,src:n,sandbox:o},initialisedFirstPage:r,waitForLoad:a,warningTimeout:s}=e,l=(e=>{try{return new URL(e).origin}catch(e){return null}})(n);ce(i,"noResponse"),he(i,`<rb>No response from iframe</>\n\nThe iframe (<i>${i}</>) has not responded within ${s/1e3} seconds. Check <b>@iframe-resizer/child</> package has been loaded in the iframe.\n${t&&l?`\nThe <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.\n`:""}${a&&!r?"\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===$&&e.length>0&&!(e.contains("allow-scripts")&&e.contains("allow-same-origin")))(o)?"\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`)}const be={};const ve=Object.freeze({autoResize:!0,bodyBackground:null,bodyMargin:null,bodyPadding:null,checkOrigin:!0,direction:M,firstRun:!0,inPageLinks:!1,heightCalculationMethod:k,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:k,onBeforeClose:()=>!0,onAfterClose(){},onInit:!1,onMessage:null,onMouseEnter(){},onMouseLeave(){},onReady:e=>{typeof K[e.id].onInit===j&&(ge("init()","onReady()","",e.id),K[e.id].onInit(e))},onResized(){},onScroll:()=>!0}),we={position:null,version:o};function ze(e){function t(){Ie(F),Me(U),E("onResized",F)}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 c(e){if("border-box"!==e.boxSizing)return 0;return(e.borderTopWidth?parseInt(e.borderTopWidth,10):0)+(e.borderBottomWidth?parseInt(e.borderBottomWidth,10):0)}const f=e=>B.slice(B.indexOf(a)+7+e);const b=(e,t)=>(i,n)=>{const o={};var r,a;r=function(){Re(`${i} (${e})`,`${e}:${t()}`,n)},o[a=n]||(r(),o[a]=requestAnimationFrame(()=>{o[a]=null}))},v=(e,t)=>()=>{let i=!1;const n=t=>()=>{K[l]?i&&i!==t||(e(t,l),i=t,requestAnimationFrame(()=>{i=!1})):s()},o=n(y),r=n("resize window");function a(e,t){t(window,y,o),t(window,g,r)}function s(){ce(l,`stop${t}`),a(0,N),c.disconnect(),d.disconnect(),N(K[l].iframe,u,s)}const l=U,c=new ResizeObserver(n("pageObserver")),d=new ResizeObserver(n("iframeObserver"));K[l]&&(K[l][`stop${t}`]=s,A(K[l].iframe,u,s),a(0,A),c.observe(document.body,{attributes:!0,childList:!0,subtree:!0}),d.observe(K[l].iframe,{attributes:!0,childList:!1,subtree:!1}))},$=e=>()=>{e in K[U]&&(K[U][e](),delete K[U][e])},j=b(p,function(){const e=document.body.getBoundingClientRect(),t=F.iframe.getBoundingClientRect(),{scrollY:i,scrollX:n,innerHeight:o,innerWidth:r}=window,{clientHeight:a,clientWidth:s}=document.documentElement;return JSON.stringify({iframeHeight:t.height,iframeWidth:t.width,clientHeight:Math.max(a,o||0),clientWidth:Math.max(s,r||0),offsetTop:parseInt(t.top-e.top,10),offsetLeft:parseInt(t.left-e.left,10),scrollTop:i,scrollLeft:n,documentHeight:a,documentWidth:s,windowHeight:o,windowWidth:r})}),k=b(h,function(){const{iframe:e}=F,{scrollWidth:t,scrollHeight:i}=document.documentElement,{width:n,height:o,offsetLeft:r,offsetTop:a,pageLeft:s,pageTop:l,scale:c}=window.visualViewport;return JSON.stringify({iframe:e.getBoundingClientRect(),document:{scrollWidth:t,scrollHeight:i},viewport:{width:n,height:o,offsetLeft:r,offsetTop:a,pageLeft:s,pageTop:l,scale:c}})}),T=v(j,"PageInfo"),x=v(k,"ParentInfo"),M=$("stopPageInfo"),S=$("stopParentInfo");function O(e){const t=e.getBoundingClientRect();return Te(),{x:Number(t.left)+Number(we.position.x),y:Number(t.top)+Number(we.position.y)}}function R(e){const t=e?O(F.iframe):{x:0,y:0};ae(U,`Reposition requested (offset x:%c${t.x}%c y:%c${t.y})`,i,n,i);const o=((e,t)=>({x:e.width+t.x,y:e.height+t.y}))(F,t),r=window.parentIframe||window.parentIFrame;r?function(t,i){setTimeout(()=>t["scrollTo"+(e?"Offset":"")](i.x,i.y))}(r,o):function(e){we.position=e,C(U)}(o)}function C(e){const{x:t,y:i}=we.position,n=K[e]?.iframe;!1!==E("onScroll",{iframe:n,top:i,left:t,x:t,y:i})?Me(e):xe()}function W(e){let t={};if(0===F.width&&0===F.height){const e=f(9).split(a);t={x:e[1],y:e[0]}}else t={x:F.width,y:F.height};E(e,{iframe:F.iframe,screenX:Number(t.x),screenY:Number(t.y),type:F.type})}const E=(e,t)=>$e(U,e,t);function L(){const{height:e,iframe:r,msg:a,type:c,width:u}=F;switch(K[U]?.firstRun&&function(){if(!K[U])return;Le(U,F.mode),K[U].firstRun=!1}(),c){case"close":ke(r);break;case d:y=f(6),E("onMessage",{iframe:F.iframe,message:JSON.parse(y)});break;case"mouseenter":W("onMouseEnter");break;case"mouseleave":W("onMouseLeave");break;case"beforeUnload":ae(U,"Ready state reset"),K[U].initialised=!1;break;case s:K[U].autoResize=JSON.parse(f(9));break;case"scrollBy":!function(){const e=F.width,t=F.height,o=window.parentIframe||window.parentIFrame||window;ae(U,`scrollBy: x: %c${e}%c y: %c${t}`,i,n,i),o.scrollBy(e,t)}();break;case"scrollTo":R(!1);break;case"scrollToOffset":R(!0);break;case p:T();break;case h:x();break;case"pageInfoStop":M();break;case"parentInfoStop":S();break;case"inPageLink":!function(e){const t=e.split("#")[1]||"",n=decodeURIComponent(t);let o=document.getElementById(n)||document.getElementsByName(n)[0];o?function(){const e=O(o);ae(U,`Moving to in page link: %c#${t}`,i),we.position={x:e.x,y:e.y},C(U),window.location.hash=t}():window.top!==window.self&&function(){const e=window.parentIframe||window.parentIFrame;e&&e.moveToAnchor(t)}()}(f(9));break;case"title":!function(e,t){K[t]?.syncTitle&&(K[t].iframe.title=e,ae(t,`Set iframe title attribute: %c${e}`,i))}(a,U);break;case m:Se(F);break;case l:t(),function(e){try{K[e].sameOrigin=!!K[e]?.iframe?.contentWindow?.iframeChildListener}catch(t){K[e].sameOrigin=!1}}(U),(g=a)!==o&&(void 0!==g||he(U,"<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")),K[U].initialised=!0,E("onReady",r);break;default:if(0===u&&0===e)return void se(U,`Unsupported message received (${c}), this is likely due to the iframe containing a later version of iframe-resizer than the parent page`);if(0===u||0===e)return;if(document.hidden)return;t()}var g,y}function P(e){if(!K[e])throw new Error(`${F.type} No settings for ${e}. Message was: ${B}`)}let B=e.data;if("[iFrameResizerChild]Ready"===B)return H=e.source,void Object.values(K).forEach((e=>({initChild:t,postMessageTarget:i})=>{e===i&&t()})(H));var H;if(!(e=>I===`${e}`.slice(0,13)&&e.slice(13).split(a)[0]in K)(B)){if(typeof B!==z)return;return void ce(w,"ignoredMessage")}const F=function(e){const t=e.slice(13).split(a),i=t[1]?Number(t[1]):0,n=K[t[0]]?.iframe,o=getComputedStyle(n),s={iframe:n,id:t[0],height:i+r(o)+c(o),width:Number(t[2]),type:t[3],msg:t[4]};return t[5]&&(s.mode=t[5]),s}(B),{id:q,type:D}=F,U=q;U?(ce(U,D),fe(U,function(t){P(U),F.type in{true:1,false:1,undefined:1}||(null!==F.iframe||(se(U,`The iframe (${F.id}) was not found.`),0))&&function(){const{origin:t,sameOrigin:i}=e;if(i)return!0;let n=K[U]?.checkOrigin;if(n&&"null"!=`${t}`&&!(n.constructor===Array?function(){let e=0,i=!1;for(;e<n.length;e++)if(n[e]===t){i=!0;break}return i}():function(){const e=K[U]?.remoteHost;return t===e}()))throw new Error(`Unexpected message received from: ${t} for ${F.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}()&&L()})(B)):se("","iframeResizer received messageData without id, message was: ",B)}function $e(e,t,i){let n=null,o=null;if(K[e]){if(n=K[e][t],typeof n!==j)throw new TypeError(`${t} on iFrame[${e}] is not a function`);if("onBeforeClose"===t||"onScroll"===t)try{o=n(i)}catch(i){console.error(i),se(e,`Error in ${t} callback`)}else((e,...t)=>{setTimeout(()=>e(...t),0)})(n,i)}return o}function je(e){const{id:t}=e;delete K[t],delete e.iframeResizer}function ke(e){const{id:t}=e;if(!1!==$e(t,"onBeforeClose",t)){try{e.parentNode&&e.remove()}catch(e){se(t,e)}$e(t,"onAfterClose",t),je(e)}}function Te(e){null===we.position&&(we.position={x:window.scrollX,y:window.scrollY})}function xe(){we.position=null}function Me(e){null!==we.position&&(window.scrollTo(we.position.x,we.position.y),ae(e,`Set page position: %c${we.position.x}%c, %c${we.position.y}`,i,n,i),xe())}function Se(e){Te(e.id),Ie(e),Re(m,m,e.id)}function Ie(e){function t(t){const o=`${e[t]}px`;e.iframe.style[t]=o,ae(n,`Set ${t}: %c${o}`,i)}const{id:n}=e,{sizeHeight:o,sizeWidth:r}=K[n];o&&t("height"),r&&t("width")}const Oe=e=>e.split(a).filter((e,t)=>19!==t).join(a);function Re(e,t,o){function r(r){const a=e in R?Oe(t):t;ae(o,r,i,n,i),ae(o,`Message data: %c${a}`,i)}ce(o,e),K[o]&&(K[o]?.postMessageTarget?function(){const{iframe:i,postMessageTarget:n,sameOrigin:a,targetOrigin:s}=K[o];if(a)try{return i.contentWindow.iframeChildListener(I+t),void r(`Sending message to iframe %c${o}%c via same origin%c`)}catch(t){e in R?K[o].sameOrigin=!1:se(o,"Same origin messaging failed, falling back to postMessage")}r(`Sending message to iframe: %c${o}%c targetOrigin: %c${s}`),n.postMessage(I+t,s)}():se(o,`Iframe(${o}) not found`))}let Ce=0,We=!1,Ee=!1;function Le(e,i=-3){if(We)return;const n=Math.max(K[e].mode,i);if(n>K[e].mode&&(K[e].mode=n),n<0)throw ue(e),K[e].vAdvised||he(e||"Parent",`${U(n+2)}${U(2)}`),K[e].vAdvised=!0,U(n+2).replace(/<\/?[a-z][^>]*>|<\/>/gi,"");n>0&&Ee||function(e,i){queueMicrotask(()=>console.info(`%ciframe-resizer ${e}`,te||i<1?"font-weight: bold;":t))}(`v${o} (${(e=>B(q[e]))(n)})`,n),n<1&&he("Parent",U(3)),We=!0}const Ae=e=>t=>{function n(){K[R]?.heightCalculationMethod in O&&Se({iframe:t,height:1,width:1,type:l})}function o(){if(K[R]){const{iframe:e}=K[R],t={close:ke.bind(null,e),disconnect:je.bind(null,e),removeListeners(){he(R,`<rb>Deprecated Method Name</>\n\nThe <b>removeListeners()</> method has been renamed to <b>disconnect()</>. ${L}\n`),this.disconnect()},resize(){he(R,"<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."),Re.bind(null,"Window resize",g,R)},moveToAnchor(e){((e,t,i)=>{if(typeof e!==t)throw new TypeError(`${i} is not a ${n=t,n.charAt(0).toUpperCase()+n.slice(1)}`);var n})(e,z,"moveToAnchor(anchor) anchor"),Re("Move to anchor",`moveToAnchor:${e}`,R)},sendMessage(e){e=JSON.stringify(e),Re(d,`${d}:${e}`,R)}};e.iframeResizer=t,e.iFrameResizer=t}}function p(e,t){const i=i=>()=>{if(!K[e])return;const{firstRun:o,iframe:r}=K[e];Re(i,t,e),(e=>e===l)(i)&&(e=>"lazy"===e.loading)(r)||function(e,t){const i=t[e],{msgTimeout:n,warningTimeout:o}=i;o&&(n&&clearTimeout(n),i.msgTimeout=setTimeout(function(){const i=t[e];void 0!==i&&((e=>{e.msgTimeout=void 0})(i),function(e){const{initialised:t}=e;return t&&(e.initialisedFirstPage=!0),t}(i)||ye(i))},o))}(e,K),o||n()},{iframe:o}=K[e];K[e].initChild=i(c),function(e,t){A(e,u,()=>setTimeout(t,1))}(o,i(f)),function(e,t){const{iframe:i,waitForLoad:n}=K[e];!0!==n&&((e=>{const{src:t,srcdoc:i}=e;return!i&&(null==t||""===t||"about:blank"===t)})(i)?setTimeout(()=>{ce(e,"noContent"),ae(e,"No content detected in the iframe, delaying initialisation")}):setTimeout(t))}(e,i(l))}function h(e){return e?(("sizeWidth"in e||"sizeHeight"in e||s in e)&&he(R,`<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>${M}</>, <bb>${S}</>, <bb>${x}</> or <bb>${T}</>.\n`),e):{}}function m(e){const t=K[e]?.iframe?.title;return""===t||void 0===t}function y(e,t){Z(K[R],e)&&(he(R,`<rb>Deprecated option</>\n\nThe <b>${e}</> option has been renamed to <b>${t}</>. ${L}`),K[R][t]=K[R][e],delete K[R][e])}const w=e=>Z(e,"onMouseEnter")||Z(e,"onMouseLeave");function j(e){var n,o;K[R]={...K[R],iframe:t,remoteHost:t?.src.split("/").slice(0,3).join("/"),...ve,...h(e),mouseEvents:w(e),mode:J(e),syncTitle:m(R)},y("offset","offsetSize"),y("onClose","onBeforeClose"),y("onClosed","onAfterClose"),ce(R,"setup"),function(){const{direction:e}=K[R];switch(e){case M:break;case S:K[R].sizeHeight=!1;case x:K[R].sizeWidth=!0;break;case T:K[R].sizeWidth=!1,K[R].sizeHeight=!1,K[R].autoResize=!1;break;default:throw new TypeError(R,`Direction value of "${e}" is not valid`)}}(),(n=e?.offsetSize||e?.offset)&&(K[R].direction===M?K[R].offsetHeight=n:K[R].offsetWidth=n),K[R].warningTimeout||ae(R,"warningTimeout:%c disabled",i),null===K[R].postMessageTarget&&(K[R].postMessageTarget=t.contentWindow),K[R].targetOrigin=!0===K[R].checkOrigin?""===(o=K[R].remoteHost)||null!==o.match(/^(about:blank|javascript:|file:\/\/)/)?"*":o:"*"}const I=()=>r in t,R=function(i){if(i&&typeof i!==z)throw new TypeError("Invalid id for iFrame. Expected String");return""!==i&&i||(i=function(){let t=e?.id||ve.id+Ce++;return null!==document.getElementById(t)&&(t+=Ce++),t}(),t.id=i,ce(i,"assignId")),i}(t.id);if(typeof e!==$)throw new TypeError("Options is not an object");return function(e){const{search:t}=window.location;t.includes("ifrlog")&&(e.log=W,e.logExpand=t.includes("ifrlog=expanded"))}(e),function(e,t){const i=Z(t,"log"),n=typeof t.log===z,o=i?!!n||t.log:ve.log;Z(t,"logExpand")||(t.logExpand=i&&n?t.log===C:ve.logExpand),function(e){-1===e?.log&&(e.log=!1,Ee=!0)}(t),function({enabled:e,expand:t,iframeId:i}){const n=Q({expand:t,label:ne(i)});te=e,K[i]||(K[i]={console:n})}({enabled:o,expand:t.logExpand,iframeId:e}),n&&!(t.log in E)&&le(e,'Invalid value for options.log: Accepted values are "expanded" and "collapsed"'),t.log=o}(R,e),fe(R,function(e){I()?se(R,`Ignored iframe (${R}), already setup.`):(j(e),function(e){if(!0===be[e])return!1;const t=document.querySelectorAll(`iframe#${CSS.escape(e)}`);if(t.length<=1)return!0;be[e]=!0;const i=Array.from(t).flatMap(e=>[b,e,b]);he(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,b)}(R),function(){if(We)return;const{mode:e}=K[R];-1!==e&&Le(R,e)}(),Pe(),function(){switch(t.style.overflow=!1===K[R]?.scrolling?"hidden":k,K[R]?.scrolling){case"omit":break;case!0:t.scrolling="yes";break;case!1:t.scrolling="no";break;default:t.scrolling=K[R]?K[R].scrolling:"no"}}(),function(){const{bodyMargin:e}=K[R];"number"!=typeof e&&"0"!==e||(K[R].bodyMargin=`${e}px`)}(),p(R,function(e){const{autoResize:t,bodyBackground:i,bodyMargin:n,bodyPadding:o,heightCalculationMethod:r,inPageLinks:s,license:l,log:c,logExpand:u,mouseEvents:d,offsetHeight:f,offsetWidth:p,mode:h,sizeHeight:m,sizeWidth:g,tolerance:y,widthCalculationMethod:b}=K[e];return[e,"8",g,c,"32",!0,t,n,r,i,o,y,s,v,b,d,f,p,m,l,we.version,h,"",u].join(a)}(R)),o(),de(R))})(e),t?.iframeResizer};function Ne(){!0!==document.hidden&&((e,t)=>{Object.values(K).filter(({autoResize:e,firstRun:t})=>e&&!t).forEach(({iframe:i})=>Re(e,t,i.id))})("tabVisible",g)}const Pe=(e=>{let t=!1;return function(){return t?void 0:(t=!0,Reflect.apply(e,this,arguments))}})(()=>{A(window,d,ze),A(document,"visibilitychange",Ne),window.iframeParentListener=e=>setTimeout(()=>ze({data:e,sameOrigin:!0}))});export{Ae as default};
|
|
1
|
+
import tt, { NORMAL as nt, HIGHLIGHT as l, FOREGROUND as w } from "auto-console-group";
|
|
2
|
+
const _ = "6.0.0-beta.1", pe = "iframeResizer", L = ":", ot = "[iFrameResizerChild]Ready", ge = "autoResize", it = "beforeUnload", st = "close", rt = "inPageLink", j = "init", de = "iframeReady", ct = "lazy", G = "load", A = "message", at = "mouseenter", lt = "mouseleave", me = "onload", ye = "pageInfo", be = "parentInfo", ut = "pageInfoStop", ft = "parentInfoStop", U = "reset", Y = "resize", ht = "scrollBy", pt = "scrollTo", gt = "scrollToOffset", dt = "title", ee = 1, mt = "height", yt = "width", bt = "offset", vt = "offsetSize", te = "scroll", C = `
|
|
3
|
+
`, wt = "hidden", zt = "child", V = "parent", X = "string", Et = "number", ve = "object", we = "function", q = "auto", Ot = "font-weight: bold;", ze = "none", Ee = "both", D = "vertical", Oe = "horizontal", Tt = "omit", It = A.length, F = "[iFrameSizer]", Z = F.length, kt = Object.freeze({
|
|
4
|
+
max: 1,
|
|
5
|
+
scroll: 1,
|
|
6
|
+
bodyScroll: 1,
|
|
7
|
+
documentElementScroll: 1
|
|
8
|
+
}), ne = Object.freeze({
|
|
9
|
+
[me]: 1,
|
|
10
|
+
[j]: 1,
|
|
11
|
+
[de]: 1
|
|
12
|
+
}), M = "expanded", S = "collapsed", Te = 0, Ie = 1, ke = 2, $t = Object.freeze({
|
|
13
|
+
[M]: 1,
|
|
14
|
+
[S]: 1
|
|
15
|
+
}), $e = "Use of the old name will be removed in a future version of <i>iframe-resizer</>.", Me = (e) => typeof e === ve && e !== null, K = (e) => typeof e === X;
|
|
16
|
+
function Mt(e) {
|
|
17
|
+
if (!Me(e)) return !1;
|
|
18
|
+
try {
|
|
19
|
+
return e.tagName === "IFRAME" || e instanceof HTMLIFrameElement;
|
|
20
|
+
} catch {
|
|
21
|
+
return !1;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
const St = (e, ...t) => setTimeout(() => e(...t), 0), jt = (e) => {
|
|
25
|
+
let t = !1;
|
|
26
|
+
return function(...n) {
|
|
27
|
+
return t ? void 0 : (t = !0, e.apply(this, n));
|
|
28
|
+
};
|
|
29
|
+
}, Rt = (e, t) => Object.prototype.hasOwnProperty.call(e, t), P = (e, t) => Object.hasOwn ? Object.hasOwn(e, t) : Rt(e, t), Lt = (e) => e, At = (e) => e.charAt(0).toUpperCase() + e.slice(1), Pt = (e) => (
|
|
30
|
+
// eslint-disable-next-line no-underscore-dangle
|
|
31
|
+
e?.__esModule ? e.default : e
|
|
32
|
+
), Nt = (e, t, n) => {
|
|
33
|
+
if (typeof e !== t)
|
|
34
|
+
throw new TypeError(`${n} is not a ${At(t)}`);
|
|
35
|
+
}, Ct = (e) => (t, n = "renamed to") => (o, s, c = "", r = "") => e(
|
|
36
|
+
r,
|
|
37
|
+
`<rb>Deprecated ${t}(${o.replace("()", "")})</>
|
|
38
|
+
|
|
39
|
+
The <b>${o}</> ${t.toLowerCase()} has been ${n} <b>${s}</>. ${c}Use of the old ${t.toLowerCase()} will be removed in a future version of <i>iframe-resizer</>.`
|
|
40
|
+
), Se = {
|
|
41
|
+
br: `
|
|
42
|
+
`,
|
|
43
|
+
rb: "\x1B[31;1m",
|
|
44
|
+
// red bold
|
|
45
|
+
bb: "\x1B[34;1m",
|
|
46
|
+
// blue bold
|
|
47
|
+
b: "\x1B[1m",
|
|
48
|
+
// bold
|
|
49
|
+
i: "\x1B[3m",
|
|
50
|
+
// italic
|
|
51
|
+
u: "\x1B[4m",
|
|
52
|
+
// underline
|
|
53
|
+
"/": "\x1B[m"
|
|
54
|
+
// reset
|
|
55
|
+
}, xt = Object.keys(Se), _t = new RegExp(`<(${xt.join("|")})>`, "gi"), Ft = (e, t) => Se[t] ?? "", Bt = (e) => e.replace(_t, Ft), Wt = (e) => e.replaceAll("<br>", C).replaceAll(/<\/?[^>]+>/gi, ""), je = (e) => (t) => e(
|
|
56
|
+
K(t) ? window.chrome ? Bt(t) : Wt(t) : t
|
|
57
|
+
), i = {}, Re = Pt(tt);
|
|
58
|
+
let Q = !0;
|
|
59
|
+
const Dt = Re({
|
|
60
|
+
expand: !1,
|
|
61
|
+
label: V
|
|
62
|
+
}), Ht = (e) => window.top === window.self ? `parent(${e})` : `nested parent(${e})`, Gt = (e) => i[e] ? i[e].log : Q;
|
|
63
|
+
function Ut({
|
|
64
|
+
enabled: e,
|
|
65
|
+
expand: t,
|
|
66
|
+
iframeId: n
|
|
67
|
+
}) {
|
|
68
|
+
const o = Re({
|
|
69
|
+
expand: t,
|
|
70
|
+
label: Ht(n)
|
|
71
|
+
});
|
|
72
|
+
Q = e, i[n] || (i[n] = {
|
|
73
|
+
console: o
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
const k = (e) => (t, ...n) => i[t] ? i[t].console[e](...n) : Dt[e](...n), Le = (e) => (t, ...n) => Gt(t) === !0 ? k(e)(t, ...n) : null, u = Le("log"), y = u, Vt = Le("debug"), z = k("warn"), qt = k("error"), b = k("event"), Zt = k("purge"), Jt = k("endAutoGroup"), Ae = k("errorBoundary");
|
|
77
|
+
function Yt(e, t) {
|
|
78
|
+
queueMicrotask(
|
|
79
|
+
() => (
|
|
80
|
+
// eslint-disable-next-line no-console
|
|
81
|
+
console.info(
|
|
82
|
+
`%ciframe-resizer ${e}`,
|
|
83
|
+
Q || t < 1 ? Ot : nt
|
|
84
|
+
)
|
|
85
|
+
)
|
|
86
|
+
);
|
|
87
|
+
}
|
|
88
|
+
const Xt = (e) => (...t) => [`${pe}(${e})`, ...t].join(" "), Kt = je(Lt), m = (e, ...t) => i[e] ? i[e].console.warn(...t.map(Kt)) : queueMicrotask(() => {
|
|
89
|
+
const n = je(Xt(e));
|
|
90
|
+
console?.warn(...t.map(n));
|
|
91
|
+
}), Qt = Ct(m), en = Qt("Option"), tn = (e) => {
|
|
92
|
+
typeof i[e.id].onInit === we && (en("init()", "onReady()", "", e.id), i[e.id].onInit(e));
|
|
93
|
+
}, B = Object.freeze({
|
|
94
|
+
autoResize: !0,
|
|
95
|
+
bodyBackground: null,
|
|
96
|
+
bodyMargin: null,
|
|
97
|
+
bodyPadding: null,
|
|
98
|
+
checkOrigin: !0,
|
|
99
|
+
direction: D,
|
|
100
|
+
firstRun: !0,
|
|
101
|
+
inPageLinks: !1,
|
|
102
|
+
heightCalculationMethod: q,
|
|
103
|
+
id: "iFrameResizer",
|
|
104
|
+
// TODO: v6 change to 'iframeResizer'
|
|
105
|
+
log: !1,
|
|
106
|
+
logExpand: !1,
|
|
107
|
+
license: void 0,
|
|
108
|
+
mouseEvents: !0,
|
|
109
|
+
offsetHeight: null,
|
|
110
|
+
offsetWidth: null,
|
|
111
|
+
postMessageTarget: null,
|
|
112
|
+
sameDomain: !1,
|
|
113
|
+
scrolling: !1,
|
|
114
|
+
sizeHeight: !0,
|
|
115
|
+
// sizeSelector: '',
|
|
116
|
+
sizeWidth: !1,
|
|
117
|
+
tolerance: 0,
|
|
118
|
+
waitForLoad: !1,
|
|
119
|
+
warningTimeout: 5e3,
|
|
120
|
+
widthCalculationMethod: q,
|
|
121
|
+
onBeforeClose: () => !0,
|
|
122
|
+
onAfterClose() {
|
|
123
|
+
},
|
|
124
|
+
onInit: !1,
|
|
125
|
+
onMessage: null,
|
|
126
|
+
onMouseEnter() {
|
|
127
|
+
},
|
|
128
|
+
onMouseLeave() {
|
|
129
|
+
},
|
|
130
|
+
onReady: tn,
|
|
131
|
+
onResized() {
|
|
132
|
+
},
|
|
133
|
+
onScroll: () => !0
|
|
134
|
+
});
|
|
135
|
+
let oe = 0;
|
|
136
|
+
function nn(e) {
|
|
137
|
+
const t = e?.id || B.id + oe++;
|
|
138
|
+
return document.getElementById(t) === null ? t : `${t}${oe++}`;
|
|
139
|
+
}
|
|
140
|
+
function on(e, t) {
|
|
141
|
+
let { id: n } = e;
|
|
142
|
+
if (n && !K(n))
|
|
143
|
+
throw new TypeError("Invalid id for iFrame. Expected String");
|
|
144
|
+
return (!n || n === "") && (n = nn(t), e.id = n, b(n, "assignId"), u(n, `Added missing iframe ID: ${n} (${e.src})`)), n;
|
|
145
|
+
}
|
|
146
|
+
function sn(e) {
|
|
147
|
+
const { search: t } = window.location;
|
|
148
|
+
if (t.includes("ifrlog"))
|
|
149
|
+
switch (new URLSearchParams(t).get("ifrlog")) {
|
|
150
|
+
case String(Te): {
|
|
151
|
+
e.log = !1;
|
|
152
|
+
break;
|
|
153
|
+
}
|
|
154
|
+
case M:
|
|
155
|
+
case String(ke): {
|
|
156
|
+
e.log = M;
|
|
157
|
+
break;
|
|
158
|
+
}
|
|
159
|
+
case S:
|
|
160
|
+
case String(Ie): {
|
|
161
|
+
e.log = S;
|
|
162
|
+
break;
|
|
163
|
+
}
|
|
164
|
+
default:
|
|
165
|
+
e.log = S;
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
const N = (e, t, n, o) => e.addEventListener(t, n, o || !1), ie = (e, t, n) => e.removeEventListener(t, n, !1), rn = (e) => e.split(L).filter((t, n) => n !== 19).join(L);
|
|
169
|
+
function cn(e, t, n) {
|
|
170
|
+
function o(f) {
|
|
171
|
+
const h = e in ne ? rn(t) : t;
|
|
172
|
+
y(n, f, l, w, l), y(n, `Message data: %c${h}`, l);
|
|
173
|
+
}
|
|
174
|
+
const { iframe: s, postMessageTarget: c, sameOrigin: r, targetOrigin: a } = i[n];
|
|
175
|
+
if (r)
|
|
176
|
+
try {
|
|
177
|
+
s.contentWindow.iframeChildListener(F + t), o(`Sending message to iframe %c${n}%c via same origin%c`);
|
|
178
|
+
return;
|
|
179
|
+
} catch {
|
|
180
|
+
e in ne ? (i[n].sameOrigin = !1, u(n, "New iframe does not support same origin")) : z(n, "Same origin messaging failed, falling back to postMessage");
|
|
181
|
+
}
|
|
182
|
+
o(
|
|
183
|
+
`Sending message to iframe: %c${n}%c targetOrigin: %c${a.join(", ")}`
|
|
184
|
+
);
|
|
185
|
+
for (const f of a)
|
|
186
|
+
c.postMessage(F + t, f);
|
|
187
|
+
}
|
|
188
|
+
function T(e, t, n) {
|
|
189
|
+
if (b(n, e), !i[n]?.postMessageTarget) {
|
|
190
|
+
z(n, "Iframe not found");
|
|
191
|
+
return;
|
|
192
|
+
}
|
|
193
|
+
cn(e, t, n);
|
|
194
|
+
}
|
|
195
|
+
const an = (e, t) => Object.values(i).filter(({ autoResize: n, firstRun: o }) => n && !o).forEach(({ iframe: n }) => T(e, t, n.id));
|
|
196
|
+
function ln() {
|
|
197
|
+
document.hidden !== !0 && an("tabVisible", Y);
|
|
198
|
+
}
|
|
199
|
+
function un(e) {
|
|
200
|
+
if (e.boxSizing !== "border-box") return 0;
|
|
201
|
+
const t = e.paddingTop ? parseInt(e.paddingTop, 10) : 0, n = e.paddingBottom ? parseInt(e.paddingBottom, 10) : 0;
|
|
202
|
+
return t + n;
|
|
203
|
+
}
|
|
204
|
+
function fn(e) {
|
|
205
|
+
if (e.boxSizing !== "border-box") return 0;
|
|
206
|
+
const t = e.borderTopWidth ? parseInt(e.borderTopWidth, 10) : 0, n = e.borderBottomWidth ? parseInt(e.borderBottomWidth, 10) : 0;
|
|
207
|
+
return t + n;
|
|
208
|
+
}
|
|
209
|
+
function hn(e) {
|
|
210
|
+
const t = e.slice(Z).split(":"), n = t[1] ? Number(t[1]) : 0, o = i[t[0]]?.iframe, s = getComputedStyle(o), c = {
|
|
211
|
+
iframe: o,
|
|
212
|
+
id: t[0],
|
|
213
|
+
height: n + un(s) + fn(s),
|
|
214
|
+
width: Number(t[2]),
|
|
215
|
+
type: t[3],
|
|
216
|
+
msg: t[4],
|
|
217
|
+
message: t[4]
|
|
218
|
+
};
|
|
219
|
+
return t[5] && (c.mode = t[5]), c;
|
|
220
|
+
}
|
|
221
|
+
const pn = { true: 1, false: 1, undefined: 1 };
|
|
222
|
+
function gn(e) {
|
|
223
|
+
const { id: t, msg: n, iframe: o } = e, s = Mt(o);
|
|
224
|
+
return s || (u(t, `Received: %c${n}`, l), z(t, "The target iframe was not found.")), s;
|
|
225
|
+
}
|
|
226
|
+
function dn(e, t) {
|
|
227
|
+
const { id: n } = e, { data: o, origin: s } = t;
|
|
228
|
+
if ("sameOrigin" in t && t.sameOrigin) return !0;
|
|
229
|
+
const r = i[n]?.checkOrigin;
|
|
230
|
+
function a() {
|
|
231
|
+
function f() {
|
|
232
|
+
u(
|
|
233
|
+
n,
|
|
234
|
+
`Checking connection is from allowed list of origins: %c${r}`,
|
|
235
|
+
l
|
|
236
|
+
);
|
|
237
|
+
for (const g of r)
|
|
238
|
+
if (g === s)
|
|
239
|
+
return !0;
|
|
240
|
+
return !1;
|
|
241
|
+
}
|
|
242
|
+
function h() {
|
|
243
|
+
const g = i[n]?.remoteHost;
|
|
244
|
+
return u(n, `Checking connection is from: %c${g}`, l), s === g;
|
|
245
|
+
}
|
|
246
|
+
return r.constructor === Array ? f() : h();
|
|
247
|
+
}
|
|
248
|
+
if (r && `${s}` != "null" && !a())
|
|
249
|
+
throw new Error(
|
|
250
|
+
`Unexpected message received from: ${s} for ${n}. Message was: ${o}. This error can be disabled by setting the checkOrigin: false option or by providing an array of trusted domains.`
|
|
251
|
+
);
|
|
252
|
+
return !0;
|
|
253
|
+
}
|
|
254
|
+
const mn = (e) => F === `${e}`.slice(0, Z) && e.slice(Z).split(":")[0] in i;
|
|
255
|
+
function yn(e) {
|
|
256
|
+
const { id: t, type: n } = e, o = n in pn;
|
|
257
|
+
return o && u(t, "Ignoring init message from meta parent page"), o;
|
|
258
|
+
}
|
|
259
|
+
function bn(e) {
|
|
260
|
+
try {
|
|
261
|
+
i[e].sameOrigin = !!i[e]?.iframe?.contentWindow?.iframeChildListener;
|
|
262
|
+
} catch {
|
|
263
|
+
i[e].sameOrigin = !1;
|
|
264
|
+
}
|
|
265
|
+
u(e, `sameOrigin: %c${i[e].sameOrigin}`, l);
|
|
266
|
+
}
|
|
267
|
+
function vn(e, t) {
|
|
268
|
+
if (t !== _) {
|
|
269
|
+
if (t === void 0) {
|
|
270
|
+
m(
|
|
271
|
+
e,
|
|
272
|
+
`<rb>Legacy version detected in iframe</>
|
|
273
|
+
|
|
274
|
+
Detected legacy version of child page script. It is recommended to update the page in the iframe to use <b>@iframe-resizer/child</>.
|
|
275
|
+
|
|
276
|
+
See <u>https://iframe-resizer.com/setup/#child-page-setup</> for more details.
|
|
277
|
+
`
|
|
278
|
+
);
|
|
279
|
+
return;
|
|
280
|
+
}
|
|
281
|
+
u(
|
|
282
|
+
e,
|
|
283
|
+
`Version mismatch (Child: %c${t}%c !== Parent: %c${_})`,
|
|
284
|
+
l,
|
|
285
|
+
w,
|
|
286
|
+
l
|
|
287
|
+
);
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
function I(e, t, n) {
|
|
291
|
+
if (!i[e]) return null;
|
|
292
|
+
const o = i[e][t];
|
|
293
|
+
if (typeof o !== we)
|
|
294
|
+
throw new TypeError(`${t} on iframe[${e}] is not a function`);
|
|
295
|
+
if (t !== "onBeforeClose" && t !== "onScroll")
|
|
296
|
+
return St(o, n);
|
|
297
|
+
try {
|
|
298
|
+
return o(n);
|
|
299
|
+
} catch (s) {
|
|
300
|
+
return console.error(s), z(e, `Error in ${t} callback`), null;
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
function wn(e, t) {
|
|
304
|
+
const { id: n, iframe: o } = e;
|
|
305
|
+
u(
|
|
306
|
+
n,
|
|
307
|
+
`onMessage passed: {iframe: %c${n}%c, message: %c${t}%c}`,
|
|
308
|
+
l,
|
|
309
|
+
w,
|
|
310
|
+
l,
|
|
311
|
+
w
|
|
312
|
+
), I(n, "onMessage", {
|
|
313
|
+
iframe: o,
|
|
314
|
+
message: JSON.parse(t)
|
|
315
|
+
});
|
|
316
|
+
}
|
|
317
|
+
function x(e, t) {
|
|
318
|
+
const { lastMessage: n } = i[e];
|
|
319
|
+
return n.slice(
|
|
320
|
+
n.indexOf(L) + It + t
|
|
321
|
+
);
|
|
322
|
+
}
|
|
323
|
+
function se(e, t) {
|
|
324
|
+
const { id: n, iframe: o, height: s, type: c, width: r } = t;
|
|
325
|
+
let a = { x: 0, y: 0 };
|
|
326
|
+
if (r === 0 && s === 0) {
|
|
327
|
+
const f = x(n, 9).split(L);
|
|
328
|
+
a = {
|
|
329
|
+
x: f[1],
|
|
330
|
+
y: f[0]
|
|
331
|
+
};
|
|
332
|
+
} else
|
|
333
|
+
a = {
|
|
334
|
+
x: r,
|
|
335
|
+
y: s
|
|
336
|
+
};
|
|
337
|
+
I(n, e, {
|
|
338
|
+
iframe: o,
|
|
339
|
+
screenX: Number(a.x),
|
|
340
|
+
screenY: Number(a.y),
|
|
341
|
+
type: c
|
|
342
|
+
});
|
|
343
|
+
}
|
|
344
|
+
const p = {
|
|
345
|
+
position: null,
|
|
346
|
+
version: _
|
|
347
|
+
};
|
|
348
|
+
function Pe() {
|
|
349
|
+
p.position = null;
|
|
350
|
+
}
|
|
351
|
+
const zn = () => p.position;
|
|
352
|
+
function En(e) {
|
|
353
|
+
p.position = e;
|
|
354
|
+
}
|
|
355
|
+
function Ne(e) {
|
|
356
|
+
return p.position === null && (p.position = {
|
|
357
|
+
x: window.scrollX,
|
|
358
|
+
y: window.scrollY
|
|
359
|
+
}), u(
|
|
360
|
+
e,
|
|
361
|
+
`Get page position: %c${p.position.x}%c, %c${p.position.y}`,
|
|
362
|
+
l,
|
|
363
|
+
w,
|
|
364
|
+
l
|
|
365
|
+
), p.position;
|
|
366
|
+
}
|
|
367
|
+
function Ce(e) {
|
|
368
|
+
p.position !== null && (window.scrollTo(p.position.x, p.position.y), y(
|
|
369
|
+
e,
|
|
370
|
+
`Set page position: %c${p.position.x}%c, %c${p.position.y}`,
|
|
371
|
+
l,
|
|
372
|
+
w,
|
|
373
|
+
l
|
|
374
|
+
), Pe());
|
|
375
|
+
}
|
|
376
|
+
function re(e, t) {
|
|
377
|
+
const { id: n } = t, o = `${t[e]}px`;
|
|
378
|
+
i[n].iframe.style[e] = o, y(n, `Set ${e}: %c${o}`, l);
|
|
379
|
+
}
|
|
380
|
+
function xe(e) {
|
|
381
|
+
const { id: t } = e, { sizeHeight: n, sizeWidth: o } = i[t];
|
|
382
|
+
n && re(mt, e), o && re(yt, e);
|
|
383
|
+
}
|
|
384
|
+
function ce(e) {
|
|
385
|
+
const { id: t } = e;
|
|
386
|
+
xe(e), Ce(t), I(t, "onResized", e);
|
|
387
|
+
}
|
|
388
|
+
function _e(e) {
|
|
389
|
+
const { id: t } = e;
|
|
390
|
+
u(t, "Disconnected from iframe"), delete i[t], delete e.iframeResizer;
|
|
391
|
+
}
|
|
392
|
+
function Fe(e) {
|
|
393
|
+
const { id: t } = e;
|
|
394
|
+
if (I(t, "onBeforeClose", t) === !1) {
|
|
395
|
+
u(t, "Close iframe cancelled by onBeforeClose");
|
|
396
|
+
return;
|
|
397
|
+
}
|
|
398
|
+
u(t, `Removing iFrame: %c${t}`, l);
|
|
399
|
+
try {
|
|
400
|
+
e.parentNode && e.remove();
|
|
401
|
+
} catch (n) {
|
|
402
|
+
z(t, n);
|
|
403
|
+
}
|
|
404
|
+
I(t, "onAfterClose", t), _e(e);
|
|
405
|
+
}
|
|
406
|
+
function Be(e) {
|
|
407
|
+
const { id: t, type: n } = e;
|
|
408
|
+
u(
|
|
409
|
+
t,
|
|
410
|
+
`Size reset requested by ${n === j ? "parent page" : "child page"}`
|
|
411
|
+
), Ne(t), xe(e), T(U, U, t);
|
|
412
|
+
}
|
|
413
|
+
const We = (e, t) => {
|
|
414
|
+
const n = {};
|
|
415
|
+
return (o, s) => {
|
|
416
|
+
const { iframe: c } = i[s];
|
|
417
|
+
function r(f, h) {
|
|
418
|
+
n[h] || (f(), n[h] = requestAnimationFrame(() => {
|
|
419
|
+
n[h] = null;
|
|
420
|
+
}));
|
|
421
|
+
}
|
|
422
|
+
function a() {
|
|
423
|
+
T(`${o} (${e})`, `${e}:${t(c)}`, s);
|
|
424
|
+
}
|
|
425
|
+
r(a, s);
|
|
426
|
+
};
|
|
427
|
+
}, De = (e) => (t) => {
|
|
428
|
+
e in i[t] && (i[t][e](), delete i[t][e]);
|
|
429
|
+
}, He = (
|
|
430
|
+
// eslint-disable-next-line @typescript-eslint/no-shadow
|
|
431
|
+
((e, t) => (n) => {
|
|
432
|
+
let o = !1;
|
|
433
|
+
const s = (d) => () => {
|
|
434
|
+
i[n] ? (!o || o === d) && (e(d, n), o = d, requestAnimationFrame(() => {
|
|
435
|
+
o = !1;
|
|
436
|
+
})) : g();
|
|
437
|
+
}, c = s(te), r = s("resize window"), a = new ResizeObserver(s("pageObserver")), f = new ResizeObserver(s("iframeObserver"));
|
|
438
|
+
function h(d, E) {
|
|
439
|
+
u(n, `${d}listeners for send${t}`), E(window, te, c), E(window, Y, r);
|
|
440
|
+
}
|
|
441
|
+
function g() {
|
|
442
|
+
b(n, `stop${t}`), h("Remove ", ie), a.disconnect(), f.disconnect(), i[n] && ie(i[n].iframe, G, g);
|
|
443
|
+
}
|
|
444
|
+
function $() {
|
|
445
|
+
h("Add ", N), a.observe(document.body), f.observe(i[n].iframe);
|
|
446
|
+
}
|
|
447
|
+
i[n] && (i[n][`stop${t}`] = g, N(i[n].iframe, G, g), $());
|
|
448
|
+
})
|
|
449
|
+
);
|
|
450
|
+
function On(e) {
|
|
451
|
+
const t = document.body.getBoundingClientRect(), n = e.getBoundingClientRect(), { scrollY: o, scrollX: s, innerHeight: c, innerWidth: r } = window, { clientHeight: a, clientWidth: f } = document.documentElement;
|
|
452
|
+
return JSON.stringify({
|
|
453
|
+
iframeHeight: n.height,
|
|
454
|
+
iframeWidth: n.width,
|
|
455
|
+
clientHeight: Math.max(a, c || 0),
|
|
456
|
+
clientWidth: Math.max(f, r || 0),
|
|
457
|
+
offsetTop: Math.trunc(n.top - t.top),
|
|
458
|
+
offsetLeft: Math.trunc(n.left - t.left),
|
|
459
|
+
scrollTop: o,
|
|
460
|
+
scrollLeft: s,
|
|
461
|
+
documentHeight: a,
|
|
462
|
+
documentWidth: f,
|
|
463
|
+
windowHeight: c,
|
|
464
|
+
windowWidth: r
|
|
465
|
+
});
|
|
466
|
+
}
|
|
467
|
+
const Tn = We(ye, On), In = He(
|
|
468
|
+
Tn,
|
|
469
|
+
"PageInfo"
|
|
470
|
+
), kn = De("stopPageInfo");
|
|
471
|
+
function $n(e) {
|
|
472
|
+
const { scrollWidth: t, scrollHeight: n } = document.documentElement, { width: o, height: s, offsetLeft: c, offsetTop: r, pageLeft: a, pageTop: f, scale: h } = window.visualViewport;
|
|
473
|
+
return JSON.stringify({
|
|
474
|
+
iframe: e.getBoundingClientRect(),
|
|
475
|
+
document: {
|
|
476
|
+
scrollWidth: t,
|
|
477
|
+
scrollHeight: n
|
|
478
|
+
},
|
|
479
|
+
viewport: {
|
|
480
|
+
width: o,
|
|
481
|
+
height: s,
|
|
482
|
+
offsetLeft: c,
|
|
483
|
+
offsetTop: r,
|
|
484
|
+
pageLeft: a,
|
|
485
|
+
pageTop: f,
|
|
486
|
+
scale: h
|
|
487
|
+
}
|
|
488
|
+
});
|
|
489
|
+
}
|
|
490
|
+
const Mn = We(be, $n), Sn = He(
|
|
491
|
+
Mn,
|
|
492
|
+
"ParentInfo"
|
|
493
|
+
), jn = De("stopParentInfo");
|
|
494
|
+
function Ge(e) {
|
|
495
|
+
const t = e.getBoundingClientRect(), n = Ne(e.id);
|
|
496
|
+
return {
|
|
497
|
+
x: Number(t.left) + Number(n.x),
|
|
498
|
+
y: Number(t.top) + Number(n.y)
|
|
499
|
+
};
|
|
500
|
+
}
|
|
501
|
+
function Ue(e) {
|
|
502
|
+
const { x: t, y: n } = zn(), o = i[e]?.iframe;
|
|
503
|
+
if (I(e, "onScroll", { iframe: o, top: n, left: t, x: t, y: n }) === !1) {
|
|
504
|
+
Pe();
|
|
505
|
+
return;
|
|
506
|
+
}
|
|
507
|
+
Ce(e);
|
|
508
|
+
}
|
|
509
|
+
function Rn(e) {
|
|
510
|
+
const { id: t, height: n, width: o } = e, s = window.parentIframe || window.parentIFrame || window;
|
|
511
|
+
y(
|
|
512
|
+
t,
|
|
513
|
+
`scrollBy: x: %c${o}%c y: %c${n}`,
|
|
514
|
+
l,
|
|
515
|
+
w,
|
|
516
|
+
l
|
|
517
|
+
), s.scrollBy(o, n);
|
|
518
|
+
}
|
|
519
|
+
const Ve = (e) => (t) => {
|
|
520
|
+
const { id: n, iframe: o, height: s, width: c } = t;
|
|
521
|
+
function r(d) {
|
|
522
|
+
En(d), Ue(n);
|
|
523
|
+
}
|
|
524
|
+
function a(d, E) {
|
|
525
|
+
d[`scrollTo${e ? "Offset" : ""}`](
|
|
526
|
+
E.x,
|
|
527
|
+
E.y
|
|
528
|
+
);
|
|
529
|
+
}
|
|
530
|
+
const f = (d) => ({
|
|
531
|
+
x: c + d.x,
|
|
532
|
+
y: s + d.y
|
|
533
|
+
}), h = e ? Ge(o) : { x: 0, y: 0 }, g = f(h), $ = window.parentIframe || window.parentIFrame;
|
|
534
|
+
y(
|
|
535
|
+
n,
|
|
536
|
+
`Reposition requested (offset x:%c${h.x}%c y:%c${h.y})`,
|
|
537
|
+
l,
|
|
538
|
+
w,
|
|
539
|
+
l
|
|
540
|
+
), $ ? a($, g) : r(g);
|
|
541
|
+
}, Ln = Ve(!1), An = Ve(!0);
|
|
542
|
+
function Pn(e, t, n) {
|
|
543
|
+
const { x: o, y: s } = Ge(n);
|
|
544
|
+
y(e, `Moving to in page link: %c#${t}`, l), p.position = { x: o, y: s }, Ue(e), window.location.hash = t;
|
|
545
|
+
}
|
|
546
|
+
function Nn(e, t) {
|
|
547
|
+
const n = window.parentIframe || window.parentIFrame;
|
|
548
|
+
if (!n) {
|
|
549
|
+
u(e, `In page link #${t} not found`);
|
|
550
|
+
return;
|
|
551
|
+
}
|
|
552
|
+
n.moveToAnchor(t);
|
|
553
|
+
}
|
|
554
|
+
function Cn(e, t) {
|
|
555
|
+
const n = t.split("#")[1] || "", o = decodeURIComponent(n), s = document.getElementById(o) || document.getElementsByName(o)[0];
|
|
556
|
+
if (s) {
|
|
557
|
+
Pn(e, n, s);
|
|
558
|
+
return;
|
|
559
|
+
}
|
|
560
|
+
if (window.top === window.self) {
|
|
561
|
+
u(e, `In page link #${n} not found`);
|
|
562
|
+
return;
|
|
563
|
+
}
|
|
564
|
+
Nn(e, n);
|
|
565
|
+
}
|
|
566
|
+
function xn(e) {
|
|
567
|
+
const t = i[e]?.iframe?.title;
|
|
568
|
+
return t === "" || t === void 0;
|
|
569
|
+
}
|
|
570
|
+
function _n(e, t) {
|
|
571
|
+
i[e]?.syncTitle && (i[e].iframe.title = t, y(e, `Set iframe title attribute: %c${t}`, l));
|
|
572
|
+
}
|
|
573
|
+
const W = (e) => {
|
|
574
|
+
if (!e) return "";
|
|
575
|
+
let t = -559038744, n = 1103547984;
|
|
576
|
+
for (let o, s = 0; s < e.length; s++)
|
|
577
|
+
o = e.codePointAt(s), t = Math.imul(t ^ o, 2246822519), n = Math.imul(n ^ o, 3266489917);
|
|
578
|
+
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);
|
|
579
|
+
}, v = (e) => e.replace(
|
|
580
|
+
/[A-Za-z]/g,
|
|
581
|
+
(t) => String.fromCodePoint(
|
|
582
|
+
(t <= "Z" ? 90 : 122) >= (t = t.codePointAt(0) + 19) ? t : t - 26
|
|
583
|
+
)
|
|
584
|
+
), Fn = /* @__PURE__ */ new Date(), qe = (e) => new Set(Array.from({ length: 9 }, e)), Bn = (e) => [
|
|
585
|
+
e[0],
|
|
586
|
+
...e.slice(1).map((t) => `${t} - lewpylk`),
|
|
587
|
+
`${e[4]} - lewpylk`,
|
|
588
|
+
...e.slice(1)
|
|
589
|
+
], R = ["spjluzl", "rlf", "clyzpvu", "rlf2", "nlaMbssFlhy"], Wn = [
|
|
590
|
+
"<yi>Puchspk Spjluzl Rlf</><iy><iy>",
|
|
591
|
+
"<yi>Tpzzpun Spjluzl Rlf</><iy><iy>",
|
|
592
|
+
"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</>",
|
|
593
|
+
"<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</>.",
|
|
594
|
+
"<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.",
|
|
595
|
+
"Pu whnl spurpun ylxbpylz h Wyvmlzzpvuhs vy Ibzpulzz spjluzl. Wslhzl zll <b>oaawz://pmyhtl-ylzpgly.jvt/wypjpun</> mvy tvyl klahpsz.",
|
|
596
|
+
"<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</>.",
|
|
597
|
+
// Upgrade
|
|
598
|
+
"<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.",
|
|
599
|
+
// Upgrade OEM
|
|
600
|
+
"<yi>VLT rlf lewpylk</><iy><iy>Wslhzl kvdusvhk aol shalza rlf myvt sltvu-zxbllgf.jvt."
|
|
601
|
+
// key expired
|
|
602
|
+
], Dn = Bn(["NWSc3", "zvsv", "wyv", "ibzpulzz", "VLT"]), ae = Object.fromEntries(
|
|
603
|
+
[
|
|
604
|
+
"2cgs7fdf4xb",
|
|
605
|
+
"1c9ctcccr4z",
|
|
606
|
+
"1q2pc4eebgb",
|
|
607
|
+
"ueokt0969w",
|
|
608
|
+
"w2zxchhgqz",
|
|
609
|
+
"1umuxblj2e5",
|
|
610
|
+
"1foobarqaz",
|
|
611
|
+
"2b5sdlfhbev",
|
|
612
|
+
"zo4ui3arjo",
|
|
613
|
+
"oclbb4thgl",
|
|
614
|
+
"igb1wzrjqr"
|
|
615
|
+
].map((e, t) => [e, Math.max(0, t - 1)])
|
|
616
|
+
), Ze = Fn[v(R[4])](), Hn = qe((e, t) => W(`${Ze + t}`)), Gn = qe((e, t) => W(`${Ze - ++t}`)), Un = (e) => Hn.has(e) ? 9 : Gn.has(e) ? 5 : -2, O = (e) => v(Wn[e]), Vn = (e) => v(Dn[e]), qn = (e) => {
|
|
617
|
+
const t = e[v(R[0])] || e[v(R[1])] || e[v(R[2])] || e[v(R[3])];
|
|
618
|
+
if (!t) return -1;
|
|
619
|
+
const n = t.split("-");
|
|
620
|
+
let o = (function(s = "", c = "") {
|
|
621
|
+
let r = -2;
|
|
622
|
+
const a = W(v(s));
|
|
623
|
+
return a in ae && (r = ae[a]), r === 9 ? Un(c) : r;
|
|
624
|
+
})(...n);
|
|
625
|
+
return o === 0 || ((s) => s[2] === W(s[0] + s[1]))(n) || (o = -2), o;
|
|
626
|
+
};
|
|
627
|
+
let J = !1, Je = !1;
|
|
628
|
+
function Ye(e, t = -3) {
|
|
629
|
+
if (J) return;
|
|
630
|
+
const n = Math.max(i[e].mode, t);
|
|
631
|
+
if (n > i[e].mode && (i[e].mode = n), n < 0)
|
|
632
|
+
throw Zt(e), i[e].vAdvised || m(e || "Parent", `${O(n + 2)}${O(2)}`), i[e].vAdvised = !0, O(n + 2).replace(/<\/?[a-z][^>]*>|<\/>/gi, "");
|
|
633
|
+
switch (n > 5 && Je || Yt(`v${_} (${Vn(n)})`, n), n) {
|
|
634
|
+
case 1:
|
|
635
|
+
case 2:
|
|
636
|
+
case 3:
|
|
637
|
+
m(e, O(6));
|
|
638
|
+
break;
|
|
639
|
+
case 4:
|
|
640
|
+
m(e, O(7));
|
|
641
|
+
break;
|
|
642
|
+
case 5:
|
|
643
|
+
m(e, O(8));
|
|
644
|
+
break;
|
|
645
|
+
default:
|
|
646
|
+
n < 1 && m("Parent", O(3));
|
|
647
|
+
}
|
|
648
|
+
J = !0;
|
|
649
|
+
}
|
|
650
|
+
function Zn(e) {
|
|
651
|
+
if (J) return;
|
|
652
|
+
const { mode: t } = i[e];
|
|
653
|
+
t > 5 && Ye(e, t);
|
|
654
|
+
}
|
|
655
|
+
function Jn(e) {
|
|
656
|
+
e?.log === -1 && (e.log = !1, Je = !0);
|
|
657
|
+
}
|
|
658
|
+
function Yn(e, t) {
|
|
659
|
+
i[e] && (u(e, `First run for ${e}`), Ye(e, t === void 0 ? void 0 : Number(t)), i[e].firstRun = !1);
|
|
660
|
+
}
|
|
661
|
+
function Xn(e) {
|
|
662
|
+
const { height: t, id: n, iframe: o, mode: s, message: c, type: r, width: a } = e, { lastMessage: f } = i[n];
|
|
663
|
+
switch (i[n]?.firstRun && Yn(n, s), u(n, `Received: %c${f}`, l), r) {
|
|
664
|
+
case ge:
|
|
665
|
+
i[n].autoResize = JSON.parse(x(n, 9));
|
|
666
|
+
break;
|
|
667
|
+
case it:
|
|
668
|
+
y(n, "Ready state reset"), i[n].initialised = !1;
|
|
669
|
+
break;
|
|
670
|
+
case st:
|
|
671
|
+
Fe(o);
|
|
672
|
+
break;
|
|
673
|
+
case rt:
|
|
674
|
+
Cn(n, x(n, 9));
|
|
675
|
+
break;
|
|
676
|
+
case j:
|
|
677
|
+
ce(e), bn(n), vn(n, c), i[n].initialised = !0, I(n, "onReady", o);
|
|
678
|
+
break;
|
|
679
|
+
case A:
|
|
680
|
+
wn(e, x(n, 6));
|
|
681
|
+
break;
|
|
682
|
+
case at:
|
|
683
|
+
se("onMouseEnter", e);
|
|
684
|
+
break;
|
|
685
|
+
case lt:
|
|
686
|
+
se("onMouseLeave", e);
|
|
687
|
+
break;
|
|
688
|
+
case ye:
|
|
689
|
+
In(n);
|
|
690
|
+
break;
|
|
691
|
+
case be:
|
|
692
|
+
Sn(n);
|
|
693
|
+
break;
|
|
694
|
+
case ut:
|
|
695
|
+
kn(n);
|
|
696
|
+
break;
|
|
697
|
+
case ft:
|
|
698
|
+
jn(n);
|
|
699
|
+
break;
|
|
700
|
+
case U:
|
|
701
|
+
Be(e);
|
|
702
|
+
break;
|
|
703
|
+
case ht:
|
|
704
|
+
Rn(e);
|
|
705
|
+
break;
|
|
706
|
+
case pt:
|
|
707
|
+
Ln(e);
|
|
708
|
+
break;
|
|
709
|
+
case gt:
|
|
710
|
+
An(e);
|
|
711
|
+
break;
|
|
712
|
+
case dt:
|
|
713
|
+
_n(n, c);
|
|
714
|
+
break;
|
|
715
|
+
default:
|
|
716
|
+
if (a === 0 && t === 0) {
|
|
717
|
+
z(
|
|
718
|
+
n,
|
|
719
|
+
`Unsupported message received (${r}), this is likely due to the iframe containing a later version of iframe-resizer than the parent page`
|
|
720
|
+
);
|
|
721
|
+
return;
|
|
722
|
+
}
|
|
723
|
+
if (a === 0 || t === 0) {
|
|
724
|
+
u(n, "Ignoring message with 0 height or width");
|
|
725
|
+
return;
|
|
726
|
+
}
|
|
727
|
+
if (document.hidden) {
|
|
728
|
+
u(n, "Page hidden - ignored resize request");
|
|
729
|
+
return;
|
|
730
|
+
}
|
|
731
|
+
ce(e);
|
|
732
|
+
}
|
|
733
|
+
}
|
|
734
|
+
const Kn = (e) => ({
|
|
735
|
+
initChild: t,
|
|
736
|
+
postMessageTarget: n
|
|
737
|
+
}) => {
|
|
738
|
+
e === n && t();
|
|
739
|
+
}, Qn = (e) => Object.values(i).forEach(Kn(e));
|
|
740
|
+
function le(e) {
|
|
741
|
+
const t = e.data;
|
|
742
|
+
if (t === ot) {
|
|
743
|
+
Qn(e.source);
|
|
744
|
+
return;
|
|
745
|
+
}
|
|
746
|
+
if (!mn(t)) {
|
|
747
|
+
if (typeof t !== X) return;
|
|
748
|
+
b(V, "ignoredMessage"), Vt(V, t);
|
|
749
|
+
return;
|
|
750
|
+
}
|
|
751
|
+
const n = hn(t), { id: o, type: s } = n;
|
|
752
|
+
switch (b(o, s), !0) {
|
|
753
|
+
case !i[o]:
|
|
754
|
+
throw new Error(`${s} No settings for ${o}. Message was: ${t}`);
|
|
755
|
+
case !gn(n):
|
|
756
|
+
case yn(n):
|
|
757
|
+
case !dn(n, e):
|
|
758
|
+
return;
|
|
759
|
+
default:
|
|
760
|
+
i[o].lastMessage = e.data, Ae(o, Xn)(n);
|
|
761
|
+
}
|
|
762
|
+
}
|
|
763
|
+
const eo = jt(() => {
|
|
764
|
+
N(window, A, le), N(document, "visibilitychange", ln), window.iframeParentListener = (e) => setTimeout(() => le({ data: e, sameOrigin: !0 }));
|
|
765
|
+
}), ue = {};
|
|
766
|
+
function to(e) {
|
|
767
|
+
if (ue[e] === !0) return !1;
|
|
768
|
+
const t = document.querySelectorAll(`iframe#${CSS.escape(e)}`);
|
|
769
|
+
if (t.length <= 1) return !0;
|
|
770
|
+
ue[e] = !0;
|
|
771
|
+
const n = Array.from(t).flatMap((o) => [
|
|
772
|
+
C,
|
|
773
|
+
o,
|
|
774
|
+
C
|
|
775
|
+
]);
|
|
776
|
+
return m(
|
|
777
|
+
e,
|
|
778
|
+
`<rb>Duplicate ID attributes detected</>
|
|
779
|
+
|
|
780
|
+
The <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.
|
|
781
|
+
|
|
782
|
+
Found <bb>${t.length}</> iframes with the <b>${e}</> ID:`,
|
|
783
|
+
...n,
|
|
784
|
+
C
|
|
785
|
+
), !1;
|
|
786
|
+
}
|
|
787
|
+
const no = `<rb>Deprecated Method Name</>
|
|
788
|
+
|
|
789
|
+
The <b>removeListeners()</> method has been renamed to <b>disconnect()</>. ${$e}`, oo = `<rb>Deprecated Method</>
|
|
790
|
+
|
|
791
|
+
Use of the <b>resize()</> method from the parent page is deprecated and will be removed in a future version of <i>iframe-resizer</>. As there 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.`;
|
|
792
|
+
function io(e) {
|
|
793
|
+
if (i[e]) {
|
|
794
|
+
const { iframe: t } = i[e], n = {
|
|
795
|
+
close: Fe.bind(null, t),
|
|
796
|
+
disconnect: _e.bind(null, t),
|
|
797
|
+
moveToAnchor(o) {
|
|
798
|
+
Nt(o, X, "moveToAnchor(anchor) anchor"), T("Move to anchor", `moveToAnchor:${o}`, e);
|
|
799
|
+
},
|
|
800
|
+
removeListeners() {
|
|
801
|
+
m(e, no), this.disconnect();
|
|
802
|
+
},
|
|
803
|
+
resize() {
|
|
804
|
+
m(e, oo), T("Window resize", Y, e);
|
|
805
|
+
},
|
|
806
|
+
sendMessage(o) {
|
|
807
|
+
o = JSON.stringify(o), T(A, `${A}:${o}`, e);
|
|
808
|
+
}
|
|
809
|
+
};
|
|
810
|
+
t.iframeResizer = n, t.iFrameResizer = n;
|
|
811
|
+
}
|
|
812
|
+
}
|
|
813
|
+
const so = "8", ro = "32", co = zt, ao = !0;
|
|
814
|
+
function lo(e) {
|
|
815
|
+
const {
|
|
816
|
+
autoResize: t,
|
|
817
|
+
bodyBackground: n,
|
|
818
|
+
bodyMargin: o,
|
|
819
|
+
bodyPadding: s,
|
|
820
|
+
heightCalculationMethod: c,
|
|
821
|
+
inPageLinks: r,
|
|
822
|
+
license: a,
|
|
823
|
+
log: f,
|
|
824
|
+
logExpand: h,
|
|
825
|
+
mouseEvents: g,
|
|
826
|
+
offsetHeight: $,
|
|
827
|
+
offsetWidth: d,
|
|
828
|
+
mode: E,
|
|
829
|
+
sizeHeight: Xe,
|
|
830
|
+
// sizeSelector,
|
|
831
|
+
sizeWidth: Ke,
|
|
832
|
+
tolerance: Qe,
|
|
833
|
+
widthCalculationMethod: et
|
|
834
|
+
} = i[e];
|
|
835
|
+
return [
|
|
836
|
+
e,
|
|
837
|
+
so,
|
|
838
|
+
Ke,
|
|
839
|
+
f,
|
|
840
|
+
ro,
|
|
841
|
+
ao,
|
|
842
|
+
t,
|
|
843
|
+
o,
|
|
844
|
+
c,
|
|
845
|
+
n,
|
|
846
|
+
s,
|
|
847
|
+
Qe,
|
|
848
|
+
r,
|
|
849
|
+
co,
|
|
850
|
+
et,
|
|
851
|
+
g,
|
|
852
|
+
$,
|
|
853
|
+
d,
|
|
854
|
+
Xe,
|
|
855
|
+
a,
|
|
856
|
+
p.version,
|
|
857
|
+
E,
|
|
858
|
+
"",
|
|
859
|
+
// sizeSelector,
|
|
860
|
+
h
|
|
861
|
+
].join(L);
|
|
862
|
+
}
|
|
863
|
+
const uo = "0";
|
|
864
|
+
function fo(e) {
|
|
865
|
+
const { bodyMargin: t } = i[e];
|
|
866
|
+
(typeof t === Et || t === uo) && (i[e].bodyMargin = `${t}px`);
|
|
867
|
+
}
|
|
868
|
+
const ho = (e) => {
|
|
869
|
+
try {
|
|
870
|
+
return new URL(e).origin;
|
|
871
|
+
} catch {
|
|
872
|
+
return null;
|
|
873
|
+
}
|
|
874
|
+
}, po = (e) => typeof e === ve && e.length > 0 && !(e.contains("allow-scripts") && e.contains("allow-same-origin"));
|
|
875
|
+
function go(e, t) {
|
|
876
|
+
const {
|
|
877
|
+
checkOrigin: n,
|
|
878
|
+
iframe: { src: o, sandbox: s },
|
|
879
|
+
initialisedFirstPage: c,
|
|
880
|
+
waitForLoad: r
|
|
881
|
+
} = t[e], a = ho(o);
|
|
882
|
+
b(e, "noResponse"), m(
|
|
883
|
+
e,
|
|
884
|
+
`<rb>No response from iframe</>
|
|
885
|
+
|
|
886
|
+
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.
|
|
887
|
+
${n && a ? `
|
|
888
|
+
The <b>checkOrigin</> option is currently enabled. If the iframe redirects away from <i>${a}</>, 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.
|
|
889
|
+
` : ""}${r && !c ? `
|
|
890
|
+
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</>.
|
|
891
|
+
` : ""}${po(s) ? `
|
|
892
|
+
The iframe has the <b>sandbox</> attribute, please ensure it contains both the <bb>allow-same-origin</> and <bb>allow-scripts</> values.
|
|
893
|
+
` : ""}
|
|
894
|
+
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.
|
|
895
|
+
`
|
|
896
|
+
);
|
|
897
|
+
}
|
|
898
|
+
function mo(e, t) {
|
|
899
|
+
function n() {
|
|
900
|
+
if (t[e] === void 0) return;
|
|
901
|
+
const { initialised: c, loadErrorShown: r } = t[e];
|
|
902
|
+
if (t[e].msgTimeout = void 0, c) {
|
|
903
|
+
t[e].initialisedFirstPage = !0;
|
|
904
|
+
return;
|
|
905
|
+
}
|
|
906
|
+
r || (t[e].loadErrorShown = !0, go(e, t));
|
|
907
|
+
}
|
|
908
|
+
const { msgTimeout: o, warningTimeout: s } = t[e];
|
|
909
|
+
s && (o && clearTimeout(o), t[e].msgTimeout = setTimeout(n, s));
|
|
910
|
+
}
|
|
911
|
+
const yo = 1, bo = (e) => e.loading === ct, vo = (e) => e === j;
|
|
912
|
+
function wo(e) {
|
|
913
|
+
i[e]?.heightCalculationMethod in kt && Be({
|
|
914
|
+
id: e,
|
|
915
|
+
iframe: i[e].iframe,
|
|
916
|
+
height: ee,
|
|
917
|
+
width: ee,
|
|
918
|
+
type: j
|
|
919
|
+
});
|
|
920
|
+
}
|
|
921
|
+
function zo(e, t) {
|
|
922
|
+
N(e, G, () => setTimeout(t, yo));
|
|
923
|
+
}
|
|
924
|
+
const Eo = (e) => {
|
|
925
|
+
const { src: t, srcdoc: n } = e;
|
|
926
|
+
return !n && (t == null || t === "" || t === "about:blank");
|
|
927
|
+
};
|
|
928
|
+
function Oo(e, t) {
|
|
929
|
+
const { iframe: n, waitForLoad: o } = i[e];
|
|
930
|
+
if (o !== !0) {
|
|
931
|
+
if (Eo(n)) {
|
|
932
|
+
setTimeout(() => {
|
|
933
|
+
b(e, "noContent"), y(e, "No content detected in the iframe, delaying initialisation");
|
|
934
|
+
});
|
|
935
|
+
return;
|
|
936
|
+
}
|
|
937
|
+
setTimeout(t);
|
|
938
|
+
}
|
|
939
|
+
}
|
|
940
|
+
function To(e, t) {
|
|
941
|
+
const n = (s) => () => {
|
|
942
|
+
if (!i[e]) return;
|
|
943
|
+
const { firstRun: c, iframe: r } = i[e];
|
|
944
|
+
T(s, t, e), vo(s) && bo(r) || mo(e, i), c || wo(e);
|
|
945
|
+
}, { iframe: o } = i[e];
|
|
946
|
+
i[e].initChild = n(de), zo(o, n(me)), Oo(e, n(j));
|
|
947
|
+
}
|
|
948
|
+
function Io(e, t) {
|
|
949
|
+
return t ? (("sizeWidth" in t || "sizeHeight" in t || ge in t) && m(
|
|
950
|
+
e,
|
|
951
|
+
`<rb>Deprecated Option</>
|
|
952
|
+
|
|
953
|
+
The <b>sizeWidth</>, <b>sizeHeight</> and <b>autoResize</> options have been replaced with new <b>direction</> option which expects values of <bb>${D}</>, <bb>${Oe}</>, <bb>${Ee}</> or <bb>${ze}</>.
|
|
954
|
+
`
|
|
955
|
+
), t) : {};
|
|
956
|
+
}
|
|
957
|
+
function ko(e) {
|
|
958
|
+
i[e].warningTimeout || y(e, "warningTimeout:%c disabled", l);
|
|
959
|
+
}
|
|
960
|
+
function $o(e, { offset: t, offsetSize: n }) {
|
|
961
|
+
const o = n || t;
|
|
962
|
+
o && (i[e].direction === D ? (i[e].offsetHeight = o, u(e, `Offset height: %c${o}`, l)) : (i[e].offsetWidth = o, u(e, `Offset width: %c${o}`, l)));
|
|
963
|
+
}
|
|
964
|
+
function Mo(e) {
|
|
965
|
+
const { direction: t } = i[e];
|
|
966
|
+
switch (t) {
|
|
967
|
+
case D:
|
|
968
|
+
break;
|
|
969
|
+
case Oe:
|
|
970
|
+
i[e].sizeHeight = !1;
|
|
971
|
+
// eslint-disable-next-line no-fallthrough
|
|
972
|
+
case Ee:
|
|
973
|
+
i[e].sizeWidth = !0;
|
|
974
|
+
break;
|
|
975
|
+
case ze:
|
|
976
|
+
i[e].sizeWidth = !1, i[e].sizeHeight = !1, i[e].autoResize = !1;
|
|
977
|
+
break;
|
|
978
|
+
default:
|
|
979
|
+
throw new TypeError(`Direction value of "${t}" is not valid`);
|
|
980
|
+
}
|
|
981
|
+
u(e, `direction: %c${t}`, l);
|
|
982
|
+
}
|
|
983
|
+
const fe = (e) => e === "" || e.match(/^(about:blank|javascript:|file:\/\/)/) !== null ? "*" : e;
|
|
984
|
+
function So(e) {
|
|
985
|
+
const { checkOrigin: t, remoteHost: n } = i[e];
|
|
986
|
+
Array.isArray(t) && t.length === 0 && z(
|
|
987
|
+
e,
|
|
988
|
+
"checkOrigin is an empty array — no messages will be sent to the iframe"
|
|
989
|
+
), i[e].targetOrigin = Array.isArray(t) ? t.map(fe) : [t === !1 ? "*" : fe(n)];
|
|
990
|
+
}
|
|
991
|
+
function jo(e) {
|
|
992
|
+
const { id: t } = e;
|
|
993
|
+
i[t].postMessageTarget === null && (i[t].postMessageTarget = e.contentWindow);
|
|
994
|
+
}
|
|
995
|
+
function H(e, t, n) {
|
|
996
|
+
P(i[e], t) && (m(
|
|
997
|
+
e,
|
|
998
|
+
`<rb>Deprecated option</>
|
|
999
|
+
|
|
1000
|
+
The <b>${t}</> option has been renamed to <b>${n}</>. ${$e}`
|
|
1001
|
+
), i[e][n] = i[e][t], delete i[e][t]);
|
|
1002
|
+
}
|
|
1003
|
+
function Ro(e) {
|
|
1004
|
+
H(e, bt, vt), H(e, "onClose", "onBeforeClose"), H(e, "onClosed", "onAfterClose");
|
|
1005
|
+
}
|
|
1006
|
+
const Lo = (e) => P(e, "onMouseEnter") || P(e, "onMouseLeave");
|
|
1007
|
+
function Ao(e, t) {
|
|
1008
|
+
const { id: n } = e;
|
|
1009
|
+
i[n] = {
|
|
1010
|
+
...i[n],
|
|
1011
|
+
iframe: e,
|
|
1012
|
+
remoteHost: e?.src.split("/").slice(0, 3).join("/"),
|
|
1013
|
+
...B,
|
|
1014
|
+
...Io(n, t),
|
|
1015
|
+
mouseEvents: Lo(t),
|
|
1016
|
+
mode: qn(t),
|
|
1017
|
+
syncTitle: xn(n)
|
|
1018
|
+
}, Ro(n), Mo(n), $o(n, t), ko(n), jo(e), So(n);
|
|
1019
|
+
}
|
|
1020
|
+
const Po = "yes", he = "no";
|
|
1021
|
+
function No(e) {
|
|
1022
|
+
const { id: t } = e;
|
|
1023
|
+
switch (u(
|
|
1024
|
+
t,
|
|
1025
|
+
`Iframe scrolling ${i[t]?.scrolling ? "enabled" : "disabled"} for ${t}`
|
|
1026
|
+
), e.style.overflow = i[t]?.scrolling === !1 ? wt : q, i[t]?.scrolling) {
|
|
1027
|
+
case Tt:
|
|
1028
|
+
break;
|
|
1029
|
+
case !0:
|
|
1030
|
+
e.scrolling = Po;
|
|
1031
|
+
break;
|
|
1032
|
+
case !1:
|
|
1033
|
+
e.scrolling = he;
|
|
1034
|
+
break;
|
|
1035
|
+
default:
|
|
1036
|
+
e.scrolling = i[t]?.scrolling || he;
|
|
1037
|
+
}
|
|
1038
|
+
}
|
|
1039
|
+
function Co(e, t, n) {
|
|
1040
|
+
Ao(t, n), u(e, `src: %c${t.srcdoc || t.src}`, l), Zn(e), No(t), fo(e), To(e, lo(e)), io(e), u(e, "Setup complete");
|
|
1041
|
+
}
|
|
1042
|
+
function xo(e, t) {
|
|
1043
|
+
const { id: n } = e;
|
|
1044
|
+
b(n, "setup"), to(n) && Co(n, e, t), Jt(n);
|
|
1045
|
+
}
|
|
1046
|
+
function _o(e, t) {
|
|
1047
|
+
t.log === Te ? t.log = !1 : t.log === Ie ? t.log = S : t.log === ke && (t.log = M);
|
|
1048
|
+
const n = P(t, "log"), o = K(t.log), s = n ? o ? !0 : t.log : B.log;
|
|
1049
|
+
P(t, "logExpand") || (t.logExpand = n && o ? t.log === M : B.logExpand), Jn(t), Ut({
|
|
1050
|
+
enabled: s,
|
|
1051
|
+
expand: t.logExpand,
|
|
1052
|
+
iframeId: e
|
|
1053
|
+
}), o && !(t.log in $t) && qt(
|
|
1054
|
+
e,
|
|
1055
|
+
`Invalid value for options.log: Accepted values are "${M}" and "${S}"`
|
|
1056
|
+
), t.log = s;
|
|
1057
|
+
}
|
|
1058
|
+
function Bo(e) {
|
|
1059
|
+
if (!Me(e)) throw new TypeError("Options is not an object");
|
|
1060
|
+
return eo(), sn(e), (t) => {
|
|
1061
|
+
const n = on(t, e);
|
|
1062
|
+
return pe in t ? (b(n, "alreadySetup"), z(n, `Ignored iframe (${n}), already setup.`)) : (_o(n, e), Ae(n, xo)(t, e)), t?.iframeResizer;
|
|
1063
|
+
};
|
|
1064
|
+
}
|
|
1065
|
+
export {
|
|
1066
|
+
Ie as LOG_COLLAPSED,
|
|
1067
|
+
Te as LOG_DISABLED,
|
|
1068
|
+
ke as LOG_EXPANDED,
|
|
1069
|
+
Bo as default
|
|
1070
|
+
};
|
|
1071
|
+
//# sourceMappingURL=index.esm.js.map
|