1"use strict"; 2var IframeBridge = (() => { 3 var __defProp = Object.defineProperty; 4 var __getOwnPropDesc = Object.getOwnPropertyDescriptor; 5 var __getOwnPropNames = Object.getOwnPropertyNames; 6 var __getOwnPropSymbols = Object.getOwnPropertySymbols; 7 var __hasOwnProp = Object.prototype.hasOwnProperty; 8 var __propIsEnum = Object.prototype.propertyIsEnumerable; 9 var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value; 10 var __spreadValues = (a, b2) => { 11 for (var prop in b2 || (b2 = {})) 12 if (__hasOwnProp.call(b2, prop)) 13 __defNormalProp(a, prop, b2[prop]); 14 if (__getOwnPropSymbols) 15 for (var prop of __getOwnPropSymbols(b2)) { 16 if (__propIsEnum.call(b2, prop)) 17 __defNormalProp(a, prop, b2[prop]); 18 } 19 return a; 20 }; 21 var __export = (target, all) => { 22 for (var name in all) 23 __defProp(target, name, { get: all[name], enumerable: true }); 24 }; 25 var __copyProps = (to, from, except, desc) => { 26 if (from && typeof from === "object" || typeof from === "function") { 27 for (let key of __getOwnPropNames(from)) 28 if (!__hasOwnProp.call(to, key) && key !== except) 29 __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); 30 } 31 return to; 32 }; 33 var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); 34 35
35// src/index.ts 36 var index_exports = {}; 37 __export(index_exports, { 38 iFrameSetup: () => iFrameSetup 39 }); 40 41
vendor: 7,197 bytes, lines 41-254
41// node_modules/@open-iframe-resizer/core/dist/index.js 42 var p = () => typeof window < "u"; 43 var E = () => window.self !== window.top; 44 var b = (e) => e instanceof HTMLIFrameElement; 45 var M = (e) => { 46 window.document.readyState === "complete" ? e() : window.addEventListener("load", e); 47 }; 48 var T = (e, t) => { 49 t(), e.addEventListener("load", t); 50 }; 51 var C = (e, t) => { 52 var o, i; 53 const n = ((o = e.contentWindow) == null ? void 0 : o.document.readyState) === "complete"; 54 return e.src !== "about:blank" && ((i = e.contentWindow) == null ? void 0 : i.location.href) !== "about:blank" && n ? t() : e.addEventListener("load", t); 55 }; 56 var B = () => ({ offsetSize: 0, checkOrigin: true, enableLegacyLibSupport: false }); 57 var k = (e) => { 58 try { 59 return new URL(e.src).origin === window.location.origin; 60 } catch (e2) { 61 return false; 62 } 63 }; 64 var D = (e) => { 65 try { 66 const t = new URL(e.src).origin; 67 if (t !== "about:blank") 68 return t; 69 } catch (e2) { 70 } 71 return null; 72 }; 73 var W = (e) => (Object.keys(e).forEach((t) => e[t] === void 0 && delete e[t]), e); 74 var L = (e) => { 75 const { height: t, width: n } = e.getBoundingClientRect(); 76 return { height: Math.ceil(t), width: Math.ceil(n) }; 77 }; 78 var g = (e, t) => e ? t ? e.querySelector(t) : e.documentElement : null; 79 var I = (e, t) => { 80 e && (t.bodyPadding && (e.body.style.padding = t.bodyPadding), t.bodyMargin && (e.body.style.margin = t.bodyMargin)); 81 }; 82 var h = (e) => e <= 100 ? 100 : e <= 120 ? 1e3 : 1e4; 83 var A = () => "[iFrameSizer]ID:0:false:false:32:true:true::auto:::0:false:child:auto:true:::true:::false"; 84 function H(e) { 85 if (typeof e.data != "string" || !e.data.startsWith("[iFrameSizer]") || !e.data.endsWith("mutationObserver") && !e.data.endsWith("resizeObserver")) 86 return null; 87 const [t, n] = e.data.split(":"), r = +n; 88 return r > 0 ? r : null; 89 } 90 var z = q(); 91 var f = []; 92 var K = (e, t) => { 93 if (!p()) 94 return []; 95 const n = __spreadValues(__spreadValues({}, B()), W(e != null ? e : {})), r = P(t), o = x(n, r); 96 return r.map((i) => { 97 const s = { 98 iframe: i, 99 settings: n, 100 interactionState: { isHovered: false }, 101 initContext: { isInitialized: false, retryAttempts: 0 } 102 }, a = F(s, o); 103 return f.push(s), { 104 unsubscribe: () => { 105 a(), f = f.filter((d) => d.iframe !== i); 106 } 107 }; 108 }); 109 }; 110 function P(e) { 111 return typeof e == "string" ? Array.from(document.querySelectorAll(e)).filter(b) : e ? b(e) ? [e] : [] : Array.from(document.getElementsByTagName("iframe")); 112 } 113 function x(e, t) { 114 if (Array.isArray(e.checkOrigin)) 115 return e.checkOrigin; 116 if (!e.checkOrigin) 117 return []; 118 const n = []; 119 for (const r of t) { 120 const o = D(r); 121 o && n.push(o); 122 } 123 return n; 124 } 125 function F(e, t) { 126 const n = k(e.iframe) ? U(e) : N(e, t), r = $(e); 127 return () => { 128 n(), r(); 129 }; 130 } 131 function N(e, t) { 132 const { 133 iframe: n, 134 initContext: r, 135 settings: { checkOrigin: o, enableLegacyLibSupport: i, targetElementSelector: s, bodyPadding: a, bodyMargin: d } 136 } = e, u = (c) => { 137 var y; 138 const S = !o || t.includes(c.origin); 139 if (!(!(n.contentWindow === c.source) || !S)) { 140 if (((y = c.data) == null ? void 0 : y.type) === "iframe-resized") { 141 const { height: l } = c.data; 142 l && m({ newHeight: l, registeredElement: e }); 143 return; 144 } 145 if (i) { 146 const l = H(c); 147 l !== null && m({ newHeight: l, registeredElement: e }); 148 return; 149 } 150 } 151 }; 152 window.addEventListener("message", u); 153 const R = i ? A() : { type: "iframe-child-init", targetElementSelector: s, bodyPadding: a, bodyMargin: d }, w = () => { 154 T(n, () => { 155 var c; 156 return (c = n.contentWindow) == null ? void 0 : c.postMessage(R, "*"); 157 }), r.retryAttempts++, r.retryTimeoutId = window.setTimeout(w, h(r.retryAttempts)); 158 }; 159 return w(), () => window.removeEventListener("message", u); 160 } 161 function U(e) { 162 const { iframe: t, settings: n } = e, { targetElementSelector: r } = n; 163 let o = 0; 164 const i = () => { 165 const s = g(t.contentDocument, r); 166 if (!t.contentDocument || !s) 167 return o++, setTimeout(i, h(o)); 168 I(t.contentDocument, n), z().observe(s); 169 }; 170 return C(t, i), () => { 171 const s = g(t.contentDocument, r); 172 s && z().unobserve(s), t.removeEventListener("load", i); 173 }; 174 } 175 function $({ iframe: e, interactionState: t }) { 176 const n = () => { 177 t.isHovered = true; 178 }, r = () => { 179 t.isHovered = false; 180 }; 181 return e.addEventListener("mouseenter", n), e.addEventListener("mouseleave", r), () => { 182 e.removeEventListener("mouseenter", n), e.removeEventListener("mouseleave", r); 183 }; 184 } 185 function q() { 186 let e = null; 187 return () => { 188 if (!e) { 189 const t = ({ target: n }) => { 190 const r = f.find(({ iframe: d }) => d.contentDocument === n.ownerDocument); 191 if (!r) 192 return; 193 const { iframe: o, settings: i } = r, s = g(o.contentDocument, i.targetElementSelector); 194 if (!s) 195 return; 196 const { height: a } = L(s); 197 a && m({ newHeight: a, registeredElement: r }); 198 }; 199 e = new ResizeObserver((n) => n.forEach(t)); 200 } 201 return e; 202 }; 203 } 204 function m({ registeredElement: e, newHeight: t }) { 205 var u; 206 const { iframe: n, settings: r, interactionState: o, initContext: i } = e; 207 if (i.isInitialized || (i.isInitialized = true, clearTimeout(i.retryTimeoutId)), ((u = r.onBeforeIframeResize) == null ? void 0 : u.call(r, { iframe: n, settings: __spreadValues({}, r), observedHeight: t })) === false) 208 return; 209 const s = n.getBoundingClientRect(), a = t + r.offsetSize; 210 if (n.style.height = `${a}px`, !r.onIframeResize) 211 return; 212 const d = { 213 iframe: n, 214 settings: __spreadValues({}, r), 215 interactionState: __spreadValues({}, o), 216 previousRenderState: { rect: s }, 217 nextRenderState: { rect: n.getBoundingClientRect() } 218 }; 219 r.onIframeResize(d); 220 } 221 var V = G(); 222 var v = false; 223 _(); 224 function _() { 225 !p() || !E() || window.addEventListener("message", (e) => { 226 var t; 227 ((t = e.data) == null ? void 0 : t.type) === "iframe-child-init" && M(() => O(e)); 228 }); 229 } 230 function O(e, t = 0) { 231 const { targetElementSelector: n, bodyPadding: r, bodyMargin: o } = e.data, i = g(document, n); 232 if (v || window.parent !== e.source) 233 return; 234 if (!i) 235 return setTimeout(() => O(e, t + 1), h(t)); 236 I(document, { bodyMargin: o, bodyPadding: r }); 237 const s = V(); 238 s.disconnect(), s.observe(i), v = true; 239 } 240 function G() { 241 let e = null; 242 return () => (e || (e = new ResizeObserver((t) => { 243 if (!t[0].target) 244 return; 245 const { height: n, width: r } = L(t[0].target), o = { 246 type: "iframe-resized", 247 width: r, 248 height: n 249 }; 250 window.parent.postMessage(o, "*"); 251 })), e); 252 } 253 254
254// src/iframe-bridge.ts 255 var iframeRegistry = /* @__PURE__ */ new Map(); 256 var init = (iframe) => { 257 const iframeId = iframe.id; 258 K( 259 { 260 checkOrigin: false 261 }, 262 `#${iframeId}` 263 ); 264 iframeRegistry.set(iframeId, iframe); 265 }; 266 var initializeGlobalMessageHandler = () => { 267 if (window.__iframeBridgeHandlerInitialized) { 268 return; 269 } 270 window.addEventListener("message", (event) => { 271 var _a; 272 if (event.data && event.data.type === "get_viewport_info") { 273 let targetIframe = null; 274 for (const [_2, iframe] of iframeRegistry.entries()) { 275 if (iframe.contentWindow === event.source) { 276 targetIframe = iframe; 277 break; 278 } 279 } 280 if (!targetIframe && iframeRegistry.size > 0) { 281 const firstIframe = Array.from(iframeRegistry.values())[0]; 282 targetIframe = firstIframe || null; 283 } 284 if (targetIframe) { 285 const rect = targetIframe.getBoundingClientRect(); 286 const response = { 287 type: "viewport_info_response", 288 iframeTopInViewport: rect.top, 289 iframeLeftInViewport: rect.left, 290 viewportHeight: window.innerHeight, 291 viewportWidth: window.innerWidth, 292 scrollTop: window.scrollY, 293 scrollLeft: window.scrollX, 294 requestId: (_a = event.data.data) == null ? void 0 : _a.requestId 295 }; 296 if (event.source) { 297 event.source.postMessage(response, { targetOrigin: event.origin }); 298 } 299 } 300 } 301 }); 302 window.__iframeBridgeHandlerInitialized = true; 303 }; 304 var iFrameSetup = (iframe) => { 305 if (!iframe.id) { 306 iframe.id = `iframe-${Date.now()}-${Math.random().toString(36).substring(2, 11)}`; 307 } 308 initializeGlobalMessageHandler(); 309 init(iframe); 310 }; 311 if (typeof window !== "undefined") { 312 window.iFrameSetup = iFrameSetup; 313 } 314 return __toCommonJS(index_exports); 315})(); 316//# sourceMappingURL=iframe-bridge.umd.js.map
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.