@open-iframe-resizer/vue 1.6.0 → 1.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,19 +1,18 @@
1
- import { defineComponent as O, ref as k, onMounted as M, onBeforeUnmount as B, createElementBlock as P, openBlock as A, mergeProps as H } from "vue";
2
- const S = () => typeof window < "u", _ = () => window.self !== window.top, v = (e) => e instanceof HTMLIFrameElement, D = (e) => {
1
+ import { defineComponent as I, ref as O, onMounted as k, onBeforeUnmount as M, createElementBlock as B, openBlock as P, mergeProps as A } from "vue";
2
+ const v = () => typeof window < "u", H = () => window.self !== window.top, h = (e) => e instanceof HTMLIFrameElement, _ = (e) => {
3
3
  window.document.readyState === "complete" ? e() : window.addEventListener("load", e);
4
- }, T = (e, t) => {
4
+ }, D = (e, t) => {
5
5
  t(), e.addEventListener("load", t);
6
- }, x = (e, t) => {
7
- var n, r;
8
- const i = ((n = e.contentWindow) == null ? void 0 : n.document.readyState) === "complete";
9
- return e.src !== "about:blank" && ((r = e.contentWindow) == null ? void 0 : r.location.href) !== "about:blank" && i ? t() : e.addEventListener("load", t);
10
- }, C = () => ({ offsetSize: 0, checkOrigin: !0, enableLegacyLibSupport: !1 }), W = (e) => {
6
+ }, T = (e, t) => {
7
+ const n = e.contentWindow?.document.readyState === "complete";
8
+ return e.src !== "about:blank" && e.contentWindow?.location.href !== "about:blank" && n ? t() : e.addEventListener("load", t);
9
+ }, x = () => ({ offsetSize: 0, checkOrigin: !0, enableLegacyLibSupport: !1 }), C = (e) => {
11
10
  try {
12
11
  return new URL(e.src).origin === window.location.origin;
13
12
  } catch {
14
13
  return !1;
15
14
  }
16
- }, F = (e) => {
15
+ }, W = (e) => {
17
16
  try {
18
17
  const t = new URL(e.src).origin;
19
18
  if (t !== "about:blank")
@@ -21,55 +20,57 @@ const S = () => typeof window < "u", _ = () => window.self !== window.top, v = (
21
20
  } catch {
22
21
  }
23
22
  return null;
24
- }, $ = (e) => (Object.keys(e).forEach((t) => e[t] === void 0 && delete e[t]), e), E = (e) => {
23
+ }, F = (e) => (Object.keys(e).forEach((t) => {
24
+ e[t] === void 0 && delete e[t];
25
+ }), e), S = (e) => {
25
26
  const { height: t, width: n } = e.getBoundingClientRect();
26
27
  return { height: Math.ceil(t), width: Math.ceil(n) };
27
- }, m = (e, t) => e ? t ? e.querySelector(t) : e.documentElement : null, z = (e, t) => {
28
+ }, l = (e, t) => e ? t ? e.querySelector(t) : e.documentElement : null, E = (e, t) => {
28
29
  e && (t.bodyPadding && (e.body.style.padding = t.bodyPadding), t.bodyMargin && (e.body.style.margin = t.bodyMargin));
29
- }, b = (e) => e <= 100 ? 100 : e <= 120 ? 1e3 : 1e4, N = () => "[iFrameSizer]ID:0:false:false:32:true:true::auto:::0:false:child:auto:true:::true:::false";
30
- function U(e) {
30
+ }, g = (e) => e <= 100 ? 100 : e <= 120 ? 1e3 : 1e4, $ = () => "[iFrameSizer]ID:0:false:false:32:true:true::auto:::0:false:child:auto:true:::true:::false";
31
+ function N(e) {
31
32
  if (typeof e.data != "string" || !e.data.startsWith("[iFrameSizer]") || !e.data.endsWith("mutationObserver") && !e.data.endsWith("resizeObserver"))
32
33
  return null;
33
34
  const [t, n] = e.data.split(":"), r = +n;
34
35
  return r > 0 ? r : null;
35
36
  }
36
- const w = X();
37
+ const w = Q();
37
38
  let f = [];
38
- const j = (e, t) => {
39
- if (!S())
39
+ const U = (e, t) => {
40
+ if (!v())
40
41
  return [];
41
- const n = { ...C(), ...$(e ?? {}) }, r = q(t), i = G(n, r);
42
- return r.map((a) => {
42
+ const n = { ...x(), ...F(e ?? {}) }, r = j(t), a = q(n, r);
43
+ return r.map((i) => {
43
44
  const o = {
44
- iframe: a,
45
+ iframe: i,
45
46
  settings: n,
46
47
  interactionState: { isHovered: !1 },
47
48
  initContext: { isInitialized: !1, retryAttempts: 0 }
48
- }, s = K(o, i);
49
+ }, s = J(o, a);
49
50
  return f.push(o), {
50
51
  unsubscribe: () => {
51
- s(), f = f.filter((d) => d.iframe !== a);
52
+ s(), f = f.filter((c) => c.iframe !== i);
52
53
  }
53
54
  };
54
55
  });
55
56
  };
56
- function q(e) {
57
- return typeof e == "string" ? Array.from(document.querySelectorAll(e)).filter(v) : e ? v(e) ? [e] : [] : Array.from(document.getElementsByTagName("iframe"));
57
+ function j(e) {
58
+ return typeof e == "string" ? Array.from(document.querySelectorAll(e)).filter(h) : e ? h(e) ? [e] : [] : Array.from(document.getElementsByTagName("iframe"));
58
59
  }
59
- function G(e, t) {
60
+ function q(e, t) {
60
61
  if (Array.isArray(e.checkOrigin))
61
62
  return e.checkOrigin;
62
63
  if (!e.checkOrigin)
63
64
  return [];
64
65
  const n = [];
65
66
  for (const r of t) {
66
- const i = F(r);
67
- i && n.push(i);
67
+ const a = W(r);
68
+ a && n.push(a);
68
69
  }
69
70
  return n;
70
71
  }
71
- function K(e, t) {
72
- const n = W(e.iframe) ? J(e) : V(e, t), r = Q(e);
72
+ function J(e, t) {
73
+ const n = C(e.iframe) ? G(e) : V(e, t), r = K(e);
73
74
  return () => {
74
75
  n(), r();
75
76
  };
@@ -78,47 +79,43 @@ function V(e, t) {
78
79
  const {
79
80
  iframe: n,
80
81
  initContext: r,
81
- settings: { checkOrigin: i, enableLegacyLibSupport: a, targetElementSelector: o, bodyPadding: s, bodyMargin: d }
82
- } = e, l = (c) => {
83
- var h;
84
- const I = !i || t.includes(c.origin);
85
- if (!(n.contentWindow !== c.source || !I)) {
86
- if (((h = c.data) == null ? void 0 : h.type) === "iframe-resized") {
87
- const { height: u } = c.data;
88
- u && g({ newHeight: u, registeredElement: e });
82
+ settings: { checkOrigin: a, enableLegacyLibSupport: i, targetElementSelector: o, bodyPadding: s, bodyMargin: c }
83
+ } = e, b = (u) => {
84
+ const L = !a || t.includes(u.origin);
85
+ if (!(n.contentWindow !== u.source || !L)) {
86
+ if (u.data?.type === "iframe-resized") {
87
+ const { height: d } = u.data;
88
+ d && m({ newHeight: d, registeredElement: e });
89
89
  return;
90
90
  }
91
- if (a) {
92
- const u = U(c);
93
- u !== null && g({ newHeight: u, registeredElement: e });
91
+ if (i) {
92
+ const d = N(u);
93
+ d !== null && m({ newHeight: d, registeredElement: e });
94
94
  return;
95
95
  }
96
96
  }
97
97
  };
98
- window.addEventListener("message", l);
99
- const L = a ? N() : { type: "iframe-child-init", targetElementSelector: o, bodyPadding: s, bodyMargin: d }, y = () => {
100
- T(n, () => {
101
- var c;
102
- return (c = n.contentWindow) == null ? void 0 : c.postMessage(L, "*");
103
- }), r.retryAttempts++, r.retryTimeoutId = window.setTimeout(y, b(r.retryAttempts));
98
+ window.addEventListener("message", b);
99
+ const R = i ? $() : { type: "iframe-child-init", targetElementSelector: o, bodyPadding: s, bodyMargin: c }, y = () => {
100
+ D(n, () => n.contentWindow?.postMessage(R, "*")), r.retryAttempts++, r.retryTimeoutId = window.setTimeout(y, g(r.retryAttempts));
104
101
  };
105
- return y(), () => window.removeEventListener("message", l);
102
+ return y(), () => window.removeEventListener("message", b);
106
103
  }
107
- function J(e) {
104
+ function G(e) {
108
105
  const { iframe: t, settings: n } = e, { targetElementSelector: r } = n;
109
- let i = 0;
110
- const a = () => {
111
- const o = m(t.contentDocument, r);
106
+ let a = 0;
107
+ const i = () => {
108
+ const o = l(t.contentDocument, r);
112
109
  if (!t.contentDocument || !o)
113
- return i++, setTimeout(a, b(i));
114
- z(t.contentDocument, n), w().observe(o);
110
+ return a++, setTimeout(i, g(a));
111
+ E(t.contentDocument, n), w().observe(o);
115
112
  };
116
- return x(t, a), () => {
117
- const o = m(t.contentDocument, r);
118
- o && w().unobserve(o), t.removeEventListener("load", a);
113
+ return T(t, i), () => {
114
+ const o = l(t.contentDocument, r);
115
+ o && w().unobserve(o), t.removeEventListener("load", i);
119
116
  };
120
117
  }
121
- function Q({ iframe: e, interactionState: t }) {
118
+ function K({ iframe: e, interactionState: t }) {
122
119
  const n = () => {
123
120
  t.isHovered = !0;
124
121
  }, r = () => {
@@ -128,75 +125,73 @@ function Q({ iframe: e, interactionState: t }) {
128
125
  e.removeEventListener("mouseenter", n), e.removeEventListener("mouseleave", r);
129
126
  };
130
127
  }
131
- function X() {
128
+ function Q() {
132
129
  let e = null;
133
130
  return () => {
134
131
  if (!e) {
135
132
  const t = ({ target: n }) => {
136
- const r = f.find(({ iframe: d }) => d.contentDocument === n.ownerDocument);
133
+ const r = f.find(({ iframe: c }) => c.contentDocument === n.ownerDocument);
137
134
  if (!r)
138
135
  return;
139
- const { iframe: i, settings: a } = r, o = m(i.contentDocument, a.targetElementSelector);
136
+ const { iframe: a, settings: i } = r, o = l(a.contentDocument, i.targetElementSelector);
140
137
  if (!o)
141
138
  return;
142
- const { height: s } = E(o);
143
- s && g({ newHeight: s, registeredElement: r });
139
+ const { height: s } = S(o);
140
+ s && m({ newHeight: s, registeredElement: r });
144
141
  };
145
142
  e = new ResizeObserver((n) => n.forEach(t));
146
143
  }
147
144
  return e;
148
145
  };
149
146
  }
150
- function g({ registeredElement: e, newHeight: t }) {
151
- var n;
152
- const { iframe: r, settings: i, interactionState: a, initContext: o } = e;
153
- if (o.isInitialized || (o.isInitialized = !0, clearTimeout(o.retryTimeoutId)), ((n = i.onBeforeIframeResize) == null ? void 0 : n.call(i, { iframe: r, settings: { ...i }, observedHeight: t })) === !1)
147
+ function m({ registeredElement: e, newHeight: t }) {
148
+ const { iframe: n, settings: r, interactionState: a, initContext: i } = e;
149
+ if (i.isInitialized || (i.isInitialized = !0, clearTimeout(i.retryTimeoutId)), r.onBeforeIframeResize?.({ iframe: n, settings: { ...r }, observedHeight: t }) === !1)
154
150
  return;
155
- const s = r.getBoundingClientRect(), d = t + i.offsetSize;
156
- if (r.style.height = `${d}px`, !i.onIframeResize)
151
+ const o = n.getBoundingClientRect(), s = t + r.offsetSize;
152
+ if (n.style.height = `${s}px`, !r.onIframeResize)
157
153
  return;
158
- const l = {
159
- iframe: r,
160
- settings: { ...i },
154
+ const c = {
155
+ iframe: n,
156
+ settings: { ...r },
161
157
  interactionState: { ...a },
162
- previousRenderState: { rect: s },
163
- nextRenderState: { rect: r.getBoundingClientRect() }
158
+ previousRenderState: { rect: o },
159
+ nextRenderState: { rect: n.getBoundingClientRect() }
164
160
  };
165
- i.onIframeResize(l);
161
+ r.onIframeResize(c);
166
162
  }
167
- const Y = ee();
163
+ const X = Z();
168
164
  let p = !1;
169
- Z();
170
- function Z() {
171
- !S() || !_() || window.addEventListener("message", (e) => {
172
- var t;
173
- ((t = e.data) == null ? void 0 : t.type) === "iframe-child-init" && D(() => R(e));
165
+ Y();
166
+ function Y() {
167
+ !v() || !H() || window.addEventListener("message", (e) => {
168
+ e.data?.type === "iframe-child-init" && _(() => z(e));
174
169
  });
175
170
  }
176
- function R(e, t = 0) {
177
- const { targetElementSelector: n, bodyPadding: r, bodyMargin: i } = e.data, a = m(document, n);
171
+ function z(e, t = 0) {
172
+ const { targetElementSelector: n, bodyPadding: r, bodyMargin: a } = e.data, i = l(document, n);
178
173
  if (p || window.parent !== e.source)
179
174
  return;
180
- if (!a)
181
- return setTimeout(() => R(e, t + 1), b(t));
182
- z(document, { bodyMargin: i, bodyPadding: r });
183
- const o = Y();
184
- o.disconnect(), o.observe(a), p = !0;
175
+ if (!i)
176
+ return setTimeout(() => z(e, t + 1), g(t));
177
+ E(document, { bodyMargin: a, bodyPadding: r });
178
+ const o = X();
179
+ o.disconnect(), o.observe(i), p = !0;
185
180
  }
186
- function ee() {
181
+ function Z() {
187
182
  let e = null;
188
183
  return () => (e || (e = new ResizeObserver((t) => {
189
184
  if (!t[0].target)
190
185
  return;
191
- const { height: n, width: r } = E(t[0].target), i = {
186
+ const { height: n, width: r } = S(t[0].target), a = {
192
187
  type: "iframe-resized",
193
188
  width: r,
194
189
  height: n
195
190
  };
196
- window.parent.postMessage(i, "*");
191
+ window.parent.postMessage(a, "*");
197
192
  })), e);
198
193
  }
199
- const te = O({
194
+ const ee = I({
200
195
  name: "ResizableIframe",
201
196
  props: {
202
197
  offsetSize: [String, Number, Object],
@@ -209,9 +204,9 @@ const te = O({
209
204
  enableLegacyLibSupport: Boolean
210
205
  },
211
206
  setup(e, { attrs: t }) {
212
- const n = k(null);
207
+ const n = O(null);
213
208
  let r = [];
214
- const i = (a) => {
209
+ const a = (i) => {
215
210
  const o = {
216
211
  offsetSize: e.offsetSize,
217
212
  enableLegacyLibSupport: e.enableLegacyLibSupport,
@@ -224,32 +219,34 @@ const te = O({
224
219
  };
225
220
  Object.keys(o).forEach((s) => {
226
221
  o[s] === void 0 && delete o[s];
227
- }), r = j(o, a);
222
+ }), r = U(o, i);
228
223
  };
229
- return M(() => {
230
- n.value && i(n.value);
231
- }), B(() => {
232
- r.forEach((a) => a.unsubscribe()), r = [];
224
+ return k(() => {
225
+ n.value && a(n.value);
226
+ }), M(() => {
227
+ r.forEach((i) => {
228
+ i.unsubscribe();
229
+ }), r = [];
233
230
  }), {
234
231
  iframeRef: n,
235
232
  attrs: t
236
233
  };
237
234
  }
238
- }), ne = (e, t) => {
235
+ }), te = (e, t) => {
239
236
  const n = e.__vccOpts || e;
240
- for (const [r, i] of t)
241
- n[r] = i;
237
+ for (const [r, a] of t)
238
+ n[r] = a;
242
239
  return n;
243
240
  };
244
- function re(e, t, n, r, i, a) {
245
- return A(), P("iframe", H({ ref: "iframeRef" }, e.$attrs), null, 16);
241
+ function ne(e, t, n, r, a, i) {
242
+ return P(), B("iframe", A({ ref: "iframeRef" }, e.$attrs), null, 16);
246
243
  }
247
- const ie = /* @__PURE__ */ ne(te, [["render", re]]), ae = {
244
+ const re = /* @__PURE__ */ te(ee, [["render", ne]]), oe = {
248
245
  install(e) {
249
- e.component("IframeResizer", ie);
246
+ e.component("IframeResizer", re);
250
247
  }
251
248
  };
252
249
  export {
253
- ie as IframeResizer,
254
- ae as IframeResizerPlugin
250
+ re as IframeResizer,
251
+ oe as IframeResizerPlugin
255
252
  };
@@ -1 +1 @@
1
- (function(d,s){typeof exports=="object"&&typeof module<"u"?s(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],s):(d=typeof globalThis<"u"?globalThis:d||self,s(d["open-iframe-resizer-vue"]={},d.Vue))})(this,function(d,s){"use strict";const v=()=>typeof window<"u",M=()=>window.self!==window.top,p=e=>e instanceof HTMLIFrameElement,k=e=>{window.document.readyState==="complete"?e():window.addEventListener("load",e)},B=(e,t)=>{t(),e.addEventListener("load",t)},P=(e,t)=>{var n,r;const i=((n=e.contentWindow)==null?void 0:n.document.readyState)==="complete";return e.src!=="about:blank"&&((r=e.contentWindow)==null?void 0:r.location.href)!=="about:blank"&&i?t():e.addEventListener("load",t)},T=()=>({offsetSize:0,checkOrigin:!0,enableLegacyLibSupport:!1}),A=e=>{try{return new URL(e.src).origin===window.location.origin}catch{return!1}},H=e=>{try{const t=new URL(e.src).origin;if(t!=="about:blank")return t}catch{}return null},_=e=>(Object.keys(e).forEach(t=>e[t]===void 0&&delete e[t]),e),w=e=>{const{height:t,width:n}=e.getBoundingClientRect();return{height:Math.ceil(t),width:Math.ceil(n)}},m=(e,t)=>e?t?e.querySelector(t):e.documentElement:null,S=(e,t)=>{e&&(t.bodyPadding&&(e.body.style.padding=t.bodyPadding),t.bodyMargin&&(e.body.style.margin=t.bodyMargin))},b=e=>e<=100?100:e<=120?1e3:1e4,D=()=>"[iFrameSizer]ID:0:false:false:32:true:true::auto:::0:false:child:auto:true:::true:::false";function x(e){if(typeof e.data!="string"||!e.data.startsWith("[iFrameSizer]")||!e.data.endsWith("mutationObserver")&&!e.data.endsWith("resizeObserver"))return null;const[t,n]=e.data.split(":"),r=+n;return r>0?r:null}const z=U();let g=[];const C=(e,t)=>{if(!v())return[];const n={...T(),..._(e??{})},r=W(t),i=F(n,r);return r.map(a=>{const o={iframe:a,settings:n,interactionState:{isHovered:!1},initContext:{isInitialized:!1,retryAttempts:0}},c=$(o,i);return g.push(o),{unsubscribe:()=>{c(),g=g.filter(l=>l.iframe!==a)}}})};function W(e){return typeof e=="string"?Array.from(document.querySelectorAll(e)).filter(p):e?p(e)?[e]:[]:Array.from(document.getElementsByTagName("iframe"))}function F(e,t){if(Array.isArray(e.checkOrigin))return e.checkOrigin;if(!e.checkOrigin)return[];const n=[];for(const r of t){const i=H(r);i&&n.push(i)}return n}function $(e,t){const n=A(e.iframe)?N(e):j(e,t),r=q(e);return()=>{n(),r()}}function j(e,t){const{iframe:n,initContext:r,settings:{checkOrigin:i,enableLegacyLibSupport:a,targetElementSelector:o,bodyPadding:c,bodyMargin:l}}=e,y=u=>{var O;const ee=!i||t.includes(u.origin);if(!(n.contentWindow!==u.source||!ee)){if(((O=u.data)==null?void 0:O.type)==="iframe-resized"){const{height:f}=u.data;f&&h({newHeight:f,registeredElement:e});return}if(a){const f=x(u);f!==null&&h({newHeight:f,registeredElement:e});return}}};window.addEventListener("message",y);const Z=a?D():{type:"iframe-child-init",targetElementSelector:o,bodyPadding:c,bodyMargin:l},I=()=>{B(n,()=>{var u;return(u=n.contentWindow)==null?void 0:u.postMessage(Z,"*")}),r.retryAttempts++,r.retryTimeoutId=window.setTimeout(I,b(r.retryAttempts))};return I(),()=>window.removeEventListener("message",y)}function N(e){const{iframe:t,settings:n}=e,{targetElementSelector:r}=n;let i=0;const a=()=>{const o=m(t.contentDocument,r);if(!t.contentDocument||!o)return i++,setTimeout(a,b(i));S(t.contentDocument,n),z().observe(o)};return P(t,a),()=>{const o=m(t.contentDocument,r);o&&z().unobserve(o),t.removeEventListener("load",a)}}function q({iframe:e,interactionState:t}){const n=()=>{t.isHovered=!0},r=()=>{t.isHovered=!1};return e.addEventListener("mouseenter",n),e.addEventListener("mouseleave",r),()=>{e.removeEventListener("mouseenter",n),e.removeEventListener("mouseleave",r)}}function U(){let e=null;return()=>{if(!e){const t=({target:n})=>{const r=g.find(({iframe:l})=>l.contentDocument===n.ownerDocument);if(!r)return;const{iframe:i,settings:a}=r,o=m(i.contentDocument,a.targetElementSelector);if(!o)return;const{height:c}=w(o);c&&h({newHeight:c,registeredElement:r})};e=new ResizeObserver(n=>n.forEach(t))}return e}}function h({registeredElement:e,newHeight:t}){var n;const{iframe:r,settings:i,interactionState:a,initContext:o}=e;if(o.isInitialized||(o.isInitialized=!0,clearTimeout(o.retryTimeoutId)),((n=i.onBeforeIframeResize)==null?void 0:n.call(i,{iframe:r,settings:{...i},observedHeight:t}))===!1)return;const c=r.getBoundingClientRect(),l=t+i.offsetSize;if(r.style.height=`${l}px`,!i.onIframeResize)return;const y={iframe:r,settings:{...i},interactionState:{...a},previousRenderState:{rect:c},nextRenderState:{rect:r.getBoundingClientRect()}};i.onIframeResize(y)}const V=K();let E=!1;G();function G(){!v()||!M()||window.addEventListener("message",e=>{var t;((t=e.data)==null?void 0:t.type)==="iframe-child-init"&&k(()=>R(e))})}function R(e,t=0){const{targetElementSelector:n,bodyPadding:r,bodyMargin:i}=e.data,a=m(document,n);if(E||window.parent!==e.source)return;if(!a)return setTimeout(()=>R(e,t+1),b(t));S(document,{bodyMargin:i,bodyPadding:r});const o=V();o.disconnect(),o.observe(a),E=!0}function K(){let e=null;return()=>(e||(e=new ResizeObserver(t=>{if(!t[0].target)return;const{height:n,width:r}=w(t[0].target),i={type:"iframe-resized",width:r,height:n};window.parent.postMessage(i,"*")})),e)}const J=s.defineComponent({name:"ResizableIframe",props:{offsetSize:[String,Number,Object],checkOrigin:[Boolean,Array],onIframeResize:Function,onBeforeIframeResize:Function,targetElementSelector:[String],bodyMargin:[String,Number],bodyPadding:[String,Number],enableLegacyLibSupport:Boolean},setup(e,{attrs:t}){const n=s.ref(null);let r=[];const i=a=>{const o={offsetSize:e.offsetSize,enableLegacyLibSupport:e.enableLegacyLibSupport,checkOrigin:e.checkOrigin,onIframeResize:e.onIframeResize,onBeforeIframeResize:e.onBeforeIframeResize,targetElementSelector:e.targetElementSelector,bodyMargin:e.bodyMargin,bodyPadding:e.bodyPadding};Object.keys(o).forEach(c=>{o[c]===void 0&&delete o[c]}),r=C(o,a)};return s.onMounted(()=>{n.value&&i(n.value)}),s.onBeforeUnmount(()=>{r.forEach(a=>a.unsubscribe()),r=[]}),{iframeRef:n,attrs:t}}}),Q=(e,t)=>{const n=e.__vccOpts||e;for(const[r,i]of t)n[r]=i;return n};function X(e,t,n,r,i,a){return s.openBlock(),s.createElementBlock("iframe",s.mergeProps({ref:"iframeRef"},e.$attrs),null,16)}const L=Q(J,[["render",X]]),Y={install(e){e.component("IframeResizer",L)}};d.IframeResizer=L,d.IframeResizerPlugin=Y,Object.defineProperty(d,Symbol.toStringTag,{value:"Module"})});
1
+ (function(u,a){typeof exports=="object"&&typeof module<"u"?a(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],a):(u=typeof globalThis<"u"?globalThis:u||self,a(u["open-iframe-resizer-vue"]={},u.Vue))})(this,function(u,a){"use strict";const h=()=>typeof window<"u",O=()=>window.self!==window.top,p=e=>e instanceof HTMLIFrameElement,M=e=>{window.document.readyState==="complete"?e():window.addEventListener("load",e)},k=(e,t)=>{t(),e.addEventListener("load",t)},B=(e,t)=>{const n=e.contentWindow?.document.readyState==="complete";return e.src!=="about:blank"&&e.contentWindow?.location.href!=="about:blank"&&n?t():e.addEventListener("load",t)},P=()=>({offsetSize:0,checkOrigin:!0,enableLegacyLibSupport:!1}),T=e=>{try{return new URL(e.src).origin===window.location.origin}catch{return!1}},A=e=>{try{const t=new URL(e.src).origin;if(t!=="about:blank")return t}catch{}return null},H=e=>(Object.keys(e).forEach(t=>{e[t]===void 0&&delete e[t]}),e),w=e=>{const{height:t,width:n}=e.getBoundingClientRect();return{height:Math.ceil(t),width:Math.ceil(n)}},m=(e,t)=>e?t?e.querySelector(t):e.documentElement:null,S=(e,t)=>{e&&(t.bodyPadding&&(e.body.style.padding=t.bodyPadding),t.bodyMargin&&(e.body.style.margin=t.bodyMargin))},y=e=>e<=100?100:e<=120?1e3:1e4,_=()=>"[iFrameSizer]ID:0:false:false:32:true:true::auto:::0:false:child:auto:true:::true:::false";function D(e){if(typeof e.data!="string"||!e.data.startsWith("[iFrameSizer]")||!e.data.endsWith("mutationObserver")&&!e.data.endsWith("resizeObserver"))return null;const[t,n]=e.data.split(":"),r=+n;return r>0?r:null}const v=q();let g=[];const x=(e,t)=>{if(!h())return[];const n={...P(),...H(e??{})},r=C(t),s=W(n,r);return r.map(i=>{const o={iframe:i,settings:n,interactionState:{isHovered:!1},initContext:{isInitialized:!1,retryAttempts:0}},c=F(o,s);return g.push(o),{unsubscribe:()=>{c(),g=g.filter(d=>d.iframe!==i)}}})};function C(e){return typeof e=="string"?Array.from(document.querySelectorAll(e)).filter(p):e?p(e)?[e]:[]:Array.from(document.getElementsByTagName("iframe"))}function W(e,t){if(Array.isArray(e.checkOrigin))return e.checkOrigin;if(!e.checkOrigin)return[];const n=[];for(const r of t){const s=A(r);s&&n.push(s)}return n}function F(e,t){const n=T(e.iframe)?j(e):$(e,t),r=N(e);return()=>{n(),r()}}function $(e,t){const{iframe:n,initContext:r,settings:{checkOrigin:s,enableLegacyLibSupport:i,targetElementSelector:o,bodyPadding:c,bodyMargin:d}}=e,L=f=>{const Z=!s||t.includes(f.origin);if(!(n.contentWindow!==f.source||!Z)){if(f.data?.type==="iframe-resized"){const{height:l}=f.data;l&&b({newHeight:l,registeredElement:e});return}if(i){const l=D(f);l!==null&&b({newHeight:l,registeredElement:e});return}}};window.addEventListener("message",L);const Y=i?_():{type:"iframe-child-init",targetElementSelector:o,bodyPadding:c,bodyMargin:d},I=()=>{k(n,()=>n.contentWindow?.postMessage(Y,"*")),r.retryAttempts++,r.retryTimeoutId=window.setTimeout(I,y(r.retryAttempts))};return I(),()=>window.removeEventListener("message",L)}function j(e){const{iframe:t,settings:n}=e,{targetElementSelector:r}=n;let s=0;const i=()=>{const o=m(t.contentDocument,r);if(!t.contentDocument||!o)return s++,setTimeout(i,y(s));S(t.contentDocument,n),v().observe(o)};return B(t,i),()=>{const o=m(t.contentDocument,r);o&&v().unobserve(o),t.removeEventListener("load",i)}}function N({iframe:e,interactionState:t}){const n=()=>{t.isHovered=!0},r=()=>{t.isHovered=!1};return e.addEventListener("mouseenter",n),e.addEventListener("mouseleave",r),()=>{e.removeEventListener("mouseenter",n),e.removeEventListener("mouseleave",r)}}function q(){let e=null;return()=>{if(!e){const t=({target:n})=>{const r=g.find(({iframe:d})=>d.contentDocument===n.ownerDocument);if(!r)return;const{iframe:s,settings:i}=r,o=m(s.contentDocument,i.targetElementSelector);if(!o)return;const{height:c}=w(o);c&&b({newHeight:c,registeredElement:r})};e=new ResizeObserver(n=>n.forEach(t))}return e}}function b({registeredElement:e,newHeight:t}){const{iframe:n,settings:r,interactionState:s,initContext:i}=e;if(i.isInitialized||(i.isInitialized=!0,clearTimeout(i.retryTimeoutId)),r.onBeforeIframeResize?.({iframe:n,settings:{...r},observedHeight:t})===!1)return;const o=n.getBoundingClientRect(),c=t+r.offsetSize;if(n.style.height=`${c}px`,!r.onIframeResize)return;const d={iframe:n,settings:{...r},interactionState:{...s},previousRenderState:{rect:o},nextRenderState:{rect:n.getBoundingClientRect()}};r.onIframeResize(d)}const U=J();let z=!1;V();function V(){!h()||!O()||window.addEventListener("message",e=>{e.data?.type==="iframe-child-init"&&M(()=>E(e))})}function E(e,t=0){const{targetElementSelector:n,bodyPadding:r,bodyMargin:s}=e.data,i=m(document,n);if(z||window.parent!==e.source)return;if(!i)return setTimeout(()=>E(e,t+1),y(t));S(document,{bodyMargin:s,bodyPadding:r});const o=U();o.disconnect(),o.observe(i),z=!0}function J(){let e=null;return()=>(e||(e=new ResizeObserver(t=>{if(!t[0].target)return;const{height:n,width:r}=w(t[0].target),s={type:"iframe-resized",width:r,height:n};window.parent.postMessage(s,"*")})),e)}const G=a.defineComponent({name:"ResizableIframe",props:{offsetSize:[String,Number,Object],checkOrigin:[Boolean,Array],onIframeResize:Function,onBeforeIframeResize:Function,targetElementSelector:[String],bodyMargin:[String,Number],bodyPadding:[String,Number],enableLegacyLibSupport:Boolean},setup(e,{attrs:t}){const n=a.ref(null);let r=[];const s=i=>{const o={offsetSize:e.offsetSize,enableLegacyLibSupport:e.enableLegacyLibSupport,checkOrigin:e.checkOrigin,onIframeResize:e.onIframeResize,onBeforeIframeResize:e.onBeforeIframeResize,targetElementSelector:e.targetElementSelector,bodyMargin:e.bodyMargin,bodyPadding:e.bodyPadding};Object.keys(o).forEach(c=>{o[c]===void 0&&delete o[c]}),r=x(o,i)};return a.onMounted(()=>{n.value&&s(n.value)}),a.onBeforeUnmount(()=>{r.forEach(i=>{i.unsubscribe()}),r=[]}),{iframeRef:n,attrs:t}}}),K=(e,t)=>{const n=e.__vccOpts||e;for(const[r,s]of t)n[r]=s;return n};function Q(e,t,n,r,s,i){return a.openBlock(),a.createElementBlock("iframe",a.mergeProps({ref:"iframeRef"},e.$attrs),null,16)}const R=K(G,[["render",Q]]),X={install(e){e.component("IframeResizer",R)}};u.IframeResizer=R,u.IframeResizerPlugin=X,Object.defineProperty(u,Symbol.toStringTag,{value:"Module"})});
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@open-iframe-resizer/vue",
3
3
  "private": false,
4
- "version": "1.6.0",
4
+ "version": "1.6.1",
5
5
  "description": "Open-source modern iframe resizer component",
6
6
  "license": "MIT",
7
7
  "repository": {
@@ -43,13 +43,13 @@
43
43
  "test": "npx playwright install --with-deps && npx playwright test"
44
44
  },
45
45
  "dependencies": {
46
- "@open-iframe-resizer/core": "1.6.0"
46
+ "@open-iframe-resizer/core": "1.6.1"
47
47
  },
48
48
  "devDependencies": {
49
- "@vitejs/plugin-vue": "^5.2.3",
50
- "@vue/tsconfig": "^0.7.0",
51
- "vue": "^3.5.13",
52
- "vue-tsc": "^2.2.8"
49
+ "@vitejs/plugin-vue": "^6.0.1",
50
+ "@vue/tsconfig": "^0.8.1",
51
+ "vue": "^3.5.21",
52
+ "vue-tsc": "^3.0.7"
53
53
  },
54
54
  "peerDependencies": {
55
55
  "vue": ">=3.0.0"