@stackable-labs/embeddables 1.84.0 → 1.86.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/react.js CHANGED
@@ -5,7 +5,7 @@ import * as kn from "react-dom";
5
5
  import hs from "react-dom";
6
6
  const nl = () => {
7
7
  try {
8
- return "ec4bb3a4-4213-4000-818d-f0f7e06b1c72";
8
+ return "6aa0b7d1-fd27-414e-8bff-45bcdc934657";
9
9
  } catch {
10
10
  return "dev";
11
11
  }
@@ -16,18 +16,20 @@ const nl = () => {
16
16
  if (!e.bundleUrl)
17
17
  return console.warn(`[SandboxManager] Extension ${e.id} is missing bundleUrl — skipping sandbox creation`), null;
18
18
  const o = document.createElement("iframe");
19
- if (o.setAttribute("sandbox", "allow-scripts allow-same-origin"), o.style.display = "none", o.style.width = "0", o.style.height = "0", o.style.border = "none", e.bundleUrl.startsWith("http") && !e.bundleUrl.endsWith(".js")) {
20
- const i = new URL(e.bundleUrl);
21
- i.searchParams.set("__extensionId", e.id), o.src = i.toString(), console.warn(`[SandboxManager] Creating dev sandbox for ${e.id}, injecting __extensionId via query param, url: ${i.toString()}`);
19
+ o.setAttribute("sandbox", "allow-scripts allow-same-origin"), o.style.display = "none", o.style.width = "0", o.style.height = "0", o.style.border = "none";
20
+ const r = e.bundleUrl.startsWith("http") && !e.bundleUrl.endsWith(".js"), s = r ? new URL(e.bundleUrl).origin : "null";
21
+ if (r) {
22
+ const c = new URL(e.bundleUrl);
23
+ c.searchParams.set("__extensionId", e.id), o.src = c.toString(), console.warn(`[SandboxManager] Creating dev sandbox for ${e.id}, injecting __extensionId via query param, url: ${c.toString()}`);
22
24
  } else {
23
- let i = "";
25
+ let c = "";
24
26
  try {
25
- const d = nl();
26
- i = await (await fetch(`${e.bundleUrl}?_b=${d}`)).text();
27
- } catch (d) {
28
- console.error(`[SandboxManager] Failed to fetch bundle for ${e.id}:`, d);
27
+ const u = nl();
28
+ c = await (await fetch(`${e.bundleUrl}?_b=${u}`)).text();
29
+ } catch (u) {
30
+ console.error(`[SandboxManager] Failed to fetch bundle for ${e.id}:`, u);
29
31
  }
30
- const c = `<!DOCTYPE html>
32
+ const d = `<!DOCTYPE html>
31
33
  <html>
32
34
  <head>
33
35
  <meta charset="utf-8">
@@ -36,30 +38,34 @@ const nl = () => {
36
38
  <body>
37
39
  <div id="extension-root"></div>
38
40
  <script>var __STACKABLE_EXTENSION_ID__ = ${JSON.stringify(e.id)}; var process = { env: { NODE_ENV: "production" } };<\/script>
39
- <script type="module">${i}<\/script>
41
+ <script type="module">${c}<\/script>
40
42
  </body>
41
43
  </html>`;
42
- o.srcdoc = c, console.warn(`[SandboxManager] Creating srcdoc sandbox for ${e.id}, srcdoc starts with: ${c.substring(0, 300)}`);
44
+ o.srcdoc = d, console.warn(`[SandboxManager] Creating srcdoc sandbox for ${e.id}, srcdoc starts with: ${d.substring(0, 300)}`);
43
45
  }
44
46
  t.appendChild(o);
45
- const s = {
47
+ const a = {
46
48
  extensionId: e.id,
47
49
  iframe: o,
48
50
  manifest: e.manifest,
49
51
  ready: !1,
52
+ expectedOrigin: s,
50
53
  messageHandlers: /* @__PURE__ */ new Set()
51
- }, a = (i) => {
52
- const c = i.data;
53
- !c || typeof c != "object" || !("type" in c) || ("extensionId" in c ? c.extensionId : void 0) !== e.id || (c.type === "extension-ready" && (s.ready = !0), s.messageHandlers.forEach((u) => u(c)));
54
+ }, i = (c) => {
55
+ if (c.origin !== a.expectedOrigin)
56
+ return;
57
+ const d = c.data;
58
+ !d || typeof d != "object" || !("type" in d) || ("extensionId" in d ? d.extensionId : void 0) !== e.id || (d.type === "extension-ready" && (a.ready = !0), a.messageHandlers.forEach((l) => l(d)));
54
59
  };
55
- return window.addEventListener("message", a), dt.set(e.id, s), s;
60
+ return window.addEventListener("message", i), dt.set(e.id, a), a;
56
61
  }, $e = (e, t) => {
57
62
  const n = dt.get(e);
58
63
  if (!(n != null && n.iframe.contentWindow)) {
59
64
  console.warn(`Sandbox not found for extension: ${e}`);
60
65
  return;
61
66
  }
62
- n.iframe.contentWindow.postMessage(t, "*");
67
+ const o = n.expectedOrigin === "null" ? "*" : n.expectedOrigin;
68
+ n.iframe.contentWindow.postMessage(t, o);
63
69
  }, Nt = (e) => dt.get(e), rl = (e) => {
64
70
  const t = dt.get(e);
65
71
  t && (t.iframe.remove(), t.messageHandlers.clear(), dt.delete(e));