@accelerated-agency/visual-editor 0.2.6 → 0.2.7

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.
Files changed (2) hide show
  1. package/dist/index.js +33 -2
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1842,6 +1842,31 @@ function ElementIcon({ tag }) {
1842
1842
  }
1843
1843
  return /* @__PURE__ */ jsx("span", { className: "shrink-0 w-5 h-5 rounded flex items-center justify-center", style: { backgroundColor: bgColor }, children: /* @__PURE__ */ jsx("svg", { width: "12", height: "12", viewBox: "0 0 12 12", fill: "none", children: /* @__PURE__ */ jsx("rect", { x: "1.5", y: "1.5", width: "9", height: "9", rx: "1.5", stroke: iconColor, strokeWidth: "1.2" }) }) });
1844
1844
  }
1845
+
1846
+ // src/lib/normalizeProxyBaseUrl.ts
1847
+ function normalizeProxyBaseUrl(proxyBaseUrl) {
1848
+ const raw = (proxyBaseUrl || "").trim().replace(/\/+$/, "");
1849
+ if (!raw) return "";
1850
+ const isAbsoluteHttpUrl = /^https?:\/\//i.test(raw);
1851
+ if (!isAbsoluteHttpUrl || typeof window === "undefined") {
1852
+ return raw;
1853
+ }
1854
+ try {
1855
+ const parsed = new URL(raw);
1856
+ const pageIsHttps = window.location.protocol === "https:";
1857
+ const targetIsHttp = parsed.protocol === "http:";
1858
+ if (pageIsHttps && targetIsHttp) {
1859
+ if (parsed.hostname === window.location.hostname) {
1860
+ const basePath = parsed.pathname === "/" ? "" : parsed.pathname.replace(/\/+$/, "");
1861
+ return `${window.location.origin}${basePath}`;
1862
+ }
1863
+ parsed.protocol = "https:";
1864
+ }
1865
+ return parsed.toString().replace(/\/+$/, "");
1866
+ } catch {
1867
+ return raw;
1868
+ }
1869
+ }
1845
1870
  var CHANNEL = "conversion-editor";
1846
1871
  function IframeCanvas({ url, password, proxyBaseUrl = "", onBridgeReady, onPong }) {
1847
1872
  const iframeElRef = useRef(null);
@@ -1885,11 +1910,12 @@ function IframeCanvas({ url, password, proxyBaseUrl = "", onBridgeReady, onPong
1885
1910
  window.addEventListener("message", handleMessage);
1886
1911
  return () => window.removeEventListener("message", handleMessage);
1887
1912
  }, [handleMessage]);
1913
+ const resolvedProxyBaseUrl = normalizeProxyBaseUrl(proxyBaseUrl);
1888
1914
  let resolvedUrl;
1889
1915
  if (url.toLowerCase() === "test") {
1890
1916
  resolvedUrl = "/test";
1891
1917
  } else if (url.startsWith("http")) {
1892
- resolvedUrl = `${proxyBaseUrl}/api/conversion-proxy?password=${encodeURIComponent(password || "")}&url=${encodeURIComponent(url)}`;
1918
+ resolvedUrl = `${resolvedProxyBaseUrl}/api/conversion-proxy?password=${encodeURIComponent(password || "")}&url=${encodeURIComponent(url)}`;
1893
1919
  } else {
1894
1920
  resolvedUrl = url;
1895
1921
  }
@@ -4777,6 +4803,7 @@ var VVVEB_CHANNEL = "vvveb-bridge";
4777
4803
  function PlatformVisualEditorV2({
4778
4804
  // channel kept for API compatibility; VvvebJs uses its own internal channel
4779
4805
  embeddedGlobalKey = "__CONVERSION_EMBEDDED__",
4806
+ proxyBaseUrl = "",
4780
4807
  className = "fixed inset-0 z-[9999] flex flex-col bg-white",
4781
4808
  editorClassName = "flex-1 min-h-0",
4782
4809
  showHeader = true,
@@ -4839,6 +4866,10 @@ function PlatformVisualEditorV2({
4839
4866
  }),
4840
4867
  [experiment]
4841
4868
  );
4869
+ const editorSrc = useMemo(() => {
4870
+ const safeBaseUrl = normalizeProxyBaseUrl(proxyBaseUrl);
4871
+ return safeBaseUrl ? `${safeBaseUrl}/vvveb-editor` : "/vvveb-editor";
4872
+ }, [proxyBaseUrl]);
4842
4873
  useEffect(() => {
4843
4874
  if (!editorReady) return;
4844
4875
  const key = JSON.stringify(loadPayload);
@@ -4981,7 +5012,7 @@ function PlatformVisualEditorV2({
4981
5012
  "iframe",
4982
5013
  {
4983
5014
  ref: iframeRef,
4984
- src: "/vvveb-editor",
5015
+ src: editorSrc,
4985
5016
  className: "w-full h-full border-0",
4986
5017
  title: "Vvveb Visual Editor",
4987
5018
  allow: "same-origin"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@accelerated-agency/visual-editor",
3
- "version": "0.2.6",
3
+ "version": "0.2.7",
4
4
  "private": false,
5
5
  "description": "Conversion visual editor as a reusable React package",
6
6
  "type": "module",