@accelerated-agency/visual-editor 0.1.3 → 0.1.5
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.js +8 -6
- package/dist/vite.js +15 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1867,7 +1867,7 @@ import { useState as useState6, useCallback as useCallback6, useEffect as useEff
|
|
|
1867
1867
|
import { useCallback as useCallback4, useEffect as useEffect4, useRef as useRef4, useState as useState4 } from "react";
|
|
1868
1868
|
import { jsx as jsx4, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
1869
1869
|
var CHANNEL = "conversion-editor";
|
|
1870
|
-
function IframeCanvas({ url, password, onBridgeReady, onPong }) {
|
|
1870
|
+
function IframeCanvas({ url, password, proxyBaseUrl = "", onBridgeReady, onPong }) {
|
|
1871
1871
|
const iframeElRef = useRef4(null);
|
|
1872
1872
|
const setSelectedElement = useMutationsStore((s) => s.setSelectedElement);
|
|
1873
1873
|
const addMutationToActive = useVariationsStore((s) => s.addMutationToActive);
|
|
@@ -1917,7 +1917,7 @@ function IframeCanvas({ url, password, onBridgeReady, onPong }) {
|
|
|
1917
1917
|
if (url.toLowerCase() === "test") {
|
|
1918
1918
|
resolvedUrl = "/test";
|
|
1919
1919
|
} else if (url.startsWith("http")) {
|
|
1920
|
-
resolvedUrl =
|
|
1920
|
+
resolvedUrl = `${proxyBaseUrl}/api/proxy?password=${encodeURIComponent(password || "")}&url=${encodeURIComponent(url)}`;
|
|
1921
1921
|
} else {
|
|
1922
1922
|
resolvedUrl = url;
|
|
1923
1923
|
}
|
|
@@ -2185,7 +2185,7 @@ var VIEWPORT_LABELS = {
|
|
|
2185
2185
|
tablet: "768 \xD7 1024",
|
|
2186
2186
|
mobile: "375 \xD7 812"
|
|
2187
2187
|
};
|
|
2188
|
-
function CanvasArea({ url, password, viewport, onBridgeReady, onPong }) {
|
|
2188
|
+
function CanvasArea({ url, password, viewport, proxyBaseUrl, onBridgeReady, onPong }) {
|
|
2189
2189
|
const iframeWidth = VIEWPORT_WIDTHS[viewport];
|
|
2190
2190
|
const isConstrained = viewport !== "desktop";
|
|
2191
2191
|
const [dragOver, setDragOver] = useState6(false);
|
|
@@ -2289,7 +2289,7 @@ function CanvasArea({ url, password, viewport, onBridgeReady, onPong }) {
|
|
|
2289
2289
|
maxWidth: "100%",
|
|
2290
2290
|
boxShadow: isConstrained ? "0 4px 24px rgba(0,0,0,0.1)" : "none"
|
|
2291
2291
|
},
|
|
2292
|
-
children: /* @__PURE__ */ jsx6(IframeCanvas, { url, password, onBridgeReady, onPong })
|
|
2292
|
+
children: /* @__PURE__ */ jsx6(IframeCanvas, { url, password, proxyBaseUrl, onBridgeReady, onPong })
|
|
2293
2293
|
}
|
|
2294
2294
|
) }),
|
|
2295
2295
|
dragOver && draggedSection && /* @__PURE__ */ jsx6(
|
|
@@ -4136,7 +4136,7 @@ function sendToPlatform(type, payload) {
|
|
|
4136
4136
|
data: { channel: PLATFORM_CHANNEL, type, payload }
|
|
4137
4137
|
}));
|
|
4138
4138
|
}
|
|
4139
|
-
function EditorShell({ initialExperiment, embeddedMode }) {
|
|
4139
|
+
function EditorShell({ initialExperiment, embeddedMode, proxyBaseUrl }) {
|
|
4140
4140
|
const [url, setUrl] = useState12("");
|
|
4141
4141
|
const [password, setPassword] = useState12("");
|
|
4142
4142
|
const [connectionStatus, setConnectionStatus] = useState12("disconnected");
|
|
@@ -4590,6 +4590,7 @@ function EditorShell({ initialExperiment, embeddedMode }) {
|
|
|
4590
4590
|
url,
|
|
4591
4591
|
password,
|
|
4592
4592
|
viewport,
|
|
4593
|
+
proxyBaseUrl,
|
|
4593
4594
|
onBridgeReady: handleBridgeReady,
|
|
4594
4595
|
onPong: handlePong
|
|
4595
4596
|
}
|
|
@@ -4605,6 +4606,7 @@ import { jsx as jsx13, jsxs as jsxs13 } from "react/jsx-runtime";
|
|
|
4605
4606
|
function PlatformVisualEditor({
|
|
4606
4607
|
channel = "conversion-platform",
|
|
4607
4608
|
embeddedGlobalKey = "__CONVERSION_EMBEDDED__",
|
|
4609
|
+
proxyBaseUrl = typeof import.meta !== "undefined" && import.meta.env?.VITE_API_BASE_URL || "",
|
|
4608
4610
|
className = "fixed inset-0 z-[9999] flex flex-col bg-white",
|
|
4609
4611
|
editorClassName = "flex-1 min-h-0",
|
|
4610
4612
|
showHeader = true,
|
|
@@ -4816,7 +4818,7 @@ function PlatformVisualEditor({
|
|
|
4816
4818
|
) : null
|
|
4817
4819
|
] })
|
|
4818
4820
|
] }) : null,
|
|
4819
|
-
/* @__PURE__ */ jsx13("div", { className: editorClassName, children: /* @__PURE__ */ jsx13(ToastProvider, { children: /* @__PURE__ */ jsx13(EditorShell, { initialExperiment: experiment, embeddedMode: true }) }) })
|
|
4821
|
+
/* @__PURE__ */ jsx13("div", { className: editorClassName, children: /* @__PURE__ */ jsx13(ToastProvider, { children: /* @__PURE__ */ jsx13(EditorShell, { initialExperiment: experiment, embeddedMode: true, proxyBaseUrl }) }) })
|
|
4820
4822
|
] });
|
|
4821
4823
|
}
|
|
4822
4824
|
|
package/dist/vite.js
CHANGED
|
@@ -1769,6 +1769,19 @@ var getDefaultAnthropicApiKey = () => {
|
|
|
1769
1769
|
function createVisualEditorMiddleware(options) {
|
|
1770
1770
|
const anthropicApiKey = options?.anthropicApiKey || getDefaultAnthropicApiKey();
|
|
1771
1771
|
const enableGenerateTestApi = options?.enableGenerateTestApi ?? true;
|
|
1772
|
+
const allowedFrameOrigins = options?.allowedFrameOrigins ?? ["*"];
|
|
1773
|
+
function setFrameHeaders(req, res) {
|
|
1774
|
+
const requestOrigin = req.headers?.["origin"] || req.headers?.["referer"] || "";
|
|
1775
|
+
if (allowedFrameOrigins.includes("*")) {
|
|
1776
|
+
const frameOrigin = requestOrigin ? new URL(requestOrigin).origin : "*";
|
|
1777
|
+
res.setHeader("Content-Security-Policy", `frame-ancestors 'self' ${frameOrigin}`);
|
|
1778
|
+
} else {
|
|
1779
|
+
res.setHeader(
|
|
1780
|
+
"Content-Security-Policy",
|
|
1781
|
+
`frame-ancestors 'self' ${allowedFrameOrigins.join(" ")}`
|
|
1782
|
+
);
|
|
1783
|
+
}
|
|
1784
|
+
}
|
|
1772
1785
|
return async (req, res, next) => {
|
|
1773
1786
|
const pathname = (req.url || "").split("?")[0];
|
|
1774
1787
|
if (pathname === "/bridge.js") {
|
|
@@ -1780,7 +1793,7 @@ function createVisualEditorMiddleware(options) {
|
|
|
1780
1793
|
if (pathname === "/vvveb-editor") {
|
|
1781
1794
|
res.setHeader("Content-Type", "text/html; charset=utf-8");
|
|
1782
1795
|
res.setHeader("Cache-Control", "no-store");
|
|
1783
|
-
|
|
1796
|
+
setFrameHeaders(req, res);
|
|
1784
1797
|
res.end(buildVvvebEditorHtml());
|
|
1785
1798
|
return;
|
|
1786
1799
|
}
|
|
@@ -1996,7 +2009,7 @@ function createVisualEditorMiddleware(options) {
|
|
|
1996
2009
|
</body>`) : html + bridgeScript;
|
|
1997
2010
|
res.setHeader("Content-Type", "text/html; charset=utf-8");
|
|
1998
2011
|
res.setHeader("Access-Control-Allow-Origin", "*");
|
|
1999
|
-
|
|
2012
|
+
setFrameHeaders(req, res);
|
|
2000
2013
|
res.end(html);
|
|
2001
2014
|
} catch (err) {
|
|
2002
2015
|
res.statusCode = 500;
|