@iframe-resizer/core 6.0.0-beta.4 → 6.0.0-beta.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/index.cjs.js +8 -8
- package/index.cjs.js.map +1 -1
- package/index.esm.js +133 -138
- package/index.esm.js.map +1 -1
- package/index.umd.js +10 -10
- package/index.umd.js.map +1 -1
- package/package.json +2 -2
package/index.umd.js
CHANGED
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(p,i){typeof exports=="object"&&typeof module<"u"?i(exports,require("@iframe-resizer/common"),require("auto-console-group")):typeof define=="function"&&define.amd?define(["exports","@iframe-resizer/common","auto-console-group"],i):(p=typeof globalThis<"u"?globalThis:p||self,i(p.connectResizer={},p.common,p.acg))})(this,(function(p,i,a){"use strict";const r={},v=i.esModuleInterop(a);let y=!0;const se=v({expand:!1,label:i.PARENT}),oe=e=>window.top===window.self?`parent(${e})`:`nested parent(${e})`,ae=e=>r[e]?r[e].log:y;function ce({enabled:e,expand:t,iframeId:n}){const s=v({expand:t,label:oe(n)});y=e,r[n]||(r[n]={console:s})}const L=e=>(t,...n)=>r[t]?r[t].console[e](...n):se[e](...n),k=e=>(t,...n)=>ae(t)===!0?L(e)(t,...n):null,l=k("log"),O=l,fe=k("debug"),w=L("warn"),le=L("error"),T=L("event"),ue=L("purge"),de=L("endAutoGroup"),D=L("errorBoundary");function ge(e,t){queueMicrotask(()=>console.info(`%ciframe-resizer ${e}`,y||t<1?i.BOLD:a.NORMAL))}const he=e=>(...t)=>[`${i.LABEL}(${e})`,...t].join(" "),Ee=i.createFormatAdvise(i.id),b=(e,...t)=>r[e]?r[e].console.warn(...t.map(Ee)):queueMicrotask(()=>{const n=i.createFormatAdvise(he(e));console?.warn(...t.map(n))}),N=i.deprecate(b);N("Function"),N("Method"),N("Option");const G=Object.freeze({autoResize:!0,bodyBackground:null,bodyMargin:null,bodyPadding:null,checkOrigin:!0,direction:i.VERTICAL,firstRun:!0,inPageLinks:!1,heightCalculationMethod:i.AUTO,id:"iframeResizer",log:!1,logExpand:!1,license:void 0,mouseEvents:!0,offsetHeight:null,offsetWidth:null,postMessageTarget:null,sameDomain:!1,scrolling:!1,sizeHeight:!0,sizeWidth:!1,tolerance:0,waitForLoad:!1,warningTimeout:5e3,widthCalculationMethod:i.AUTO,onBeforeClose:()=>!0,onAfterClose(){},onMessage:null,onMouseEnter(){},onMouseLeave(){},onReady(){},onResized(){},onScroll:()=>!0});let _=0;function Ie(e){const t=e?.id||G.id+_++;return document.getElementById(t)===null?t:`${t}${_++}`}function pe(e,t){let{id:n}=e;if(n&&!i.isString(n))throw new TypeError("Invalid id for iframe. Expected String");return(!n||n==="")&&(n=Ie(t),e.id=n,T(n,"assignId"),l(n,`Added missing iframe ID: ${n} (${e.src})`)),n}function Oe(e){const{search:t}=window.location;if(t.includes("ifrlog"))switch(new URLSearchParams(t).get("ifrlog")){case String(i.LOG_DISABLED):{e.log=!1;break}case i.EXPAND:case String(i.LOG_EXPANDED):{e.log=i.EXPAND;break}case i.COLLAPSE:case String(i.LOG_COLLAPSED):{e.log=i.COLLAPSE;break}default:e.log=i.COLLAPSE}}const be=e=>e.split(i.SEPARATOR).filter((t,n)=>n!==19).join(i.SEPARATOR);function Te(e,t,n){function s(d){const g=e in i.INIT_EVENTS?be(t):t;O(n,d,a.HIGHLIGHT,a.FOREGROUND,a.HIGHLIGHT),O(n,`Message data: %c${g}`,a.HIGHLIGHT)}const{iframe:o,postMessageTarget:u,sameOrigin:c,targetOrigin:f}=r[n];if(c)try{o.contentWindow.iframeChildListener(i.MESSAGE_ID+t),s(`Sending message to iframe %c${n}%c via same origin%c`);return}catch{e in i.INIT_EVENTS?(r[n].sameOrigin=!1,l(n,"New iframe does not support same origin")):w(n,"Same origin messaging failed, falling back to postMessage")}s(`Sending message to iframe: %c${n}%c targetOrigin: %c${f.join(", ")}`);for(const d of f)u.postMessage(i.MESSAGE_ID+t,d)}function A(e,t,n){if(T(n,e),!r[n]?.postMessageTarget){w(n,"Iframe not found");return}Te(e,t,n)}const we=(e,t)=>Object.values(r).filter(({autoResize:n,firstRun:s})=>n&&!s).forEach(({iframe:n})=>A(e,t,n.id));function Le(){document.hidden!==!0&&we("tabVisible",i.RESIZE)}function He(e){if(e.boxSizing!=="border-box")return 0;const t=e.paddingTop?parseInt(e.paddingTop,10):0,n=e.paddingBottom?parseInt(e.paddingBottom,10):0;return t+n}function Se(e){if(e.boxSizing!=="border-box")return 0;const t=e.borderTopWidth?parseInt(e.borderTopWidth,10):0,n=e.borderBottomWidth?parseInt(e.borderBottomWidth,10):0;return t+n}function Ae(e){const t=e.slice(i.MESSAGE_ID_LENGTH).split(":"),n=t[1]?Number(t[1]):0,s=r[t[0]]?.iframe,o=s?getComputedStyle(s):null,u=o?He(o)+Se(o):0,c={iframe:s,id:t[0],height:n+u,width:Number(t[2]),type:t[3],msg:t[4],message:t[4]};return t[5]&&(c.mode=t[5]),c}const Re={true:1,false:1,undefined:1};function Ge(e){const{id:t,msg:n,iframe:s}=e,o=i.isIframe(s);return o||(l(t,`Received: %c${n}`,a.HIGHLIGHT),w(t,"The target iframe was not found.")),o}function Me(e,t){const{id:n}=e,{data:s,origin:o}=t;if("sameOrigin"in t&&t.sameOrigin)return!0;const c=r[n]?.checkOrigin;function f(){function d(){l(n,`Checking connection is from allowed list of origins: %c${c}`,a.HIGHLIGHT);for(const h of c)if(h===o)return!0;return!1}function g(){const h=r[n]?.remoteHost;return l(n,`Checking connection is from: %c${h}`,a.HIGHLIGHT),o===h}return c.constructor===Array?d():g()}if(c&&`${o}`!="null"&&!f())throw new Error(`Unexpected message received from: ${o} for ${n}. Message was: ${s}. This error can be disabled by setting the checkOrigin: false option or by providing an array of trusted domains.`);return!0}const ye=e=>i.MESSAGE_ID===`${e}`.slice(0,i.MESSAGE_ID_LENGTH)&&e.slice(i.MESSAGE_ID_LENGTH).split(":")[0]in r;function Ne(e){const{id:t,type:n}=e,s=n in Re;return s&&l(t,"Ignoring init message from meta parent page"),s}function Pe(e){try{r[e].sameOrigin=!!r[e]?.iframe?.contentWindow?.iframeChildListener}catch{r[e].sameOrigin=!1}l(e,`sameOrigin: %c${r[e].sameOrigin}`,a.HIGHLIGHT)}function $e(e,t){if(t!==i.VERSION){if(t===void 0){b(e,`<rb>Legacy version detected in iframe</>
|
|
2
2
|
|
|
3
3
|
Detected legacy version of child page script. It is recommended to update the page in the iframe to use <b>@iframe-resizer/child</>.
|
|
4
4
|
|
|
5
5
|
See <u>https://iframe-resizer.com/setup/#child-page-setup</> for more details.
|
|
6
|
-
`);return}
|
|
6
|
+
`);return}l(e,`Version mismatch (Child: %c${t}%c !== Parent: %c${i.VERSION})`,a.HIGHLIGHT,a.FOREGROUND,a.HIGHLIGHT)}}function H(e,t,n){if(!r[e])return null;const s=r[e][t];if(typeof s!==i.FUNCTION)throw new TypeError(`${t} on iframe[${e}] is not a function`);if(t!=="onBeforeClose"&&t!=="onScroll")return i.isolateUserCode(s,n);try{return s(n)}catch(o){return console.error(o),w(e,`Error in ${t} callback`),null}}function ve(e,t){const{id:n,iframe:s}=e;l(n,`onMessage passed: {iframe: %c${n}%c, message: %c${t}%c}`,a.HIGHLIGHT,a.FOREGROUND,a.HIGHLIGHT,a.FOREGROUND),H(n,"onMessage",{iframe:s,message:JSON.parse(t)})}function M(e,t){const{lastMessage:n}=r[e];return n.slice(n.indexOf(i.SEPARATOR)+i.MESSAGE_HEADER_LENGTH+t)}function C(e,t){const{id:n,iframe:s,height:o,type:u,width:c}=t;let f={x:0,y:0};if(c===0&&o===0){const d=M(n,9).split(i.SEPARATOR);f={x:d[1],y:d[0]}}else f={x:c,y:o};H(n,e,{iframe:s,screenX:Number(f.x),screenY:Number(f.y),type:u})}const E={position:null,version:i.VERSION};function z(){E.position=null}const ke=()=>E.position;function De(e){E.position=e}function F(e){return E.position===null&&(E.position={x:window.scrollX,y:window.scrollY}),l(e,`Get page position: %c${E.position.x}%c, %c${E.position.y}`,a.HIGHLIGHT,a.FOREGROUND,a.HIGHLIGHT),E.position}function B(e){E.position!==null&&(window.scrollTo(E.position.x,E.position.y),O(e,`Set page position: %c${E.position.x}%c, %c${E.position.y}`,a.HIGHLIGHT,a.FOREGROUND,a.HIGHLIGHT),z())}function x(e,t){const{id:n}=t,s=`${t[e]}px`;r[n].iframe.style[e]=s,O(n,`Set ${e}: %c${s}`,a.HIGHLIGHT)}function W(e){const{id:t}=e,{sizeHeight:n,sizeWidth:s}=r[t];n&&x(i.HEIGHT,e),s&&x(i.WIDTH,e)}function U(e){const{id:t}=e;W(e),B(t),H(t,"onResized",e)}function V(e){const{id:t}=e;l(t,"Disconnected from iframe"),delete r[t],delete e.iframeResizer}function j(e){const{id:t}=e;if(H(t,"onBeforeClose",t)===!1){l(t,"Close iframe cancelled by onBeforeClose");return}l(t,`Removing iframe: %c${t}`,a.HIGHLIGHT);try{e.parentNode&&e.remove()}catch(n){w(t,n)}H(t,"onAfterClose",t),V(e)}function X(e){const{id:t,type:n}=e;l(t,`Size reset requested by ${n===i.INIT?"parent page":"child page"}`),F(t),W(e),A(i.RESET,i.RESET,t)}const q=(e,t)=>{const n={};return(s,o)=>{const{iframe:u}=r[o];function c(d,g){n[g]||(d(),n[g]=requestAnimationFrame(()=>{n[g]=null}))}function f(){A(`${s} (${e})`,`${e}:${t(u)}`,o)}c(f,o)}},Z=e=>t=>{e in r[t]&&(r[t][e](),delete r[t][e])},Y=((e,t)=>n=>{let s=!1;const o=I=>()=>{r[n]?(!s||s===I)&&(e(I,n),s=I,requestAnimationFrame(()=>{s=!1})):h()},u=o(i.SCROLL),c=o("resize window"),f=new ResizeObserver(o("pageObserver")),d=new ResizeObserver(o("iframeObserver"));function g(I,S){l(n,`${I}listeners for send${t}`),S(window,i.SCROLL,u),S(window,i.RESIZE,c)}function h(){T(n,`stop${t}`),g("Remove ",i.removeEventListener),f.disconnect(),d.disconnect(),r[n]&&i.removeEventListener(r[n].iframe,i.LOAD,h)}function R(){g("Add ",i.addEventListener),f.observe(document.body),d.observe(r[n].iframe)}r[n]&&(r[n][`stop${t}`]=h,i.addEventListener(r[n].iframe,i.LOAD,h),R())});function _e(e){const t=document.body.getBoundingClientRect(),n=e.getBoundingClientRect(),{scrollY:s,scrollX:o,innerHeight:u,innerWidth:c}=window,{clientHeight:f,clientWidth:d}=document.documentElement;return JSON.stringify({iframeHeight:n.height,iframeWidth:n.width,clientHeight:Math.max(f,u||0),clientWidth:Math.max(d,c||0),offsetTop:Math.trunc(n.top-t.top),offsetLeft:Math.trunc(n.left-t.left),scrollTop:s,scrollLeft:o,documentHeight:f,documentWidth:d,windowHeight:u,windowWidth:c})}const Ce=q(i.PAGE_INFO,_e),ze=Y(Ce,"PageInfo"),Fe=Z("stopPageInfo");function Be(e){const{scrollWidth:t,scrollHeight:n}=document.documentElement,s=typeof window<"u"&&window.visualViewport?window.visualViewport:{},{width:o=0,height:u=0,offsetLeft:c=0,offsetTop:f=0,pageLeft:d=0,pageTop:g=0,scale:h=1}=s;return JSON.stringify({iframe:e.getBoundingClientRect(),document:{scrollWidth:t,scrollHeight:n},viewport:{width:o,height:u,offsetLeft:c,offsetTop:f,pageLeft:d,pageTop:g,scale:h}})}const xe=q(i.PARENT_INFO,Be),We=Y(xe,"ParentInfo"),Ue=Z("stopParentInfo");function J(e){const t=e.getBoundingClientRect(),n=F(e.id);return{x:Number(t.left)+Number(n.x),y:Number(t.top)+Number(n.y)}}function K(e){const{x:t,y:n}=ke(),s=r[e]?.iframe;if(H(e,"onScroll",{iframe:s,top:n,left:t,x:t,y:n})===!1){z();return}B(e)}function Ve(e){const{id:t,height:n,width:s}=e,o=window.parentIframe||window.parentIFrame||window;O(t,`scrollBy: x: %c${s}%c y: %c${n}`,a.HIGHLIGHT,a.FOREGROUND,a.HIGHLIGHT),o.scrollBy(s,n)}const Q=e=>t=>{const{id:n,iframe:s,height:o,width:u}=t;function c(I){De(I),K(n)}function f(I,S){I[`scrollTo${e?"Offset":""}`](S.x,S.y)}const d=I=>({x:u+I.x,y:o+I.y}),g=e?J(s):{x:0,y:0},h=d(g),R=window.parentIframe||window.parentIFrame;O(n,`Reposition requested (offset x:%c${g.x}%c y:%c${g.y})`,a.HIGHLIGHT,a.FOREGROUND,a.HIGHLIGHT),R?f(R,h):c(h)},je=Q(!1),Xe=Q(!0);function qe(e,t,n){const{x:s,y:o}=J(n);O(e,`Moving to in page link: %c#${t}`,a.HIGHLIGHT),E.position={x:s,y:o},K(e),window.location.hash=t}function Ze(e,t){const n=window.parentIframe||window.parentIFrame;if(!n){l(e,`In page link #${t} not found`);return}n.moveToAnchor(t)}function Ye(e,t){const n=t.split("#")[1]||"",s=decodeURIComponent(n),o=document.getElementById(s)||document.getElementsByName(s)[0];if(o){qe(e,n,o);return}if(window.top===window.self){l(e,`In page link #${n} not found`);return}Ze(e,n)}function Je(e){const t=r[e]?.iframe?.title;return t===""||t===void 0}function Ke(e,t){r[e]?.syncTitle&&(r[e].iframe.title=t,O(e,`Set iframe title attribute: %c${t}`,a.HIGHLIGHT))}let P=!1,m=!1;function ee(e,t=-3){if(P)return;const n=Math.max(r[e].mode,t);if(n>r[e].mode&&(r[e].mode=n),n<0)throw ue(e),r[e].vAdvised||b(e||"Parent",`${i.getModeData(n+2)}${i.getModeData(2)}`),r[e].vAdvised=!0,i.getModeData(n+2).replace(/<\/?[a-z][^>]*>|<\/>/gi,"");switch(n>5&&m||ge(`v${i.VERSION} (${i.getModeLabel(n)})`,n),n){case 1:case 2:case 3:b("Parent",i.getModeData(6));break;case 4:b("Parent",i.getModeData(7));break;case 5:b("Parent",i.getModeData(8));break;default:n<1&&b("Parent",i.getModeData(3))}P=!0}function Qe(e){if(P)return;const{mode:t}=r[e];t>5&&ee(e,t)}function me(e){e?.log===-1&&(e.log=!1,m=!0)}function et(e,t){r[e]&&(l(e,`First run for ${e}`),ee(e,t===void 0?void 0:Number(t)),r[e].firstRun=!1)}function tt(e){const{height:t,id:n,iframe:s,mode:o,message:u,type:c,width:f}=e,{lastMessage:d}=r[n];switch(r[n]?.firstRun&&et(n,o),l(n,`Received: %c${d}`,a.HIGHLIGHT),c){case i.AUTO_RESIZE:r[n].autoResize=JSON.parse(M(n,9));break;case i.BEFORE_UNLOAD:O(n,"Ready state reset"),r[n].initialised=!1;break;case i.CLOSE:j(s);break;case i.IN_PAGE_LINK:Ye(n,M(n,9));break;case i.INIT:U(e),Pe(n),$e(n,u),r[n].initialised=!0,H(n,"onReady",s);break;case i.MESSAGE:ve(e,M(n,6));break;case i.MOUSE_ENTER:C("onMouseEnter",e);break;case i.MOUSE_LEAVE:C("onMouseLeave",e);break;case i.PAGE_INFO:ze(n);break;case i.PARENT_INFO:We(n);break;case i.PAGE_INFO_STOP:Fe(n);break;case i.PARENT_INFO_STOP:Ue(n);break;case i.RESET:X(e);break;case i.SCROLL_BY:Ve(e);break;case i.SCROLL_TO:je(e);break;case i.SCROLL_TO_OFFSET:Xe(e);break;case i.TITLE:Ke(n,u);break;default:if(f===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(f===0||t===0){l(n,"Ignoring message with 0 height or width");return}if(document.hidden){l(n,"Page hidden - ignored resize request");return}U(e)}}const nt=e=>({initChild:t,postMessageTarget:n})=>{e===n&&t()},it=e=>Object.values(r).forEach(nt(e));function te(e){const t=e.data;if(t===i.CHILD_READY_MESSAGE){it(e.source);return}if(!ye(t)){if(typeof t!==i.STRING)return;T(i.PARENT,"ignoredMessage"),fe(i.PARENT,t);return}const n=Ae(t),{id:s,type:o}=n;switch(T(s,o),!0){case!r[s]:throw new Error(`${o} No settings for ${s}. Message was: ${t}`);case!Ge(n):case Ne(n):case!Me(n,e):return;default:r[s].lastMessage=e.data,D(s,tt)(n)}}const rt=i.once(()=>{i.addEventListener(window,i.MESSAGE,te),i.addEventListener(document,"visibilitychange",Le),window.iframeParentListener=e=>setTimeout(()=>te({data:e,sameOrigin:!0}))}),ne={};function st(e){if(ne[e]===!0)return!1;const t=document.querySelectorAll(`iframe#${CSS.escape(e)}`);if(t.length<=1)return!0;ne[e]=!0;const n=Array.from(t).flatMap(s=>[i.NEW_LINE,s,i.NEW_LINE]);return b(e,`<rb>Duplicate ID attributes detected</>
|
|
7
7
|
|
|
8
8
|
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.
|
|
9
9
|
|
|
10
|
-
Found <bb>${
|
|
10
|
+
Found <bb>${t.length}</> iframes with the <b>${e}</> ID:`,...n,i.NEW_LINE),!1}function ot(e){if(r[e]){const{iframe:t}=r[e];t.iframeResizer={close:j.bind(null,t),disconnect:V.bind(null,t),moveToAnchor(n){i.typeAssert(n,i.STRING,"moveToAnchor(anchor) anchor"),A("Move to anchor",`moveToAnchor:${n}`,e)},sendMessage(n){n=JSON.stringify(n),A(i.MESSAGE,`${i.MESSAGE}:${n}`,e)}}}}const at="8",ct="32",ft=i.CHILD,lt=!0;function ut(e){const{autoResize:t,bodyBackground:n,bodyMargin:s,bodyPadding:o,heightCalculationMethod:u,inPageLinks:c,license:f,log:d,logExpand:g,mouseEvents:h,offsetHeight:R,offsetWidth:I,mode:S,sizeHeight:xt,sizeWidth:Wt,tolerance:Ut,widthCalculationMethod:Vt}=r[e];return[e,at,Wt,d,ct,lt,t,s,u,n,o,Ut,c,ft,Vt,h,R,I,xt,f,E.version,S,"",g].join(i.SEPARATOR)}const dt="0";function gt(e){const{bodyMargin:t}=r[e];(typeof t===i.NUMBER||t===dt)&&(r[e].bodyMargin=`${t}px`)}const ht=e=>{try{return new URL(e).origin}catch{return null}},Et=e=>typeof e===i.OBJECT&&e.length>0&&!(e.contains("allow-scripts")&&e.contains("allow-same-origin"));function It(e,t){const{checkOrigin:n,iframe:{src:s,sandbox:o},initialisedFirstPage:u,waitForLoad:c}=t[e],f=ht(s);T(e,"noResponse"),b(e,`<rb>No response from iframe</>
|
|
11
11
|
|
|
12
|
-
The iframe (<i>${e}</>) has not responded within ${
|
|
13
|
-
${
|
|
12
|
+
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.
|
|
13
|
+
${n&&f?`
|
|
14
14
|
The <b>checkOrigin</> option is currently enabled. If the iframe redirects away from <i>${f}</>, 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.
|
|
15
|
-
`:""}${c&&!
|
|
15
|
+
`:""}${c&&!u?`
|
|
16
16
|
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</>.
|
|
17
|
-
`:""}${
|
|
17
|
+
`:""}${Et(o)?`
|
|
18
18
|
The iframe has the <b>sandbox</> attribute, please ensure it contains both the <bb>allow-same-origin</> and <bb>allow-scripts</> values.
|
|
19
19
|
`:""}
|
|
20
20
|
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.
|
|
21
|
-
`)}function
|
|
21
|
+
`)}function pt(e,t){function n(){if(t[e]===void 0)return;const{initialised:u,loadErrorShown:c}=t[e];if(t[e].msgTimeout=void 0,u){t[e].initialisedFirstPage=!0;return}c||(t[e].loadErrorShown=!0,It(e,t))}const{msgTimeout:s,warningTimeout:o}=t[e];o&&(s&&clearTimeout(s),t[e].msgTimeout=setTimeout(n,o))}const Ot=1,bt=e=>e.loading===i.LAZY,Tt=e=>e===i.INIT;function wt(e){r[e]?.heightCalculationMethod in i.RESET_REQUIRED_METHODS&&X({id:e,iframe:r[e].iframe,height:i.MIN_SIZE,width:i.MIN_SIZE,type:i.INIT})}function Lt(e,t){const n=()=>setTimeout(t,Ot);i.addEventListener(e,i.LOAD,n)}const Ht=e=>{const{src:t,srcdoc:n}=e;return!n&&(t==null||t===""||t==="about:blank")};function St(e,t){const{iframe:n,waitForLoad:s}=r[e];if(s!==!0){if(Ht(n)){setTimeout(()=>{T(e,"noContent"),O(e,"No content detected in the iframe, delaying initialisation")});return}setTimeout(t)}}function At(e,t){const n=o=>()=>{if(!r[e])return;const{firstRun:u,iframe:c}=r[e];A(o,t,e),Tt(o)&&bt(c)||pt(e,r),u||wt(e)},{iframe:s}=r[e];r[e].initChild=n(i.INIT_FROM_IFRAME),Lt(s,n(i.ONLOAD)),St(e,n(i.INIT))}function Rt(e,t){return t?(("sizeWidth"in t||"sizeHeight"in t||i.AUTO_RESIZE in t)&&b(e,`<rb>Deprecated Option</>
|
|
22
22
|
|
|
23
23
|
The <b>sizeWidth</>, <b>sizeHeight</> and <b>autoResize</> options have been replaced with new <b>direction</> option which expects values of <bb>${i.VERTICAL}</>, <bb>${i.HORIZONTAL}</>, <bb>${i.BOTH}</> or <bb>${i.NONE}</>.
|
|
24
|
-
`),
|
|
24
|
+
`),t):{}}function Gt(e){r[e].warningTimeout||O(e,"warningTimeout:%c disabled",a.HIGHLIGHT)}function Mt(e,{offset:t,offsetSize:n}){const s=n||t;s&&(r[e].direction===i.VERTICAL?(r[e].offsetHeight=s,l(e,`Offset height: %c${s}`,a.HIGHLIGHT)):(r[e].offsetWidth=s,l(e,`Offset width: %c${s}`,a.HIGHLIGHT)))}function yt(e){const{direction:t}=r[e];switch(t){case i.VERTICAL:break;case i.HORIZONTAL:r[e].sizeHeight=!1;case i.BOTH:r[e].sizeWidth=!0;break;case i.NONE:r[e].sizeWidth=!1,r[e].sizeHeight=!1,r[e].autoResize=!1;break;default:throw new TypeError(`Direction value of "${t}" is not valid`)}l(e,`direction: %c${t}`,a.HIGHLIGHT)}const ie=e=>e===""||e.match(/^(about:blank|javascript:|file:\/\/)/)!==null?"*":e;function Nt(e){const{checkOrigin:t,remoteHost:n}=r[e];Array.isArray(t)&&t.length===0&&w(e,"checkOrigin is an empty array — no messages will be sent to the iframe"),r[e].targetOrigin=Array.isArray(t)?t.map(ie):[t===!1?"*":ie(n)]}function Pt(e){const{id:t}=e;r[t].postMessageTarget===null&&(r[t].postMessageTarget=e.contentWindow)}function $(e,t,n){i.hasOwn(r[e],t)&&(b(e,`<rb>Deprecated option</>
|
|
25
25
|
|
|
26
|
-
The <b>${
|
|
26
|
+
The <b>${t}</> option has been renamed to <b>${n}</>. ${i.REMOVED_NEXT_VERSION}`),r[e][n]=r[e][t],delete r[e][t])}function $t(e){$(e,i.OFFSET,i.OFFSET_SIZE),$(e,"onClose","onBeforeClose"),$(e,"onClosed","onAfterClose")}const vt=e=>i.hasOwn(e,"onMouseEnter")||i.hasOwn(e,"onMouseLeave");function kt(e,t){const{id:n}=e;r[n]={...r[n],iframe:e,remoteHost:e?.src.split("/").slice(0,3).join("/"),...G,...Rt(n,t),mouseEvents:vt(t),mode:i.setMode(t),syncTitle:Je(n)},$t(n),yt(n),Mt(n,t),Gt(n),Pt(e),Nt(n)}const Dt="yes",re="no";function _t(e){const{id:t}=e;switch(l(t,`Iframe scrolling ${r[t]?.scrolling?"enabled":"disabled"} for ${t}`),e.style.overflow=r[t]?.scrolling===!1?i.HIDDEN:i.AUTO,r[t]?.scrolling){case i.OMIT:break;case!0:e.scrolling=Dt;break;case!1:e.scrolling=re;break;default:e.scrolling=r[t]?.scrolling||re}}function Ct(e,t,n){kt(t,n),l(e,`src: %c${t.srcdoc||t.src}`,a.HIGHLIGHT),Qe(e),_t(t),gt(e),At(e,ut(e)),ot(e),l(e,"Setup complete")}function zt(e,t){const{id:n}=e;T(n,"setup"),st(n)&&Ct(n,e,t),de(n)}function Ft(e,t){t.log===i.LOG_DISABLED?t.log=!1:t.log===i.LOG_COLLAPSED?t.log=i.COLLAPSE:t.log===i.LOG_EXPANDED&&(t.log=i.EXPAND);const n=i.hasOwn(t,"log"),s=i.isString(t.log),o=n?s?!0:t.log:G.log;i.hasOwn(t,"logExpand")||(t.logExpand=n&&s?t.log===i.EXPAND:G.logExpand),me(t),ce({enabled:o,expand:t.logExpand,iframeId:e}),s&&!(t.log in i.LOG_OPTIONS)&&le(e,`Invalid value for options.log: Accepted values are "${i.EXPAND}" and "${i.COLLAPSE}"`),t.log=o}function Bt(e){if(!i.isObject(e))throw new TypeError("Options is not an object");return rt(),Oe(e),t=>{const n=pe(t,e);return i.LABEL in t?(T(n,"alreadySetup"),w(n,`Ignored iframe (${n}), already setup.`)):(Ft(n,e),D(n,zt)(t,e)),t?.iframeResizer}}Object.defineProperty(p,"LOG_COLLAPSED",{enumerable:!0,get:()=>i.LOG_COLLAPSED}),Object.defineProperty(p,"LOG_DISABLED",{enumerable:!0,get:()=>i.LOG_DISABLED}),Object.defineProperty(p,"LOG_EXPANDED",{enumerable:!0,get:()=>i.LOG_EXPANDED}),p.default=Bt,Object.defineProperties(p,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
|
|
27
27
|
//# sourceMappingURL=index.umd.js.map
|