@open-iframe-resizer/core 1.0.0-rc5 → 1.1.0
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/LICENSE.md +20 -20
- package/README.md +44 -6
- package/dist/common.d.ts +15 -8
- package/dist/compat.d.ts +2 -0
- package/dist/index.js +85 -53
- package/dist/index.umd.cjs +1 -1
- package/dist/type.d.ts +34 -8
- package/package.json +20 -6
package/LICENSE.md
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
Copyright (c) 2012-2024 Scott Chacon and others
|
|
2
|
-
|
|
3
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
|
4
|
-
a copy of this software and associated documentation files (the
|
|
5
|
-
"Software"), to deal in the Software without restriction, including
|
|
6
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
|
7
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
|
8
|
-
permit persons to whom the Software is furnished to do so, subject to
|
|
9
|
-
the following conditions:
|
|
10
|
-
|
|
11
|
-
The above copyright notice and this permission notice shall be
|
|
12
|
-
included in all copies or substantial portions of the Software.
|
|
13
|
-
|
|
14
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
15
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
16
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
17
|
-
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
18
|
-
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
19
|
-
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
20
|
-
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
1
|
+
Copyright (c) 2012-2024 Scott Chacon and others
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
4
|
+
a copy of this software and associated documentation files (the
|
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
9
|
+
the following conditions:
|
|
10
|
+
|
|
11
|
+
The above copyright notice and this permission notice shall be
|
|
12
|
+
included in all copies or substantial portions of the Software.
|
|
13
|
+
|
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,18 +1,56 @@
|
|
|
1
|
-
# Open Iframe Resizer
|
|
1
|
+
# Open Iframe Resizer
|
|
2
2
|
|
|
3
3
|
## Overview
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
A modern, lightweight alternative for resizing iframes dynamically. It is shipped under the MIT license, making it usable in commercial projects.
|
|
6
|
+
|
|
7
|
+
If you found this plugin helpful, please consider starring the repository!
|
|
6
8
|
|
|
7
9
|
## Getting Started
|
|
8
10
|
|
|
9
|
-
### Browser
|
|
10
|
-
#### ES6 Modules
|
|
11
|
+
### Browser (ES6 modules)
|
|
11
12
|
|
|
12
13
|
```html
|
|
13
14
|
<script type="module">
|
|
14
|
-
import { initialize } from "/dist/index.js";
|
|
15
|
+
import { initialize } from "https://cdn.jsdelivr.net/npm/@open-iframe-resizer/core@latest/dist/index.js";
|
|
15
16
|
|
|
16
|
-
initialize({}, "#iframe
|
|
17
|
+
initialize({}, "#my-iframe");
|
|
17
18
|
</script>
|
|
18
19
|
```
|
|
20
|
+
|
|
21
|
+
You can found a working example [here](https://codesandbox.io/p/sandbox/open-iframe-resize-browser-m655zt)
|
|
22
|
+
|
|
23
|
+
### Package
|
|
24
|
+
Note you can also install the core package through [npm](https://www.npmjs.com/package/@open-iframe-resizer/core):
|
|
25
|
+
```bash
|
|
26
|
+
npm install @open-iframe-resizer/core
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
### React
|
|
30
|
+
A React component is also available:
|
|
31
|
+
```bash
|
|
32
|
+
npm install @open-iframe-resizer/react
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## Notes
|
|
36
|
+
|
|
37
|
+
### Comparison with iframe-resizer
|
|
38
|
+
This library is very good, but it has changed its license, so it is no longer usable in closed-source projects for free.
|
|
39
|
+
I decided to replicate some parts of the API, as it may facilitate migration to this project.
|
|
40
|
+
|
|
41
|
+
Some features from this library are missing, but they could be implemented in future versions.
|
|
42
|
+
|
|
43
|
+
### Resize iframes from a different origin
|
|
44
|
+
- If you have control over the embedded page, you need to load the script on your child page to enable messaging between the two windows (you do not need to call the initialize function in the child; loading the module is sufficient).
|
|
45
|
+
|
|
46
|
+
- If you have no control over the child iframe domain, and, by chance, the child page loads the legacy *iframe-resizer* script, you can initialize the library with the compatibility mode; it will try to connect to the child iframe:
|
|
47
|
+
|
|
48
|
+
```javascript
|
|
49
|
+
initialize({ enableLegacyLibSupport: true }, "#my-iframe");
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
## Browser support
|
|
53
|
+
|
|
54
|
+
| Chrome | Safari | Firefox | Opera | IE |
|
|
55
|
+
|--------|--------|---------|-------|-----------|
|
|
56
|
+
| 64+ | 13.1+ | 69+ | 51+ | 🙅♂️ |
|
package/dist/common.d.ts
CHANGED
|
@@ -1,11 +1,18 @@
|
|
|
1
1
|
import { Settings } from './type';
|
|
2
|
-
declare const isInIframe: () => boolean;
|
|
3
|
-
declare const isSameOriginIframe: (iframe: HTMLIFrameElement) => iframe is HTMLIFrameElement & {
|
|
2
|
+
export declare const isInIframe: () => boolean;
|
|
3
|
+
export declare const isSameOriginIframe: (iframe: HTMLIFrameElement) => iframe is HTMLIFrameElement & {
|
|
4
4
|
contentDocument: Document;
|
|
5
5
|
};
|
|
6
|
-
declare const isHtmlIframeElement: (element: Element) => element is HTMLIFrameElement;
|
|
7
|
-
declare const
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
export
|
|
6
|
+
export declare const isHtmlIframeElement: (element: Element) => element is HTMLIFrameElement;
|
|
7
|
+
export declare const deferWhenWindowIsLoaded: (_window: Window, executable: () => void) => void;
|
|
8
|
+
/**
|
|
9
|
+
* Post the message twice, it assures the target to receive the message at least once
|
|
10
|
+
*/
|
|
11
|
+
export declare const safePostMessageToCrossOriginIframe: (iframe: HTMLIFrameElement, executable: () => void) => void;
|
|
12
|
+
export declare const deferWhenSameOriginIframeIsLoaded: (iframe: HTMLIFrameElement, executable: () => void) => void;
|
|
13
|
+
export declare const getDefaultSettings: () => Settings;
|
|
14
|
+
export declare const isIframeSameOrigin: (iframe: HTMLIFrameElement) => boolean;
|
|
15
|
+
export declare const extractIframeOrigin: (iframe: HTMLIFrameElement) => string | null;
|
|
16
|
+
export declare const removeUndefinedProperties: <T extends {
|
|
17
|
+
[key: string]: unknown;
|
|
18
|
+
}>(object: T) => T;
|
package/dist/compat.d.ts
ADDED
package/dist/index.js
CHANGED
|
@@ -1,96 +1,128 @@
|
|
|
1
|
-
const
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
},
|
|
1
|
+
const h = () => window && window.self !== window.top, f = (e) => e instanceof HTMLIFrameElement, b = (e, n) => {
|
|
2
|
+
e.document.readyState === "complete" ? n() : e.addEventListener("load", n);
|
|
3
|
+
}, w = (e, n) => {
|
|
4
|
+
n(), e.addEventListener("load", n);
|
|
5
|
+
}, L = (e, n) => {
|
|
6
|
+
var r, o;
|
|
7
|
+
const t = ((r = e.contentWindow) == null ? void 0 : r.document.readyState) === "complete";
|
|
8
|
+
return e.src !== "about:blank" && ((o = e.contentWindow) == null ? void 0 : o.location.href) !== "about:blank" && t ? n() : e.addEventListener("load", n);
|
|
9
|
+
}, y = () => ({ offsetSize: 0, checkOrigin: !0, enableLegacyLibSupport: !1 }), p = (e) => {
|
|
6
10
|
try {
|
|
7
11
|
return new URL(e.src, window.location.origin).origin === window.location.origin;
|
|
8
12
|
} catch {
|
|
9
13
|
return !1;
|
|
10
14
|
}
|
|
11
|
-
},
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
+
}, m = (e) => {
|
|
16
|
+
try {
|
|
17
|
+
const n = new URL(e.src).origin;
|
|
18
|
+
if (n !== "about:blank")
|
|
19
|
+
return n;
|
|
20
|
+
} catch {
|
|
21
|
+
}
|
|
22
|
+
return null;
|
|
23
|
+
}, O = (e) => (Object.keys(e).forEach((n) => e[n] === void 0 && delete e[n]), e);
|
|
24
|
+
function z(e) {
|
|
25
|
+
w(
|
|
26
|
+
e,
|
|
27
|
+
() => {
|
|
28
|
+
var n;
|
|
29
|
+
return (n = e.contentWindow) == null ? void 0 : n.postMessage(
|
|
30
|
+
"[iFrameSizer]ID:0:false:false:32:true:true::auto:::0:false:child:auto:true:::true:::false",
|
|
31
|
+
m(e) ?? "*"
|
|
32
|
+
);
|
|
33
|
+
}
|
|
34
|
+
);
|
|
35
|
+
}
|
|
36
|
+
function I(e) {
|
|
37
|
+
if (typeof e.data == "string" && e.data.startsWith("[iFrameSizer]")) {
|
|
38
|
+
const [n, t] = e.data.split(":");
|
|
39
|
+
return +t;
|
|
40
|
+
}
|
|
41
|
+
return null;
|
|
42
|
+
}
|
|
43
|
+
const g = W(), d = [], D = (e, n) => {
|
|
44
|
+
const t = { ...y(), ...O(e ?? {}) }, i = v(n), r = S(t, i);
|
|
45
|
+
return i.map((o) => {
|
|
46
|
+
const c = d.push({ iframe: o, settings: t }), s = E(o, t, r);
|
|
15
47
|
return {
|
|
16
48
|
unsubscribe: () => {
|
|
17
|
-
|
|
49
|
+
s(), d.splice(c - 1, 1);
|
|
18
50
|
}
|
|
19
51
|
};
|
|
20
52
|
});
|
|
21
53
|
};
|
|
22
|
-
function
|
|
23
|
-
return typeof e == "string" ? Array.from(document.querySelectorAll(e)).filter(
|
|
54
|
+
function v(e) {
|
|
55
|
+
return typeof e == "string" ? Array.from(document.querySelectorAll(e)).filter(f) : e ? f(e) ? [e] : [] : Array.from(document.getElementsByTagName("iframe"));
|
|
24
56
|
}
|
|
25
|
-
function
|
|
57
|
+
function S(e, n) {
|
|
26
58
|
if (Array.isArray(e.checkOrigin))
|
|
27
59
|
return e.checkOrigin;
|
|
28
60
|
if (!e.checkOrigin)
|
|
29
61
|
return [];
|
|
30
62
|
const t = [];
|
|
31
|
-
for (const
|
|
32
|
-
const
|
|
33
|
-
|
|
63
|
+
for (const i of n) {
|
|
64
|
+
const r = m(i);
|
|
65
|
+
r && t.push(r);
|
|
34
66
|
}
|
|
35
67
|
return t;
|
|
36
68
|
}
|
|
37
|
-
function
|
|
38
|
-
|
|
39
|
-
const n = new URL(e.src).origin;
|
|
40
|
-
if (n !== "about:blank")
|
|
41
|
-
return n;
|
|
42
|
-
} catch {
|
|
43
|
-
}
|
|
44
|
-
return null;
|
|
45
|
-
}
|
|
46
|
-
function z(e, n, t) {
|
|
47
|
-
return b(e) ? p(e) : L(e, n, t);
|
|
69
|
+
function E(e, n, t) {
|
|
70
|
+
return p(e) ? k(e) : R(e, n, t);
|
|
48
71
|
}
|
|
49
|
-
function
|
|
50
|
-
const
|
|
72
|
+
function R(e, n, t) {
|
|
73
|
+
const i = (r) => {
|
|
51
74
|
var s;
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
75
|
+
const o = !n.checkOrigin || t.includes(r.origin);
|
|
76
|
+
if (!(!(e.contentWindow === r.source) || !o)) {
|
|
77
|
+
if (((s = r.data) == null ? void 0 : s.type) === "iframe-resized") {
|
|
78
|
+
const { height: a } = r.data;
|
|
79
|
+
u({ height: a, iframe: e, settings: n });
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
if (n.enableLegacyLibSupport) {
|
|
83
|
+
const a = I(r);
|
|
84
|
+
a !== null && u({ height: a, iframe: e, settings: n });
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
55
87
|
}
|
|
56
88
|
};
|
|
57
|
-
return window.addEventListener("message",
|
|
89
|
+
return window.addEventListener("message", i), n.enableLegacyLibSupport && z(e), () => window.removeEventListener("message", i);
|
|
58
90
|
}
|
|
59
|
-
function
|
|
91
|
+
function k(e) {
|
|
60
92
|
const n = () => {
|
|
61
|
-
var
|
|
62
|
-
const t = (
|
|
93
|
+
var i;
|
|
94
|
+
const t = (i = e.contentDocument) == null ? void 0 : i.body;
|
|
63
95
|
if (!t) {
|
|
64
96
|
console.error("Unable to observe the iframe content document body");
|
|
65
97
|
return;
|
|
66
98
|
}
|
|
67
|
-
|
|
99
|
+
g.observe(t);
|
|
68
100
|
};
|
|
69
|
-
return
|
|
101
|
+
return L(e, n), () => {
|
|
70
102
|
var t;
|
|
71
|
-
(t = e.contentDocument) != null && t.body &&
|
|
103
|
+
(t = e.contentDocument) != null && t.body && g.unobserve(e.contentDocument.body), e.removeEventListener("load", n);
|
|
72
104
|
};
|
|
73
105
|
}
|
|
74
|
-
function
|
|
106
|
+
function W() {
|
|
75
107
|
const e = ({ target: n }) => {
|
|
76
|
-
var
|
|
77
|
-
const t =
|
|
78
|
-
var
|
|
79
|
-
return ((
|
|
108
|
+
var s;
|
|
109
|
+
const t = d.find((a) => {
|
|
110
|
+
var l;
|
|
111
|
+
return ((l = a.iframe.contentDocument) == null ? void 0 : l.body) === n;
|
|
80
112
|
});
|
|
81
113
|
if (!t)
|
|
82
114
|
return;
|
|
83
|
-
const { iframe:
|
|
84
|
-
o !== void 0 &&
|
|
115
|
+
const { iframe: i, settings: r } = t, { scrollHeight: o, scrollWidth: c } = ((s = i.contentDocument) == null ? void 0 : s.documentElement) ?? {};
|
|
116
|
+
o !== void 0 && c !== void 0 && u({ height: o, iframe: i, settings: r });
|
|
85
117
|
};
|
|
86
118
|
return new ResizeObserver((n) => n.forEach(e));
|
|
87
119
|
}
|
|
88
|
-
function
|
|
89
|
-
n.style.height = `${e + t.offsetSize}px`;
|
|
120
|
+
function u({ height: e, iframe: n, settings: t }) {
|
|
121
|
+
n.style.height = `${e + t.offsetSize + 1}px`;
|
|
90
122
|
}
|
|
91
|
-
|
|
92
|
-
function
|
|
93
|
-
window
|
|
123
|
+
h() && C();
|
|
124
|
+
function C() {
|
|
125
|
+
b(window, () => {
|
|
94
126
|
const e = () => {
|
|
95
127
|
const t = {
|
|
96
128
|
type: "iframe-resized",
|
|
@@ -103,6 +135,6 @@ function E() {
|
|
|
103
135
|
});
|
|
104
136
|
}
|
|
105
137
|
export {
|
|
106
|
-
|
|
107
|
-
|
|
138
|
+
D as initialize,
|
|
139
|
+
C as initializeChildListener
|
|
108
140
|
};
|
package/dist/index.umd.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(s,
|
|
1
|
+
(function(s,d){typeof exports=="object"&&typeof module<"u"?d(exports):typeof define=="function"&&define.amd?define(["exports"],d):(s=typeof globalThis<"u"?globalThis:s||self,d(s.iframeResizer={}))})(this,function(s){"use strict";const d=()=>window&&window.self!==window.top,g=e=>e instanceof HTMLIFrameElement,p=(e,n)=>{e.document.readyState==="complete"?n():e.addEventListener("load",n)},L=(e,n)=>{n(),e.addEventListener("load",n)},w=(e,n)=>{var i,o;const t=((i=e.contentWindow)==null?void 0:i.document.readyState)==="complete";return e.src!=="about:blank"&&((o=e.contentWindow)==null?void 0:o.location.href)!=="about:blank"&&t?n():e.addEventListener("load",n)},O=()=>({offsetSize:0,checkOrigin:!0,enableLegacyLibSupport:!1}),z=e=>{try{return new URL(e.src,window.location.origin).origin===window.location.origin}catch{return!1}},m=e=>{try{const n=new URL(e.src).origin;if(n!=="about:blank")return n}catch{}return null},I=e=>(Object.keys(e).forEach(n=>e[n]===void 0&&delete e[n]),e);function v(e){L(e,()=>{var n;return(n=e.contentWindow)==null?void 0:n.postMessage("[iFrameSizer]ID:0:false:false:32:true:true::auto:::0:false:child:auto:true:::true:::false",m(e)??"*")})}function S(e){if(typeof e.data=="string"&&e.data.startsWith("[iFrameSizer]")){const[n,t]=e.data.split(":");return+t}return null}const h=D(),l=[],E=(e,n)=>{const t={...O(),...I(e??{})},r=R(n),i=k(t,r);return r.map(o=>{const u=l.push({iframe:o,settings:t}),a=W(o,t,i);return{unsubscribe:()=>{a(),l.splice(u-1,1)}}})};function R(e){return typeof e=="string"?Array.from(document.querySelectorAll(e)).filter(g):e?g(e)?[e]:[]:Array.from(document.getElementsByTagName("iframe"))}function k(e,n){if(Array.isArray(e.checkOrigin))return e.checkOrigin;if(!e.checkOrigin)return[];const t=[];for(const r of n){const i=m(r);i&&t.push(i)}return t}function W(e,n,t){return z(e)?T(e):C(e,n,t)}function C(e,n,t){const r=i=>{var a;const o=!n.checkOrigin||t.includes(i.origin);if(!(!(e.contentWindow===i.source)||!o)){if(((a=i.data)==null?void 0:a.type)==="iframe-resized"){const{height:c}=i.data;f({height:c,iframe:e,settings:n});return}if(n.enableLegacyLibSupport){const c=S(i);c!==null&&f({height:c,iframe:e,settings:n});return}}};return window.addEventListener("message",r),n.enableLegacyLibSupport&&v(e),()=>window.removeEventListener("message",r)}function T(e){const n=()=>{var r;const t=(r=e.contentDocument)==null?void 0:r.body;if(!t){console.error("Unable to observe the iframe content document body");return}h.observe(t)};return w(e,n),()=>{var t;(t=e.contentDocument)!=null&&t.body&&h.unobserve(e.contentDocument.body),e.removeEventListener("load",n)}}function D(){const e=({target:n})=>{var a;const t=l.find(c=>{var y;return((y=c.iframe.contentDocument)==null?void 0:y.body)===n});if(!t)return;const{iframe:r,settings:i}=t,{scrollHeight:o,scrollWidth:u}=((a=r.contentDocument)==null?void 0:a.documentElement)??{};o!==void 0&&u!==void 0&&f({height:o,iframe:r,settings:i})};return new ResizeObserver(n=>n.forEach(e))}function f({height:e,iframe:n,settings:t}){n.style.height=`${e+t.offsetSize+1}px`}d()&&b();function b(){p(window,()=>{const e=()=>{const t={type:"iframe-resized",width:document.documentElement.scrollWidth,height:document.documentElement.scrollHeight};window.parent.postMessage(t,"*")};new ResizeObserver(e).observe(document.body)})}s.initialize=E,s.initializeChildListener=b,Object.defineProperty(s,Symbol.toStringTag,{value:"Module"})});
|
package/dist/type.d.ts
CHANGED
|
@@ -1,21 +1,47 @@
|
|
|
1
1
|
interface Window {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
iframeResizer: {
|
|
3
|
+
initialize: InitializeFunction;
|
|
4
|
+
};
|
|
5
5
|
}
|
|
6
6
|
|
|
7
|
+
/**
|
|
8
|
+
* Automatically resizes the selected iframes.
|
|
9
|
+
* @param settings The settings for the selected iframes. The default settings properties are picked if empty.
|
|
10
|
+
* @param selector The selector for the iframe(s) or the HTMLIFrameElement to be resized. If empty, all document iframe elements will be selected.
|
|
11
|
+
* @returns A result array, which can be used to clean up the listeners if you often remove iframes from the document.
|
|
12
|
+
*/
|
|
7
13
|
export type InitializeFunction = (settings?: Partial<Settings>, selector?: string | HTMLIFrameElement) => InitializeResult[];
|
|
8
14
|
export type InitializeResult = { unsubscribe: () => void };
|
|
9
15
|
|
|
10
16
|
export type Settings = {
|
|
11
|
-
|
|
12
|
-
|
|
17
|
+
/**
|
|
18
|
+
* Offset added to the resize size (in pixels).
|
|
19
|
+
*
|
|
20
|
+
* Default: 0
|
|
21
|
+
*/
|
|
22
|
+
offsetSize: number;
|
|
23
|
+
/**
|
|
24
|
+
* Specifies whether to check the origin of incoming messages.
|
|
25
|
+
* Accepts an array of allowed origins or a boolean.
|
|
26
|
+
* If true, incoming messages are allowed from the origins of the registered iframes.
|
|
27
|
+
*
|
|
28
|
+
* Default: true
|
|
29
|
+
*/
|
|
30
|
+
checkOrigin: string[] | boolean;
|
|
31
|
+
/**
|
|
32
|
+
* Allows the library to communicate with a cross-origin child iframe
|
|
33
|
+
* containing the original "iframe-resizer" script.
|
|
34
|
+
* Useful if you do not control the child domain.
|
|
35
|
+
*
|
|
36
|
+
* Default: false
|
|
37
|
+
*/
|
|
38
|
+
enableLegacyLibSupport: boolean;
|
|
13
39
|
};
|
|
14
40
|
|
|
15
41
|
export type IframeResizeEventData = {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
42
|
+
type: "iframe-resized";
|
|
43
|
+
width: number;
|
|
44
|
+
height: number;
|
|
19
45
|
};
|
|
20
46
|
|
|
21
47
|
export type IframeResizeEvent = MessageEvent<IframeResizeEventData>;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@open-iframe-resizer/core",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.1.0",
|
|
5
5
|
"description": "Open-source modern iframe resizer",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"repository": {
|
|
@@ -11,7 +11,18 @@
|
|
|
11
11
|
"engines": {
|
|
12
12
|
"node": ">=20.0.0"
|
|
13
13
|
},
|
|
14
|
-
"keywords": [
|
|
14
|
+
"keywords": [
|
|
15
|
+
"iframe",
|
|
16
|
+
"Resizing",
|
|
17
|
+
"Resizer",
|
|
18
|
+
"resize",
|
|
19
|
+
"cross",
|
|
20
|
+
"same",
|
|
21
|
+
"domain",
|
|
22
|
+
"width",
|
|
23
|
+
"height",
|
|
24
|
+
"responsive"
|
|
25
|
+
],
|
|
15
26
|
"type": "module",
|
|
16
27
|
"main": "./dist/index.cjs",
|
|
17
28
|
"module": "./dist/index.js",
|
|
@@ -23,20 +34,23 @@
|
|
|
23
34
|
"require": "./dist/index.cjs"
|
|
24
35
|
}
|
|
25
36
|
},
|
|
26
|
-
"files": [
|
|
37
|
+
"files": [
|
|
38
|
+
"dist",
|
|
39
|
+
"README.md"
|
|
40
|
+
],
|
|
27
41
|
"scripts": {
|
|
28
42
|
"docs": "npm run typedoc",
|
|
29
43
|
"lint": "biome lint ./src",
|
|
30
44
|
"build": "tsc && npm run lint && vite build && typedoc",
|
|
31
45
|
"build:watch": "vite build --watch && typedoc",
|
|
32
|
-
"build:usecases-html": "node scripts/generate-use-cases-html.js",
|
|
33
46
|
"dev": "concurrently \"vite build --watch\" \"npm run serve\"",
|
|
34
47
|
"serve": "concurrently \"vite --port 5550\" \"vite --port 5551\"",
|
|
35
48
|
"test": "npm run test:unit && npm run test:e2e",
|
|
36
49
|
"test:e2e": "npx playwright install --with-deps && npx playwright test",
|
|
37
|
-
"test:unit": "vitest run"
|
|
50
|
+
"test:unit": "vitest run",
|
|
51
|
+
"prepare": "copyfiles -V ../../README.md packages/core"
|
|
38
52
|
},
|
|
39
53
|
"devDependencies": {
|
|
40
|
-
"@microsoft/tsdoc": "^0.
|
|
54
|
+
"@microsoft/tsdoc": "^0.15.0"
|
|
41
55
|
}
|
|
42
56
|
}
|