@iframe-resizer/child 6.0.0-beta.3 → 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 +11 -13
- package/index.cjs.js.map +1 -1
- package/index.esm.js +687 -799
- package/index.esm.js.map +1 -1
- package/index.umd.js +11 -15
- package/index.umd.js.map +1 -1
- package/package.json +2 -1
package/README.md
CHANGED
package/index.cjs.js
CHANGED
|
@@ -1,30 +1,28 @@
|
|
|
1
|
-
"use strict";const
|
|
2
|
-
`,K="string",C="number",jn="boolean",Pn="object",Ce="function",Dn="undefined",_n="false",Fn="null",Z="auto",Ct="readystatechange",jt="bottom",Pt="right",Te="autoResizeEnabled",ot=Symbol("sizeChanged"),je="manualResize",Pe="parentResize",be={[je]:1,[Pe]:1},Dt="setOffsetSize",_t="resizeObserver",De="overflowObserver",Ft="mutationObserver",xt="visibilityObserver",xn="font-weight: bold;",_e="none",st="No change in content size detected",ce="[iFrameSizer]",Bt=ce.length,Bn=Z,Ut=128,Vt=new Set(["head","body","meta","base","title","script","link","style","map","area","option","optgroup","template","track","wbr","nobr"]),Un=e=>typeof e===K,ye=(e,...t)=>setTimeout(()=>e(...t),0),Wt=e=>{let t=!1;return function(...n){return t?void 0:(t=!0,e.apply(this,n))}},ae=e=>e,rt=1e3,G=e=>Math.round(e*rt)/rt,qt=e=>e.charAt(0).toUpperCase()+e.slice(1),L=e=>`${e}`!=""&&e!==void 0,Vn=e=>e(),Wn=e=>e.toLowerCase();function qn(e){switch(!0){case!L(e):return"";case L(e.id):return`${e.nodeName}#${e.id}`;case L(e.name):return`${e.nodeName} (${e.name}`;case L(e.className):return`${e.nodeName}.${e.className}`;default:return e.nodeName}}const Zn=e=>e?.__esModule?e.default:e,S=(e,t,n)=>{if(typeof e!==t)throw new TypeError(`${n} is not a ${qt(t)}`)},Zt={br:`
|
|
3
|
-
`,rb:"\x1B[31;1m",bb:"\x1B[34;1m",b:"\x1B[1m",i:"\x1B[3m",u:"\x1B[4m","/":"\x1B[m"},Yn=Object.keys(Zt),Qn=new RegExp(`<(${Yn.join("|")})>`,"gi"),Jn=(e,t)=>Zt[t]??"",Kn=e=>e.replace(Qn,Jn),Xn=e=>e.replaceAll("<br>",Ge).replaceAll(/<\/?[^>]+>/gi,""),eo=e=>t=>e(Un(t)?window.chrome?Kn(t):Xn(t):t);let Fe=!0,it=$e;const to=Zn(r),Y=to({label:`${$e}(child)`,expand:!1});function no(e){it=e.id||$e,Y.label(`${it}`),Y.expand(e.expand),Fe=e.enabled}const Yt=e=>(...t)=>Fe?Y[e](...t):!0,l=Yt("log"),u=l,le=Yt("debug");function oo(e,t){console.info(`%ciframe-resizer ${e}`,Fe||t<1?xn:r.NORMAL)}const{assert:so,endAutoGroup:j,error:Qt,errorBoundary:xe,event:h,label:ci,purge:ai,warn:F}=Y,Jt=eo(ae),b=(...e)=>Y.warn(...e.map(Jt)),ro=(...e)=>console.warn(...e.map(Jt)),Be=[];function Kt(e,t){l(`${e} event listener: %c${t}`,r.HIGHLIGHT)}const Xt=(e,t,n,o)=>{e.removeEventListener(t,n,o),Kt("Removed",t)},$=(e,t,n,o=!1)=>{e.addEventListener(t,n,o),Be.push(()=>Xt(e,t,n,o)),Kt("Added",t)},i={applySelectors:null,firstRun:!0,hasTags:!1,hasOverflow:!1,height:0,isHidden:!1,initLock:!0,inPageLinks:{},origin:void 0,hasOverflowUpdated:!0,overflowedNodeSet:new Set,sameOrigin:!1,taggedElements:[],target:window?.parent,timerActive:!1,totalTime:0,triggerLocked:!1,width:0,win:window,onPageInfo:null,onParentInfo:null};let ct=!1;function at(e){const t=window?.iframeResizer?.targetOrigin||"*",n=Array.isArray(t)?t:[t];for(const o of n)e.postMessage(Sn,o)}function lt(){if(document.readyState==="loading"||!i.firstRun||ct)return;const{parent:e,top:t}=window;h("ready"),l("Sending%c ready%c to parent from",r.HIGHLIGHT,r.FOREGROUND,window.location.href),at(e),e!==t&&at(t),ct=!0}const ut="iframeResize",io=e=>ce===`${e.data}`.slice(0,Bt),co=()=>ut in window||window.jQuery!==void 0&&ut in window.jQuery.prototype,ao=e=>e.data.split(he)[2]in{true:1,false:1},lo=()=>[document.documentElement,document.body],uo=["min-height","min-width","max-height","max-width"],dt=new Set,fo=e=>!!e&&e!=="0px"&&e!==Z&&e!==_e,en=e=>e.tagName?e.tagName.toLowerCase():"unknown",tn=(e,t)=>window.getComputedStyle(e).getPropertyValue(t),mo=(e,t)=>fo(tn(e,t));function ho(e,t){const n=e.style.getPropertyValue(t);return n?{source:"an inline style attribute",value:n}:null}function go({href:e}){dt.has(e)||(l("Unable to access stylesheet:",e),dt.add(e))}function po(e,t){for(const n of document.styleSheets)try{for(const o of n.cssRules||[]){if(!("selectorText"in o))continue;const s=o;if(!e.matches(s.selectorText))continue;const d=s.style.getPropertyValue(t);if(!d)continue;const{ownerNode:a}=n;return{source:a instanceof Element&&a.tagName==="STYLE"?"an inline <style> block":`stylesheet (${n.href})`,value:d}}}catch{go(n)}return{source:"cross-origin stylesheet",value:tn(e,t)}}const yo=(e,t)=>ho(e,t)||po(e,t),vo=(e,t)=>{const{source:n,value:o}=yo(e,t),s=en(e);b(`The <b>${t}</> CSS property is set to <b>${o}</> on the <b><${s}></> element via ${n}. This may cause issues with the correct operation of <i>iframe-resizer</>.
|
|
1
|
+
"use strict";const n=require("@iframe-resizer/common"),s=require("auto-console-group");let ue=!0,He=n.LABEL;const Rt=n.esModuleInterop(s),F=Rt({label:`${n.LABEL}(child)`,expand:!1});function Tt(e){He=e.id||n.LABEL,F.label(`${He}`),F.expand(e.expand),ue=e.enabled}const Ye=e=>(...t)=>ue?F[e](...t):!0,d=Ye("log"),f=d,Q=Ye("debug");function bt(e,t){console.info(`%ciframe-resizer ${e}`,ue||t<1?n.BOLD:s.NORMAL)}const{assert:wt,endAutoGroup:G,error:je,errorBoundary:ge,event:h,label:Or,purge:Sr,warn:_}=F,Qe=n.createFormatAdvise(n.id),R=(...e)=>F.warn(...e.map(Qe)),vt=(...e)=>console.warn(...e.map(Qe)),me=n.deprecate((e,t)=>R(t));me("Method");me("Method","replaced with");me("Option");const he=[];function Ke(e,t){d(`${e} event listener: %c${t}`,s.HIGHLIGHT)}const Je=(e,t,o,r)=>{e.removeEventListener(t,o,r),Ke("Removed",t)},N=(e,t,o,r=!1)=>{e.addEventListener(t,o,r),he.push(()=>Je(e,t,o,r)),Ke("Added",t)},c={applySelectors:null,firstRun:!0,hasTags:!1,hasOverflow:!1,height:0,isHidden:!1,initLock:!0,inPageLinks:{},origin:void 0,hasOverflowUpdated:!0,overflowedNodeSet:new Set,sameOrigin:!1,taggedElements:[],target:window?.parent,timerActive:!1,totalTime:0,triggerLocked:!1,width:0,win:window,onPageInfo:null,onParentInfo:null};let Ae=!1;function Me(e){const t=window?.iframeResizer?.targetOrigin||"*",o=Array.isArray(t)?t:[t];for(const r of o)e.postMessage(n.CHILD_READY_MESSAGE,r)}function Ne(){if(document.readyState==="loading"||!c.firstRun||Ae)return;const{parent:e,top:t}=window;h("ready"),d("Sending%c ready%c to parent from",s.HIGHLIGHT,s.FOREGROUND,window.location.href),Me(e),e!==t&&Me(t),Ae=!0}const Le="iframeResize",yt=e=>n.MESSAGE_ID===`${e.data}`.slice(0,n.MESSAGE_ID_LENGTH),Ht=()=>Le in window||window.jQuery!==void 0&&Le in window.jQuery.prototype,At=e=>e.data.split(n.SEPARATOR)[2]in{true:1,false:1},Mt=()=>[document.documentElement,document.body],Nt=["min-height","min-width","max-height","max-width"],Ge=new Set,Lt=e=>!!e&&e!=="0px"&&e!==n.AUTO&&e!==n.NONE,Xe=e=>e.tagName?e.tagName.toLowerCase():"unknown",et=(e,t)=>window.getComputedStyle(e).getPropertyValue(t),Gt=(e,t)=>Lt(et(e,t));function zt(e,t){const o=e.style.getPropertyValue(t);return o?{source:"an inline style attribute",value:o}:null}function $t({href:e}){Ge.has(e)||(d("Unable to access stylesheet:",e),Ge.add(e))}function _t(e,t){for(const o of document.styleSheets)try{for(const r of o.cssRules||[]){if(!("selectorText"in r))continue;const i=r;if(!e.matches(i.selectorText))continue;const u=i.style.getPropertyValue(t);if(!u)continue;const{ownerNode:l}=o;return{source:l instanceof Element&&l.tagName==="STYLE"?"an inline <style> block":`stylesheet (${o.href})`,value:u}}}catch{$t(o)}return{source:"cross-origin stylesheet",value:et(e,t)}}const kt=(e,t)=>zt(e,t)||_t(e,t),Ct=(e,t)=>{const{source:o,value:r}=kt(e,t),i=Xe(e);R(`The <b>${t}</> CSS property is set to <b>${r}</> on the <b><${i}></> element via ${o}. This may cause issues with the correct operation of <i>iframe-resizer</>.
|
|
4
2
|
|
|
5
|
-
If you wish to restrict the size of the iframe, then you should set this property on the iframe element itself, not the content inside it.`)};function
|
|
3
|
+
If you wish to restrict the size of the iframe, then you should set this property on the iframe element itself, not the content inside it.`)};function Dt(){for(const e of Mt())for(const t of Nt)d(`Checking <${Xe(e)}> for blocking CSS: ${t}`),Gt(e,t)&&Ct(e,t)}const Pt=({calculateWidth:e,calculateHeight:t})=>e===t,a={autoResize:!0,bodyBackground:"",bodyMargin:0,bodyMarginStr:"",bodyPadding:"",calculateHeight:!0,calculateWidth:!1,heightCalcMode:n.AUTO,ignoreSelector:"",inPageLinks:!1,logging:!1,logExpand:!1,mode:0,mouseEvents:!1,offsetHeight:0,offsetWidth:0,parentId:void 0,sizeSelector:"",targetOrigin:"*",tolerance:0,widthCalcMode:n.AUTO,onBeforeResize:void 0,onMessage:()=>{_("onMessage function not defined")},onReady:()=>{}};function Bt(){try{c.sameOrigin=a.mode===1||"iframeParentListener"in window.parent}catch{d("Cross domain iframe detected")}}let ze=0;function Ft(e){const t=e.length===1?"":"s";_(`%c[${n.IGNORE_ATTR}]%c found on %c${e.length}%c element${t}`,s.BOLD,s.NORMAL,s.BOLD,s.NORMAL)}function Ut(){const e=document.querySelectorAll(`*[${n.IGNORE_ATTR}]`),t=e.length>0;return t&&e.length!==ze&&(Ft(e),ze=e.length),t}function xt(e,t,o){(!n.isDef(o)||t>-1&&e>t)&&(bt(`v${n.VERSION} (${n.getModeLabel(e)})`,e),e===0&&vt(n.getModeData(3)))}function Vt({key:e,key2:t,mode:o,version:r}){const i=o,u=n.isDef(e)?n.setMode({key:e}):-1,l=n.isDef(t)?n.setMode({key:t}):-1;let g;switch(o=Math.max(u,l),o){case-2:case-1:g=`${n.getModeData(Math.min(u,l)+2)}${n.getModeData(2)}`,c.firstRun=!1;break;case 1:case 2:case 3:g=n.getModeData(6);break;case 4:g=n.getModeData(7);break;case 5:g=n.getModeData(8);break}if(o>=0&&xt(o,i,r),(!n.isDef(r)||!c.firstRun)&&(g&&R(g),o<0))throw R(n.getModeData(9)),g.split("<br>")[0].replace(/<\/?[a-z][^>]*>|<\/>/gi,"");a.mode=o}const Wt="BackCompat",Zt=`<rb>Quirks Mode Detected</>
|
|
6
4
|
|
|
7
5
|
This iframe is running in the browser's legacy <b>Quirks Mode</>, this may cause issues with the correct operation of <i>iframe-resizer</>. It is recommended that you switch to the modern <b>Standards Mode</>.
|
|
8
6
|
|
|
9
7
|
For more information see <u>https://iframe-resizer.com/quirks-mode</>.
|
|
10
|
-
`;function
|
|
8
|
+
`;function qt(){document.compatMode===Wt&&R(Zt)}const Yt="complete";let $e=!1;function tt(e){document.readyState===Yt?n.isolateUserCode(e):$e||N(document,n.READY_STATE_CHANGE,()=>tt(e)),$e=!0}const jt=()=>{f(`Set targetOrigin for parent: %c${a.targetOrigin}`,s.HIGHLIGHT),a.autoResize!==!0&&d("Auto Resize disabled")};function nt(){c.taggedElements=document.querySelectorAll(`[${n.SIZE_ATTR}]`),c.hasTags=c.taggedElements.length>0,d(`Tagged elements found: %c${c.hasTags}`,s.HIGHLIGHT)}const Qt=`<rb>Legacy version detected on parent page</>
|
|
11
9
|
|
|
12
10
|
Detected legacy version of parent page script. It is recommended to update the parent page to use <b>@iframe-resizer/parent</>.
|
|
13
11
|
|
|
14
12
|
See <u>https://iframe-resizer.com/setup/</> for more details.
|
|
15
|
-
`,
|
|
13
|
+
`,Kt=e=>`<b>Version mismatch</>
|
|
16
14
|
|
|
17
15
|
The parent and child pages are running different versions of <i>iframe resizer</>.
|
|
18
16
|
|
|
19
|
-
Parent page: ${e} - Child page: ${
|
|
20
|
-
`;function
|
|
17
|
+
Parent page: ${e} - Child page: ${n.VERSION}.
|
|
18
|
+
`;function Jt({version:e}){!e||e===""||e===n.FALSE?R(Qt):e!==n.VERSION&&R(Kt(e))}const Xt=n.once(()=>R(n.getModeData(4)));function en(e){if(!c.timerActive)return;const t=n.round(performance.now()-c.totalTime),o=e===n.INIT?`Initialised iframe in %c${t}ms`:`Size calculated in %c${t}ms`;d(o,s.HIGHLIGHT)}function tn(e){return e===void 0?e=a.targetOrigin:d(`Message targetOrigin: %c${e}`,s.HIGHLIGHT),e}function nn(e,t){const{mode:o}=a,{sameOrigin:r,target:i}=c;if(r)try{window.parent.iframeParentListener(n.MESSAGE_ID+e)}catch(u){if(n.checkMode(o))Xt();else throw new Error(u);return!1}else{wt(i,"Internal error: postMessage target is undefined");const u=tn(t),l=Array.isArray(u)?u:[u];for(const g of l)i.postMessage(n.MESSAGE_ID+e,g)}return!0}function ot(e,t,o,r,i){const{parentId:u}=a,{sameOrigin:l}=c,g=`${e}:${t}`,p=`${u}:${g}:${o}${r===void 0?"":`:${r}`}`;a.mode<-1||!nn(p,i)||(en(o),f(`Sending message to parent page via ${l?"sameOrigin":"postMessage"}: %c%c${p}`,s.ITALIC,s.HIGHLIGHT))}const O=ge((e,t,o,r,i)=>{h(o),ot(e,t,o,r,i),G()}),on=e=>O(0,0,e.type,`${e.screenY}:${e.screenX}`);function _e(e,t){d(`Add event listener: %c${t}`,s.HIGHLIGHT),N(window.document,e,on)}function rn({mouseEvents:e}){e===!0&&(_e(n.MOUSE_ENTER,"Mouse Enter"),_e(n.MOUSE_LEAVE,"Mouse Leave"))}const sn=()=>O(0,0,n.BEFORE_UNLOAD);function cn({persisted:e}){e||sn(),h(n.PAGE_HIDE),f("Page persisted:",e),!e&&he.forEach(n.invoke)}const an=()=>N(window,n.lower(n.PAGE_HIDE),cn),ke=(e,t)=>!(Math.abs(e-t)<=a.tolerance);function dn(e,t){const{calculateHeight:o,calculateWidth:r}=a,{height:i,width:u}=c;return o&&ke(i,e)||r&&ke(u,t)}const A=[s.HIGHLIGHT,s.FOREGROUND,s.HIGHLIGHT],Y={height:0,width:0},$={height:0,width:0};function z(e,t,o){return $[e]=t,Y[e]=o,t}function ln(e){const t=e.getOffset();return t!==0&&f(`Page offsetSize: %c${t}px`,s.HIGHLIGHT),t}const fn=e=>e.documentElementScroll()+Math.max(0,e.getOffset());function rt(e){const{hasOverflow:t,hasTags:o,triggerLocked:r}=c,i=e.label,u=i===n.HEIGHT,l=e.boundingClientRect(),g=Math.ceil(l),p=Math.floor(l),m=fn(e),S=`HTML: %c${l}px %cPage: %c${m}px`;let E;switch(!0){case!e.enabled():return Math.max(m,n.MIN_SIZE);case o:f("Found element with data-iframe-size attribute"),E=e.taggedElement();break;case(!t&&c.firstRun&&$[i]===0&&Y[i]===0):f(`Initial page size values: ${S}`,...A),E=z(i,l,m);break;case(r&&l===$[i]&&m===Y[i]):f(`Size unchanged: ${S}`,...A),E=Math.max(l,m);break;case(l===0&&m!==0):f(`Page is hidden: ${S}`,...A),E=m;break;case(!t&&l!==$[i]&&m<=Y[i]):f(`New <html> size: ${S} `,...A),f(`Previous <html> size: %c${$[i]}px`,s.HIGHLIGHT),E=z(i,l,m);break;case!u:E=e.taggedElement();break;case(!t&&l<$[i]):f(`<html> size decreased: ${S}`,...A),E=z(i,l,m);break;case(m===p||m===g):f(`<html> size equals page size: ${S}`,...A),E=z(i,l,m);break;case l>m:f(`Page size < <html> size: ${S}`,...A),E=z(i,l,m);break;case t:f("Found elements possibly overflowing <html> "),E=e.taggedElement();break;default:f(`Using <html> size: ${S}`,...A),E=z(i,l,m)}return f(`Content ${i}: %c${E}px`,s.HIGHLIGHT),E+=ln(e),Math.max(E,n.MIN_SIZE)}const un=1e3,gn=5*un,mn=4,hn=10,En=100,Ee="--ifr-start",K="--ifr-end",st="--ifr-measure",I=[];let j={},Ce=0,ce;function it(){try{performance.clearMarks(Ee),performance.clearMarks(K),performance.clearMeasures(st)}catch{}}function In(){ce=setInterval(()=>{if(I.length<hn||j.hasTags&&j.len<25)return;I.sort();const e=Math.min(I.reduce((o,r)=>o+r,0)/I.length,I[Math.floor(I.length/2)]),t=n.round(e);t>Ce&&(Ce=t,h("performanceObserver"),d("Mean time:",n.round(I[Math.floor(I.length/2)])),d("Median time:",n.round(I.reduce((o,r)=>o+r,0)/I.length)),d("Average time:",t),d("Max time:",n.round(Math.max(...I)))),it(),!(e<=mn)&&(clearInterval(ce),R(`<rb>Performance Warning</>
|
|
21
19
|
|
|
22
|
-
Calculating the page size is taking an excessive amount of time (${
|
|
20
|
+
Calculating the page size is taking an excessive amount of time (${n.round(e)}ms).
|
|
23
21
|
|
|
24
|
-
To improve performance add the <b>data-iframe-size</> attribute to the ${
|
|
25
|
-
`,
|
|
26
|
-
`,t),t},
|
|
22
|
+
To improve performance add the <b>data-iframe-size</> attribute to the ${j.Side.toLowerCase()} most element on the page. For more details see: <u>https://iframe-resizer.com/perf</>.`))},gn)}function pn(e){e.getEntries().forEach(t=>{if(t.name===K)try{const{duration:o}=performance.measure(st,Ee,K);j=t.detail,I.push(o),I.length>En&&I.shift()}catch{}})}function On(){f("Attached%c PerformanceObserver%c to page",s.HIGHLIGHT,s.FOREGROUND);const e=new PerformanceObserver(pn);return e.observe({entryTypes:["mark"]}),In(),{disconnect:()=>{it(),clearInterval(ce),e.disconnect(),f("Detached%c PerformanceObserver",s.HIGHLIGHT)}}}const Sn=e=>`:not(${e})`,Rn=`* ${Array.from(n.IGNORE_TAGS).map(Sn).join("")}`,Ie=e=>e.querySelectorAll(Rn);function Tn(){const{hasOverflow:e,hasTags:t,overflowedNodeSet:o,taggedElements:r}=c;return t?r:e?Array.from(o):Ie(document.documentElement)}function bn(e,t){const o=`margin-${t}`;let r,i=document.documentElement,u=c.hasTags?n.MIN_SIZE:document.documentElement.getBoundingClientRect().bottom;for(const l of e)r=l.getBoundingClientRect()[t]+parseFloat(getComputedStyle(l).getPropertyValue(o)),r>u&&(u=r,i=l);return{maxEl:i,maxVal:u}}function ct(e){performance.mark(Ee);const t=n.capitalizeFirstLetter(e),{logging:o}=a,{hasTags:r}=c,i=Tn(),{maxEl:u,maxVal:l}=bn(i,e);return f(`${t} position calculated from:`,u),f(`Checked %c${i.length}%c elements`,s.HIGHLIGHT,s.FOREGROUND),performance.mark(K,{detail:{hasTags:r,len:i.length,logging:o,Side:t}}),l}const pe={label:n.HEIGHT,enabled:()=>a.calculateHeight,getOffset:()=>a.offsetHeight,auto:()=>rt(pe),boundingClientRect:()=>Math.max(document.documentElement.getBoundingClientRect().bottom,document.body.getBoundingClientRect().bottom),documentElementScroll:()=>document.documentElement.scrollHeight,taggedElement:()=>ct(n.HEIGHT_EDGE)},Oe={label:n.WIDTH,enabled:()=>a.calculateWidth,getOffset:()=>a.offsetWidth,auto:()=>rt(Oe),boundingClientRect:()=>Math.max(document.documentElement.getBoundingClientRect().right,document.body.getBoundingClientRect().right),documentElementScroll:()=>document.documentElement.scrollWidth,taggedElement:()=>ct(n.WIDTH_EDGE)};function wn(e,t,o){const r=a.onBeforeResize(e,t,o);if(r===void 0)throw new TypeError("No value returned from onBeforeResize(), expected a numeric value");if(Number.isNaN(r))throw new TypeError(`Invalid value returned from onBeforeResize(): ${r}, expected Number`);if(r<n.MIN_SIZE)throw new RangeError(`Out of range value returned from onBeforeResize(): ${r}, must be at least ${n.MIN_SIZE}`);return r}const at=(e,t)=>(o,r)=>{const i=e[o]();return e.enabled()&&a.onBeforeResize!==void 0?wn(i,r,t):i},vn=at(pe,n.HEIGHT),yn=at(Oe,n.WIDTH);function Hn(){(window.scrollY!==0||window.scrollX!==0)&&(f("Reset iframe scroll position to (0, 0)"),window.scrollTo(0,0))}function An(e,t,o,r){const{heightCalcMode:i,widthCalcMode:u}=a;Hn();const l=o??vn(i,e),g=r??yn(u,e),p=dn(l,g)?n.SIZE_CHANGE_DETECTED:e;switch(d(`Resize event: %c${t}`,s.HIGHLIGHT),p){case n.INIT:case n.ENABLE:case n.SIZE_CHANGE_DETECTED:case n.MANUAL_RESIZE_REQUEST:case n.PARENT_RESIZE_REQUEST:c.height=l,c.width=g;case n.SET_OFFSET_SIZE:return c;case n.OVERFLOW_OBSERVER:case n.MUTATION_OBSERVER:case n.RESIZE_OBSERVER:case n.VISIBILITY_OBSERVER:{d(n.NO_CHANGE);break}default:f(n.NO_CHANGE)}return null}let W=!1,ne=!1,D=null;function Mn(e,t,o,r,i){const{autoResize:u}=a,{isHidden:l}=c;switch(h(e),!0){case(l===!0&&!(e in n.IGNORE_DISABLE_RESIZE)):{if(ne===!0)break;d("Iframe hidden - Ignored resize request"),ne=!0,W=!1,cancelAnimationFrame(D),D=null;break}case(W===!0&&e!==n.OVERFLOW_OBSERVER&&!(e in n.IGNORE_DISABLE_RESIZE)):{d("Resize already pending - Ignored resize request");break}case(!u&&!(e in n.IGNORE_DISABLE_RESIZE)):{f("Resizing disabled");break}default:{ne=!1,W=!0,c.totalTime=performance.now(),c.timerActive=!0;const g=An(e,t,o,r);g&&ot(g.height,g.width,e,i),D||(D=requestAnimationFrame(()=>{W=!1,D=null,h("requestAnimationFrame"),Q(`Reset sendPending: %c${e}`,s.HIGHLIGHT)})),c.timerActive=!1}}G()}const y=ge(Mn);function De({eventType:e,eventName:t}){N(window,t,()=>y(t,e),{passive:!0})}function Nn(){De({eventType:"After Print",eventName:"afterprint"}),De({eventType:"Before Print",eventName:"beforeprint"})}function Ln(){if(c.triggerLocked){d("TriggerLock blocked calculation");return}c.triggerLocked=!0,Q("Trigger event lock on"),requestAnimationFrame(()=>{c.triggerLocked=!1,Q("Trigger event lock off")})}function dt(e){const{heightCalcMode:t,widthCalcMode:o}=a,r=pe[t](),i=Oe[o]();d(`Reset trigger event: %c${e}`,s.HIGHLIGHT),O(r,i,e)}function Gn(e){const t=a.heightCalcMode;d(`Reset trigger event: %c${e}`,s.HIGHLIGHT),a.heightCalcMode=n.HEIGHT_CALC_MODE_DEFAULT,Ln(),dt("reset"),a.heightCalcMode=t}const zn=`Auto Resize can not be changed when <b>direction</> is set to '${n.NONE}'.`;function $n(e){n.typeAssert(e,n.BOOLEAN,"parentIframe.autoResize(enable) enable");const{autoResize:t,calculateHeight:o,calculateWidth:r}=a;return r===!1&&o===!1?(h(n.ENABLE),R(zn),!1):(e===!0&&t===!1?(a.autoResize=!0,queueMicrotask(()=>y(n.ENABLE,"Auto Resize enabled"))):e===!1&&t===!0&&(a.autoResize=!1),O(0,0,n.AUTO_RESIZE,JSON.stringify(a.autoResize)),a.autoResize)}function _n(e){n.typeAssert(e,n.STRING,"parentIframe.moveToAnchor(anchor) anchor"),c.inPageLinks.findTarget(e)}function kn(e){n.typeAssert(e,n.NUMBER,"parentIframe.setOffsetSize(offset) offset"),a.offsetHeight=e,a.offsetWidth=e,y(n.SET_OFFSET_SIZE,`parentIframe.setOffsetSize(${e})`)}const Cn=()=>c.origin;function Dn(e){n.typeAssert(e,n.STRING,"parentIframe.setTargetOrigin(targetOrigin) targetOrigin"),d(`Set targetOrigin: %c${e}`,s.HIGHLIGHT),a.targetOrigin=e}function Pn(e){return n.typeAssert(e,n.FUNCTION,"parentIframe.getParentProps(callback) callback"),c.onParentInfo=e,O(0,0,n.PARENT_INFO),()=>{c.onParentInfo=null,O(0,0,n.PARENT_INFO_STOP)}}function Bn(e,t){e!==void 0&&n.typeAssert(e,n.NUMBER,"parentIframe.resize(customHeight, customWidth) customHeight"),t!==void 0&&n.typeAssert(t,n.NUMBER,"parentIframe.resize(customHeight, customWidth) customWidth");const o=e===void 0?"":e,r=t===void 0?"":`,${t}`,i=`${o}${r}`;y(n.MANUAL_RESIZE_REQUEST,`parentIframe.resize(${i})`,e,t)}const Se=e=>(t,o)=>{n.typeAssert(t,n.NUMBER,`parentIframe.${e}(x, y) x`),n.typeAssert(o,n.NUMBER,`parentIframe.${e}(x, y) y`),O(o,t,e)},Fn=Se(n.SCROLL_BY),Un=Se(n.SCROLL_TO),xn=Se(n.SCROLL_TO_OFFSET);function Vn(e,t){t&&n.typeAssert(t,n.STRING,"parentIframe.sendMessage(msg, targetOrigin) targetOrigin"),O(0,0,n.MESSAGE,JSON.stringify(e),t)}const Wn=()=>O(0,0,n.CLOSE),Zn=()=>a.parentId,qn=()=>Gn("parentIframe.reset");function Yn(){const{win:e}=c;a.mode!==1&&(e.parentIframe=Object.freeze({autoResize:$n,close:Wn,getId:Zn,getParentOrigin:Cn,getParentProps:Pn,moveToAnchor:_n,reset:qn,setOffsetSize:kn,scrollBy:Fn,scrollTo:Un,scrollToOffset:xn,sendMessage:Vn,setTargetOrigin:Dn,resize:Bn}))}const U=(e="")=>t=>o=>{o.size>0&&Q(`${t}Observer ${e}:`,...Array.from(o).flatMap(r=>[n.NEW_LINE,r]))},jn=(e="")=>t=>o=>{o.size>0&&je(`${t}Observer ${e}:`,...Array.from(o).flatMap(r=>[n.NEW_LINE,r]))},lt=U("attached to"),ft=jn("already attached"),Qn=U("detached from"),ee=(e,t=!0)=>o=>{o>0&&f(`${t?"At":"De"}tached %c${e}Observer%c ${t?"to":"from"} %c${o}%c element${o===1?"":"s"}`,s.HIGHLIGHT,s.NORMAL,s.HIGHLIGHT,s.NORMAL)},ut=(e,t,o,r)=>{const i=Qn(e);return u=>{const l=new Set;let g=0;for(const p of u)o.has(p)&&(t.unobserve(p),o.delete(p),l.add(p),g+=1);i(l),r(g),l.clear()}},Pe=16,Be=2,Kn=200,Re="Mutation",w=new Set,M=new Set,ae=new Set,J=[],Jn={attributes:!0,attributeFilter:[n.IGNORE_ATTR,n.SIZE_ATTR],attributeOldValue:!1,characterData:!1,characterDataOldValue:!1,childList:!0,subtree:!0};let oe=1,Te,de=!1,le=0;const Xn=U("added")(Re),eo=U("removed (page)")(Re),to=U("removed (added)")(Re),gt=e=>e.nodeType!==Node.ELEMENT_NODE||n.IGNORE_TAGS.has(e.tagName.toLowerCase());function no(e){const t=e.addedNodes;for(const o of t)gt(o)||w.add(o)}function oo(e){const t=e.removedNodes;for(const o of t)gt(o)||(w.has(o)?(w.delete(o),ae.add(o)):M.add(o))}const ro=e=>{f("Mutations:",e);for(const t of e)no(t),oo(t);Xn(w),eo(M),to(ae),ae.clear()};function so(){M.size>0&&d(`Detected %c${M.size} %cremoved element${M.size>1?"s":""}`,s.HIGHLIGHT,s.FOREGROUND),w.size>0&&d(`Found %c${w.size} %cnew element${w.size>1?"s":""}`,s.HIGHLIGHT,s.FOREGROUND)}const io=e=>()=>{const t=performance.now(),o=t-le,r=Pe*oe+++Be;if(o>r&&o<Kn){h("mutationThrottled"),f("Update delayed due to heavy workload on the callStack"),f(`EventLoop busy time: %c${n.round(o)}ms %c> Max wait: %c${r-Be}ms`,s.HIGHLIGHT,s.FOREGROUND,s.HIGHLIGHT),setTimeout(Te,Pe*oe),le=t;return}oe=1,J.forEach(ro),J.length=0,de=!1,so(),e({addedNodes:w,removedNodes:M}),w.clear(),M.clear()};function co(e){J.push(e),!de&&(le=performance.now(),de=!0,requestAnimationFrame(Te))}function ao(e){const t=new window.MutationObserver(co),o=document.body||document.documentElement;return Te=io(e),t.observe(o,Jn),f("Attached%c MutationObserver%c to body",s.HIGHLIGHT,s.FOREGROUND),{disconnect:()=>{w.clear(),M.clear(),J.length=0,t.disconnect(),f("Detached%c MutationObserver",s.HIGHLIGHT)}}}const lo={characterData:!0,childList:!0,subtree:!0};function fo(e){const t=document.querySelector("title")??document.head??document.documentElement,o=new MutationObserver(e);return o.observe(t,lo),f("Attached%c TitleObserver%c to head",s.HIGHLIGHT,s.FOREGROUND),setTimeout(e),{disconnect:()=>{o.disconnect(),f("Detached%c TitleObserver",s.HIGHLIGHT)}}}function uo(e){const t=new IntersectionObserver(r=>e(r.at(-1)?.isIntersecting??!1),{threshold:0}),o=document.documentElement;return t.observe(o),f("Attached%c VisibilityObserver%c to page",s.HIGHLIGHT,s.FOREGROUND),{disconnect:()=>{t.disconnect(),f("Detached%c VisibilityObserver",s.HIGHLIGHT)}}}let Fe=new Set;function go(e){const t=new Set,o=new Set;for(const r of e)r.closest(`[${n.IGNORE_ATTR}]`)?o.add(r):t.add(r);return o.size>0&&queueMicrotask(()=>{h("overflowIgnored"),f(`Ignoring elements with [data-iframe-ignore] > *:
|
|
23
|
+
`,o),G()}),t}function mt(){const e=document.querySelectorAll(`[${n.OVERFLOW_ATTR}]`),t=go(e);let o=!0;return typeof Set.prototype.symmetricDifference===n.FUNCTION&&(o=t.symmetricDifference(Fe).size>0),Fe=t,c.overflowedNodeSet=t,c.hasOverflow=t.size>0,{hasOverflowUpdated:o,overflowedNodeSet:t}}const v={},ht=e=>{const t=new Set;for(const o of e)if(o instanceof Element){t.add(o);for(const r of Ie(o))t.add(r)}return f(`Inspecting:
|
|
24
|
+
`,t),t},mo=e=>{if(e.size===0)return;h("addObservers");const t=ht(e);v.overflow.attachObservers(t),v.resize.attachObserverToNonStaticElements(t),G()},ho=e=>{if(e.size===0)return;h("removeObservers");const t=ht(e);v.overflow.detachObservers(t),v.resize.detachObservers(t),G()};function Eo({addedNodes:e,removedNodes:t}){h("contentMutated"),c.applySelectors(),nt(),mt(),G(),ho(t),mo(e)}function Io(e){Eo(e),y(n.MUTATION_OBSERVER,"Mutation Observed")}const x="Overflow",po=ee(x),Oo=ee(x,!1),So=lt(x),Ro=ft(x),To=e=>e instanceof HTMLElement&&(!!e.hidden||e.offsetParent===null||e.style.display===n.NONE),bo=(e,t)=>{const o=t.side||n.HEIGHT_EDGE,r={root:t.root,rootMargin:"0px",threshold:1},i=window?.requestAnimationFrame||n.id,u=(T=!1)=>e(T),l=(T,H)=>T===0||T>H[o],g=(T,H)=>{T.toggleAttribute(n.OVERFLOW_ATTR,H)};function p(T){for(const H of T){const{boundingClientRect:k,rootBounds:C,target:b}=H;if(!C)continue;const Ot=k[o],St=l(Ot,C)&&!(b instanceof HTMLElement&&To(b));g(b,St)}i(u)}const m=new IntersectionObserver(p,r),S=new WeakSet;function E(T){const H=new Set,k=new Set;let C=0;for(const b of T)if(b instanceof Element){if(S.has(b)){H.add(b);continue}m.observe(b),S.add(b),k.add(b),C+=1}Ro(H),So(k),po(C),k.clear(),H.clear()}return{attachObservers:E,detachObservers:ut(x,m,S,Oo),disconnect:()=>{m.disconnect(),f("Detached%c OverflowObserver",s.HIGHLIGHT)}}};function wo(){const{hasOverflow:e}=c,{hasOverflowUpdated:t,overflowedNodeSet:o}=mt();switch(!0){case!t:return;case o.size>1:f("Overflowed Elements:",o);break;case e:break;default:f("No overflow detected")}y(n.OVERFLOW_OBSERVER,"Overflow updated")}function vo(e){const t={root:document.documentElement,side:a.calculateHeight?n.HEIGHT_EDGE:n.WIDTH_EDGE};return v.overflow=bo(wo,t),v.overflow.attachObservers(e),v.overflow}const V="Resize",yo=ee(V),Ho=ee(V,!1),Ao=lt(V),Mo=ft(V),X=new WeakSet,re=new Set,se=new Set;let B;function No(e){let t=0;for(const o of e){if(!(o instanceof Element))continue;const r=getComputedStyle(o)?.position;if(!(r===""||r==="static")){if(X.has(o)){re.add(o);continue}B.observe(o),X.add(o),se.add(o),t+=1}}Mo(re),Ao(se),yo(t),se.clear(),re.clear()}const Lo=e=>(B=new ResizeObserver(e),B.observe(document.body),X.add(document.body),f("Attached%c ResizeObserver%c to body",s.HIGHLIGHT,s.FOREGROUND),{attachObserverToNonStaticElements:No,detachObservers:ut(V,B,X,Ho),disconnect:()=>{B.disconnect(),f("Detached%c ResizeObserver",s.HIGHLIGHT)}});function Go(e){if(!Array.isArray(e)||e.length===0)return;const t=e[0].target;y(n.RESIZE_OBSERVER,`Element resized <${n.getElementName(t)}>`)}function zo(e){return v.resize=Lo(Go),v.resize.attachObserverToNonStaticElements(e),v.resize}let Ue;function $o(){const e=document.title;e!==Ue&&(Ue=e,d(`Title: %c${e}`,s.HIGHLIGHT),e&&O(0,0,n.TITLE,e))}function _o(e){d(`Visible: %c${e}`,s.HIGHLIGHT),c.isHidden=!e,y(n.VISIBILITY_OBSERVER,"Visibility changed")}function ko(e){he.push(...e.map(t=>t.disconnect))}function Co(){h("attachObservers");const e=Ie(document.documentElement),t=[ao(Io),vo(e),On(),zo(e),fo($o),uo(_o)];ko(t)}const xe=(e,t,o)=>{if(o!==""){d(`${e}: %c${o}`,s.HIGHLIGHT);for(const r of document.querySelectorAll(o))d(`Applying ${t} to:`,r),r.toggleAttribute(t,!0)}};function Do({sizeSelector:e,ignoreSelector:t}){return()=>{xe("sizeSelector",n.SIZE_ATTR,e),xe("ignoreSelector",n.IGNORE_ATTR,t)}}function Po(){const e=document.createElement("div");e.style.clear="both",e.style.display="block",e.style.height="0",document.body.append(e)}function Bo(e,t){return t.includes("-")&&(_(`Negative CSS value ignored for ${e}`),t=""),t}function fe(e,t){t===void 0||t===""||t===n.NULL||(document.body.style.setProperty(e,t),f(`Set body ${e}: %c${t}`,s.HIGHLIGHT))}function Fo({bodyMarginStr:e,bodyMargin:t}){e===void 0&&(e=`${t}px`),fe("margin",Bo("margin",e))}const Uo=()=>({x:document.documentElement.scrollLeft,y:document.documentElement.scrollTop});function xo(e){const t=e.getBoundingClientRect(),o=Uo();return{x:Math.round(t.left+o.x),y:Math.round(t.top+o.y)}}function Vo(e,t){const o=xo(t);d(`Moving to in page link (%c#${e}%c) at x: %c${o.x}%c y: %c${o.y}`,s.HIGHLIGHT,s.FOREGROUND,s.HIGHLIGHT,s.FOREGROUND,s.HIGHLIGHT),O(o.y,o.x,n.SCROLL_TO_OFFSET)}function be(e){const t=e.split("#")[1]||e,o=decodeURIComponent(t),r=document.getElementById(o)||document.getElementsByName(o)[0];if(r!==void 0){Vo(t,r);return}d(`In page link (#${t}) not found in iframe, so sending to parent`),O(0,0,n.IN_PAGE_LINK,`#${t}`)}function Et(){const{hash:e,href:t}=window.location;e!==""&&e!=="#"&&be(t)}function Wo(){for(const e of document.querySelectorAll('a[href^="#"]'))e.getAttribute("href")!=="#"&&N(e,"click",t=>{t.preventDefault(),be(e.getAttribute("href"))})}function Zo(){N(window,"hashchange",Et)}function qo(){setTimeout(Et,n.EVENT_CANCEL_TIMER)}function Yo(){d("Setting up location.hash handlers"),Wo(),Zo(),qo(),c.inPageLinks={findTarget:be}}function jo(e){const{mode:t}=a;e?n.checkMode(t)?R(n.getModeData(5)):Yo():d("In page linking not enabled")}const Qo="important";function Ko(){const e=t=>t.style.setProperty(n.HEIGHT,n.AUTO,Qo);e(document.documentElement),e(document.body),d("Set HTML & body height: %cauto !important",s.HIGHLIGHT)}const we=e=>(t,o)=>{if(o in t){if(typeof t[o]===e)return t[o];throw new TypeError(`${o} is not a ${e}.`)}},ie=we(n.FUNCTION),Ve=we(n.NUMBER),Z=we(n.STRING),Jo=e=>e!==null&&typeof e===n.OBJECT&&!Array.isArray(e);function Xo(e){const{calculateHeight:t,calculateWidth:o}=a;let r,i;return typeof e?.offsetSize===n.NUMBER&&(t&&(r=Ve(e,n.OFFSET_SIZE)),o&&(i=Ve(e,n.OFFSET_SIZE))),{offsetHeight:r,offsetWidth:i}}function er(e){d("Reading data from page:",Object.keys(e));const{offsetHeight:t,offsetWidth:o}=Xo(e);return{offsetHeight:t,offsetWidth:o,ignoreSelector:Z(e,"ignoreSelector"),[n.getKey(3)]:Z(e,n.getKey(0)),sizeSelector:Z(e,"sizeSelector"),targetOrigin:Z(e,"targetOrigin"),onBeforeResize:ie(e,"onBeforeResize"),onMessage:ie(e,"onMessage"),onReady:ie(e,"onReady")}}function tr(){const{mode:e}=a;if(n.checkMode(e))return{};const t=window.iframeResizer||window.iFrameResizer;return Jo(t)?er(t):{}}const nr=e=>e==="true",It=e=>t=>t===void 0?void 0:e(t),L=It(nr),P=It(Number),or=e=>({parentId:e[0],bodyMargin:P(e[1]),calculateWidth:L(e[2]),logging:L(e[3]),autoResize:L(e[6]),bodyMarginStr:e[7],bodyBackground:e[9],bodyPadding:e[10],tolerance:P(e[11]),inPageLinks:L(e[12]),mouseEvents:L(e[15]),offsetHeight:P(e[16]),offsetWidth:P(e[17]),calculateHeight:L(e[18]),key:e[19],version:e[20],mode:P(e[21]),logExpand:L(e[23])});function rr(e){const{mode:t}=a;e.forEach(o=>{try{o()}catch(r){if(t<0)throw r;R(`<rb>Error in setup function</>
|
|
27
25
|
<i>iframe-resizer</> detected an error during setup.
|
|
28
26
|
|
|
29
|
-
Please report the following error message at <u>https://github.com/davidjbradshaw/iframe-resizer/issues</>`),
|
|
27
|
+
Please report the following error message at <u>https://github.com/davidjbradshaw/iframe-resizer/issues</>`),je(r)}})}function We(e){for(const[t,o]of Object.entries(e))o!==void 0&&(a[t]=o)}function sr({logExpand:e,logging:t,parentId:o=""}){Tt({id:o,enabled:t,expand:e}),h("initReceived"),d(`Initialising iframe v${n.VERSION} ${window.location.href}`)}function ir(e){h("ready"),tt(n.once(e)),d("Initialization complete",(({key:t,key2:o,...r})=>r)(a))}function cr({bodyBackground:e,bodyPadding:t,inPageLinks:o,onReady:r}){const i=Pt(a),u=[Ut,Bt,qt,nt,jt,i?n.id:Dt,()=>Fo(a),()=>fe("background",e),()=>fe("padding",t),i?n.id:Ko,Po,c.applySelectors,()=>jo(o),Nn,()=>rn(a),an,()=>Yn(),()=>y(n.INIT,"Init message from host page",void 0,void 0,`${n.VERSION}:${a.mode}`),Co,G];Jt(a),Vt(a),rr(u),ir(r)}function ar(e){c.firstRun&&(We(or(e)),sr(a),We(tr()),c.applySelectors=Do(a),cr(a))}function dr(e){if(document.readyState==="loading"){d("Page not ready, ignoring init message");return}const t=e.data.slice(n.MESSAGE_ID_LENGTH).split(n.SEPARATOR);c.target=e.source,c.origin=e.origin,ar(t),c.firstRun=!1,setTimeout(()=>{c.initLock=!1},n.EVENT_CANCEL_TIMER)}const{freeze:lr}=Object,{parse:ve}=JSON,ye=e=>lr(ve(e)),pt=e=>O(0,0,`${e}Stop`),te=e=>e.data.slice(e.data.indexOf(n.SEPARATOR)+1),fr=e=>At(e)?n.INIT:e.data.split("]")[1].split(n.SEPARATOR)[0];function ur(e){const t=te(e);d("onMessage called from parent:%c",s.HIGHLIGHT,ye(t)),n.isolateUserCode(a.onMessage,ve(t))}function gr(e){const{onPageInfo:t}=c,o=te(e);d("PageInfo received from parent:",ye(o)),t?n.isolateUserCode(t,ve(o)):pt(n.PAGE_INFO)}function mr(e){const{onParentInfo:t}=c,o=ye(te(e));d("ParentInfo received from parent:",o),t?n.isolateUserCode(t,o):pt(n.PARENT_INFO)}function hr(){if(c.initLock){d("Page reset ignored by init");return}d("Page size reset by host page"),dt("resetPage")}function Er(){d("Resize requested by host page"),y(n.PARENT_RESIZE_REQUEST,"Parent window requested size check")}const Ze=e=>c.inPageLinks.findTarget(te(e)),qe={init:dr,reset:hr,resize:Er,moveToAnchor:Ze,inPageLink:Ze,pageInfo:gr,parentInfo:mr,message:ur};function Ir(e){const{firstRun:t}=c,o=fr(e);switch(h(o),!0){case o in qe:qe[o](e);break;case(t&&Ht()):_(`Ignored message of type "${o}". Received before initialization.`);break;default:_(`Unexpected message (${e.data}), this is likely due to a newer version of iframe-resizer running on the parent page.`)}}const q=ge(e=>{yt(e)&&Ir(e)});function pr(){if("iframeChildListener"in window){_("Already setup");return}window.iframeChildListener=(t=>{setTimeout(()=>q({data:t,sameOrigin:!0}))}),h("listen"),N(window,n.MESSAGE,q),N(document,n.READY_STATE_CHANGE,Ne),Ne();function e(t){return q(t),c.win}try{top?.document?.getElementById("banner")&&(c.win={},window.mockMsgListener=e,Je(window,n.MESSAGE,q),typeof window.define=="function"&&window.define([],()=>e))}catch{}}typeof window!==n.UNDEFINED&&pr();
|
|
30
28
|
//# sourceMappingURL=index.cjs.js.map
|