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