@viamedici-spc/configurator-framer-host 1.2.0-alpha0002 → 1.2.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/dist/index.mjs +48 -54
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
function
|
|
1
|
+
function x(s) {
|
|
2
2
|
var e = [];
|
|
3
3
|
if (s.length === 0)
|
|
4
4
|
return "";
|
|
@@ -20,28 +20,28 @@ function S(s) {
|
|
|
20
20
|
var a = n.split("?");
|
|
21
21
|
return n = a.shift() + (a.length > 0 ? "?" : "") + a.join("&"), n;
|
|
22
22
|
}
|
|
23
|
-
function
|
|
23
|
+
function S() {
|
|
24
24
|
var s;
|
|
25
|
-
return typeof arguments[0] == "object" ? s = arguments[0] : s = [].slice.call(arguments),
|
|
25
|
+
return typeof arguments[0] == "object" ? s = arguments[0] : s = [].slice.call(arguments), x(s);
|
|
26
26
|
}
|
|
27
|
-
const m = class
|
|
27
|
+
const m = class u extends HTMLElement {
|
|
28
28
|
constructor() {
|
|
29
|
-
super(), this.src = null, this.proxyBaseUrl =
|
|
29
|
+
super(), this.src = null, this.proxyBaseUrl = u.proxyBaseUrl, this.hasConnected = !1;
|
|
30
30
|
}
|
|
31
31
|
static get observedAttributes() {
|
|
32
|
-
return
|
|
32
|
+
return u.attributeNames;
|
|
33
33
|
}
|
|
34
34
|
connectedCallback() {
|
|
35
35
|
this.hasConnected = !0, this.src && (console.log("[Configurator] Web Component connected -> reinitialize the configurator app."), this.bootstrapApp());
|
|
36
36
|
}
|
|
37
37
|
attributeChangedCallback(e, o, t) {
|
|
38
|
-
e === "src" && t !== o ? (this.src = t, this.hasConnected && this.isConnected && this.src && (console.log("[Configurator] The URL was changed -> reinitialize the configurator app."), this.bootstrapApp())) : e === "proxy-base-url" && t !== o && (this.proxyBaseUrl = t ??
|
|
38
|
+
e === "src" && t !== o ? (this.src = t, this.hasConnected && this.isConnected && this.src && (console.log("[Configurator] The URL was changed -> reinitialize the configurator app."), this.bootstrapApp())) : e === "proxy-base-url" && t !== o && (this.proxyBaseUrl = t ?? u.proxyBaseUrl);
|
|
39
39
|
}
|
|
40
40
|
async bootstrapApp() {
|
|
41
41
|
try {
|
|
42
42
|
let e;
|
|
43
43
|
try {
|
|
44
|
-
const i =
|
|
44
|
+
const i = S(this.proxyBaseUrl, `?url=${this.src}`);
|
|
45
45
|
e = await fetch(i);
|
|
46
46
|
} catch (i) {
|
|
47
47
|
console.error("[Configurator] Failed to bootstrap configurator app: Failed to load index.html.", i);
|
|
@@ -49,47 +49,41 @@ const m = class h extends HTMLElement {
|
|
|
49
49
|
}
|
|
50
50
|
for (; this.firstChild; )
|
|
51
51
|
this.removeChild(this.firstChild);
|
|
52
|
-
const o = await e.text(), t = new DOMParser().parseFromString(o, "text/html"), r = t.querySelector("style[data-framer-css-ssr-minified]") || t.querySelector("style[data-framer-css-ssr]"), n = t.querySelector("style[data-framer-fonts-ssr-minified]") || t.querySelector("style[data-framer-font-css]"), a = t.querySelector("div#main"), l = t.querySelector('script[data-framer-bundle="main"]'),
|
|
53
|
-
if (
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
if (
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
52
|
+
const o = await e.text(), t = new DOMParser().parseFromString(o, "text/html"), r = t.querySelector("style[data-framer-css-ssr-minified]") || t.querySelector("style[data-framer-css-ssr]"), n = t.querySelector("style[data-framer-fonts-ssr-minified]") || t.querySelector("style[data-framer-font-css]"), a = t.querySelector("div#main"), l = t.querySelector('script[data-framer-bundle="main"]'), f = t.querySelector('script[type="importmap"][data-framer-importmap]');
|
|
53
|
+
if (r && r.textContent) {
|
|
54
|
+
const i = r.textContent.split("}").filter((h) => {
|
|
55
|
+
const d = h.trim();
|
|
56
|
+
return !// Remove some rules that may interfere too much with the host
|
|
57
|
+
(d.startsWith("html,body,#main") || d.startsWith("h1,h2,h3,h4,h5,h6,p,figure") || d.startsWith("body,input,textarea,select,button") || d.startsWith("*"));
|
|
58
|
+
}).map((h) => h.trim()).join(`}
|
|
59
|
+
`), c = document.createElement("style");
|
|
60
|
+
for (const h of r.attributes)
|
|
61
|
+
c.setAttribute(h.name, h.value);
|
|
62
|
+
c.textContent = i, this.appendChild(c);
|
|
63
|
+
} else
|
|
64
|
+
console.warn("[Configurator] Bootstrapping configurator app: Could not find the CSS style element.");
|
|
65
|
+
if (n && n.textContent) {
|
|
66
|
+
const i = document.createElement("style");
|
|
67
|
+
for (const c of n.attributes)
|
|
68
|
+
i.setAttribute(c.name, c.value);
|
|
69
|
+
i.textContent = n.textContent, this.appendChild(i);
|
|
70
|
+
} else
|
|
71
|
+
console.warn("[Configurator] Bootstrapping configurator app: Could not find the fonts style element.");
|
|
72
|
+
if (a ? this.appendChild(a.cloneNode()) : console.warn("[Configurator] Bootstrapping configurator app: Could not find the main div."), l && l instanceof HTMLScriptElement)
|
|
73
|
+
if (l.src) {
|
|
74
|
+
const i = document.createElement("script");
|
|
75
|
+
i.type = "module", i.src = l.src, i.setAttribute("async", ""), this.appendChild(i);
|
|
76
|
+
} else if (l.textContent) {
|
|
77
|
+
const i = document.createElement("script");
|
|
78
|
+
i.type = "module", i.textContent = l.textContent, this.appendChild(i);
|
|
79
|
+
} else
|
|
80
|
+
console.error("[Configurator] Script tag found, but no src or content available.");
|
|
81
|
+
else
|
|
82
|
+
console.warn("[Configurator] Bootstrapping configurator app: Could not find the main entry script.");
|
|
83
|
+
if (f && f.textContent) {
|
|
82
84
|
const i = document.createElement("script");
|
|
83
|
-
i.type = "importmap", i.textContent =
|
|
85
|
+
i.type = "importmap", i.textContent = f.textContent, this.appendChild(i);
|
|
84
86
|
}
|
|
85
|
-
if (l.src) {
|
|
86
|
-
const i = document.createElement("script");
|
|
87
|
-
i.type = "module", i.src = l.src, i.setAttribute("async", ""), this.appendChild(i);
|
|
88
|
-
} else if (l.textContent) {
|
|
89
|
-
const i = document.createElement("script");
|
|
90
|
-
i.type = "module", i.textContent = l.textContent, this.appendChild(i);
|
|
91
|
-
} else
|
|
92
|
-
console.error("[Configurator] Script tag found, but no src or content available.");
|
|
93
87
|
} catch (e) {
|
|
94
88
|
console.error("[Configurator] Failed to bootstrap configurator app", e);
|
|
95
89
|
}
|
|
@@ -98,12 +92,12 @@ const m = class h extends HTMLElement {
|
|
|
98
92
|
m.proxyBaseUrl = "https://spc.cloud.ceventis.de/framer/host-proxy";
|
|
99
93
|
m.attributeNames = ["src", "proxy-base-url"];
|
|
100
94
|
let g = m;
|
|
101
|
-
const
|
|
95
|
+
const C = class b extends HTMLElement {
|
|
102
96
|
constructor() {
|
|
103
97
|
super(), this.src = null, this.hasConnected = !1, this.iframe = null, this.autoHeightHandler = null, this.allowedOrigin = null;
|
|
104
98
|
}
|
|
105
99
|
static get observedAttributes() {
|
|
106
|
-
return
|
|
100
|
+
return b.attributeNames;
|
|
107
101
|
}
|
|
108
102
|
connectedCallback() {
|
|
109
103
|
this.hasConnected = !0, this.src && (console.log("[Configurator] Web Component connected -> reinitialize the configurator app."), this.bootstrapApp());
|
|
@@ -139,8 +133,8 @@ const b = class C extends HTMLElement {
|
|
|
139
133
|
this.autoHeightHandler && (window.removeEventListener("message", this.autoHeightHandler), this.autoHeightHandler = null);
|
|
140
134
|
}
|
|
141
135
|
};
|
|
142
|
-
|
|
143
|
-
let y =
|
|
136
|
+
C.attributeNames = ["src", "no-auto-height"];
|
|
137
|
+
let y = C;
|
|
144
138
|
const v = class p extends HTMLElement {
|
|
145
139
|
constructor() {
|
|
146
140
|
super(), this.child = null, this.isIsolated = !1;
|
|
@@ -178,11 +172,11 @@ const v = class p extends HTMLElement {
|
|
|
178
172
|
}
|
|
179
173
|
};
|
|
180
174
|
v.childAttributes = [...g.attributeNames, ...y.attributeNames];
|
|
181
|
-
let
|
|
182
|
-
customElements.define("spc-embedded-configurator",
|
|
175
|
+
let E = v;
|
|
176
|
+
customElements.define("spc-embedded-configurator", E);
|
|
183
177
|
customElements.define("spc-embedded-configurator-native", g);
|
|
184
178
|
customElements.define("spc-embedded-configurator-iframe", y);
|
|
185
179
|
export {
|
|
186
180
|
g as EmbeddedConfiguratorNative,
|
|
187
|
-
|
|
181
|
+
E as EmbeddedConfiguratorStrategy
|
|
188
182
|
};
|
package/package.json
CHANGED