@builder.io/sdk-react 0.7.4 → 0.7.6
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/lib/browser/index.cjs +11 -11
- package/lib/browser/index.mjs +147 -147
- package/lib/edge/index.cjs +12 -12
- package/lib/edge/index.mjs +303 -303
- package/lib/node/index.cjs +9 -9
- package/lib/node/index.mjs +139 -139
- package/package.json +1 -1
- package/types/components/content/content.helpers.d.ts +1 -1
- package/types/constants/sdk-version.d.ts +1 -1
package/lib/node/index.mjs
CHANGED
|
@@ -176,24 +176,24 @@ output;
|
|
|
176
176
|
event: i,
|
|
177
177
|
state: l
|
|
178
178
|
}), s = getIsolateContext(), d = s.global;
|
|
179
|
-
d.setSync("global", d.derefInto()), d.setSync("log", function(...
|
|
180
|
-
console.log(...
|
|
181
|
-
}), d.setSync(BUILDER_SET_STATE_NAME, function(
|
|
182
|
-
set(r,
|
|
183
|
-
}), c.forEach(([
|
|
184
|
-
const
|
|
179
|
+
d.setSync("global", d.derefInto()), d.setSync("log", function(...y) {
|
|
180
|
+
console.log(...y);
|
|
181
|
+
}), d.setSync(BUILDER_SET_STATE_NAME, function(y, f) {
|
|
182
|
+
set(r, y, f), a == null || a(r);
|
|
183
|
+
}), c.forEach(([y, f]) => {
|
|
184
|
+
const S = typeof f == "object" ? new ivm.Reference(
|
|
185
185
|
// workaround: methods with default values for arguments is not being cloned over
|
|
186
|
-
|
|
187
|
-
...
|
|
188
|
-
getUserAttributes: () =>
|
|
189
|
-
} :
|
|
186
|
+
y === "builder" ? {
|
|
187
|
+
...f,
|
|
188
|
+
getUserAttributes: () => f.getUserAttributes()
|
|
189
|
+
} : f
|
|
190
190
|
) : null;
|
|
191
|
-
d.setSync(getSyncValName(
|
|
191
|
+
d.setSync(getSyncValName(y), S);
|
|
192
192
|
}), d.setSync(INJECTED_IVM_GLOBAL, ivm);
|
|
193
|
-
const
|
|
193
|
+
const g = processCode({
|
|
194
194
|
code: e,
|
|
195
195
|
args: c
|
|
196
|
-
}), b = s.evalSync(
|
|
196
|
+
}), b = s.evalSync(g);
|
|
197
197
|
try {
|
|
198
198
|
return JSON.parse(b);
|
|
199
199
|
} catch {
|
|
@@ -412,7 +412,7 @@ function BlockStyles(e) {
|
|
|
412
412
|
return checkIsDefined(i.hide) ? !i.hide : checkIsDefined(i.show) ? i.show : !0;
|
|
413
413
|
}
|
|
414
414
|
function n() {
|
|
415
|
-
var
|
|
415
|
+
var f;
|
|
416
416
|
const i = getProcessedBlock({
|
|
417
417
|
block: e.block,
|
|
418
418
|
localState: e.context.localState,
|
|
@@ -421,11 +421,11 @@ function BlockStyles(e) {
|
|
|
421
421
|
context: e.context.context,
|
|
422
422
|
shouldEvaluateBindings: !0
|
|
423
423
|
}), o = i.responsiveStyles, a = e.context.content, r = getSizesForBreakpoints(
|
|
424
|
-
((
|
|
424
|
+
((f = a == null ? void 0 : a.meta) == null ? void 0 : f.breakpoints) || {}
|
|
425
425
|
), l = o == null ? void 0 : o.large, c = o == null ? void 0 : o.medium, s = o == null ? void 0 : o.small, d = i.id;
|
|
426
426
|
if (!d)
|
|
427
427
|
return "";
|
|
428
|
-
const
|
|
428
|
+
const g = l ? createCssClass({
|
|
429
429
|
className: d,
|
|
430
430
|
styles: l
|
|
431
431
|
}) : "", b = c ? createCssClass({
|
|
@@ -435,7 +435,7 @@ function BlockStyles(e) {
|
|
|
435
435
|
"medium",
|
|
436
436
|
r
|
|
437
437
|
)
|
|
438
|
-
}) : "",
|
|
438
|
+
}) : "", y = s ? createCssClass({
|
|
439
439
|
className: d,
|
|
440
440
|
styles: s,
|
|
441
441
|
mediaQuery: getMaxWidthQueryForSize(
|
|
@@ -443,7 +443,7 @@ function BlockStyles(e) {
|
|
|
443
443
|
r
|
|
444
444
|
)
|
|
445
445
|
}) : "";
|
|
446
|
-
return [
|
|
446
|
+
return [g, b, y].join(" ");
|
|
447
447
|
}
|
|
448
448
|
return /* @__PURE__ */ jsx(Fragment, { children: n() && t() ? /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(InlinedStyles, { styles: n() }) }) : null });
|
|
449
449
|
}
|
|
@@ -657,7 +657,7 @@ function RepeatedBlock(e) {
|
|
|
657
657
|
) });
|
|
658
658
|
}
|
|
659
659
|
function Block(e) {
|
|
660
|
-
var d,
|
|
660
|
+
var d, g, b, y;
|
|
661
661
|
function t() {
|
|
662
662
|
return getComponent({
|
|
663
663
|
block: e.block,
|
|
@@ -672,7 +672,8 @@ function Block(e) {
|
|
|
672
672
|
});
|
|
673
673
|
}
|
|
674
674
|
function i() {
|
|
675
|
-
|
|
675
|
+
var f;
|
|
676
|
+
return (f = e.block.repeat) != null && f.collection ? e.block : getProcessedBlock({
|
|
676
677
|
block: e.block,
|
|
677
678
|
localState: e.context.localState,
|
|
678
679
|
rootState: e.context.rootState,
|
|
@@ -685,28 +686,32 @@ function Block(e) {
|
|
|
685
686
|
return e.block.tagName || "div";
|
|
686
687
|
}
|
|
687
688
|
function a() {
|
|
688
|
-
|
|
689
|
+
var k, C;
|
|
690
|
+
if ((k = e.block.repeat) != null && k.collection)
|
|
691
|
+
return !!((C = n == null ? void 0 : n()) != null && C.length);
|
|
692
|
+
const f = "hide" in i() ? i().hide : !1;
|
|
693
|
+
return ("show" in i() ? i().show : !0) && !f;
|
|
689
694
|
}
|
|
690
695
|
function r() {
|
|
691
|
-
var
|
|
692
|
-
return !((
|
|
696
|
+
var S;
|
|
697
|
+
return !((S = t == null ? void 0 : t()) != null && S.component) && !n() ? i().children ?? [] : [];
|
|
693
698
|
}
|
|
694
699
|
function l() {
|
|
695
|
-
var
|
|
700
|
+
var f, S, k, C, v;
|
|
696
701
|
return {
|
|
697
702
|
blockChildren: i().children ?? [],
|
|
698
|
-
componentRef: (
|
|
703
|
+
componentRef: (f = t == null ? void 0 : t()) == null ? void 0 : f.component,
|
|
699
704
|
componentOptions: {
|
|
700
705
|
...getBlockComponentOptions(i()),
|
|
701
706
|
builderContext: e.context,
|
|
702
|
-
...((
|
|
707
|
+
...((S = t == null ? void 0 : t()) == null ? void 0 : S.name) === "Symbol" || ((k = t == null ? void 0 : t()) == null ? void 0 : k.name) === "Columns" ? {
|
|
703
708
|
builderComponents: e.registeredComponents
|
|
704
709
|
} : {}
|
|
705
710
|
},
|
|
706
711
|
context: c,
|
|
707
712
|
registeredComponents: e.registeredComponents,
|
|
708
713
|
builderBlock: i(),
|
|
709
|
-
includeBlockProps: ((
|
|
714
|
+
includeBlockProps: ((C = t == null ? void 0 : t()) == null ? void 0 : C.noWrap) === !0,
|
|
710
715
|
isInteractive: !((v = t == null ? void 0 : t()) != null && v.isRSC)
|
|
711
716
|
};
|
|
712
717
|
}
|
|
@@ -733,14 +738,14 @@ function Block(e) {
|
|
|
733
738
|
hasChildren: !1
|
|
734
739
|
}
|
|
735
740
|
) }) : null,
|
|
736
|
-
!isEmptyHtmlElement(o()) && n() ? /* @__PURE__ */ jsx(Fragment, { children: (
|
|
741
|
+
!isEmptyHtmlElement(o()) && n() ? /* @__PURE__ */ jsx(Fragment, { children: (g = n()) == null ? void 0 : g.map((f, S) => /* @__PURE__ */ jsx(
|
|
737
742
|
RepeatedBlock,
|
|
738
743
|
{
|
|
739
|
-
repeatContext:
|
|
740
|
-
block:
|
|
744
|
+
repeatContext: f.context,
|
|
745
|
+
block: f.block,
|
|
741
746
|
registeredComponents: e.registeredComponents
|
|
742
747
|
},
|
|
743
|
-
|
|
748
|
+
S
|
|
744
749
|
)) }) : null,
|
|
745
750
|
!isEmptyHtmlElement(o()) && !n() ? /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs(
|
|
746
751
|
BlockWrapper,
|
|
@@ -763,22 +768,22 @@ function Block(e) {
|
|
|
763
768
|
isInteractive: l().isInteractive
|
|
764
769
|
}
|
|
765
770
|
),
|
|
766
|
-
(b = r()) == null ? void 0 : b.map((
|
|
771
|
+
(b = r()) == null ? void 0 : b.map((f) => /* @__PURE__ */ jsx(
|
|
767
772
|
Block,
|
|
768
773
|
{
|
|
769
|
-
block:
|
|
774
|
+
block: f,
|
|
770
775
|
context: c,
|
|
771
776
|
registeredComponents: e.registeredComponents
|
|
772
777
|
},
|
|
773
|
-
"block-" +
|
|
778
|
+
"block-" + f.id
|
|
774
779
|
)),
|
|
775
|
-
(
|
|
780
|
+
(y = r()) == null ? void 0 : y.map((f) => /* @__PURE__ */ jsx(
|
|
776
781
|
BlockStyles,
|
|
777
782
|
{
|
|
778
|
-
block:
|
|
783
|
+
block: f,
|
|
779
784
|
context: c
|
|
780
785
|
},
|
|
781
|
-
"block-style-" +
|
|
786
|
+
"block-style-" + f.id
|
|
782
787
|
))
|
|
783
788
|
]
|
|
784
789
|
}
|
|
@@ -870,46 +875,46 @@ function Blocks(e) {
|
|
|
870
875
|
);
|
|
871
876
|
}
|
|
872
877
|
function Columns(e) {
|
|
873
|
-
var
|
|
878
|
+
var C;
|
|
874
879
|
const [t, n] = useState(
|
|
875
880
|
() => typeof e.space == "number" ? e.space || 0 : 20
|
|
876
881
|
), [i, o] = useState(() => e.columns || []), [a, r] = useState(
|
|
877
882
|
() => e.stackColumnsAt || "tablet"
|
|
878
883
|
);
|
|
879
884
|
function l(v) {
|
|
880
|
-
var
|
|
881
|
-
return ((
|
|
885
|
+
var I;
|
|
886
|
+
return ((I = i[v]) == null ? void 0 : I.width) || 100 / i.length;
|
|
882
887
|
}
|
|
883
888
|
function c(v) {
|
|
884
|
-
const
|
|
885
|
-
return `calc(${l(v)}% - ${
|
|
889
|
+
const I = t * (i.length - 1) / i.length;
|
|
890
|
+
return `calc(${l(v)}% - ${I}px)`;
|
|
886
891
|
}
|
|
887
892
|
function s({
|
|
888
893
|
stackedStyle: v,
|
|
889
|
-
desktopStyle:
|
|
894
|
+
desktopStyle: I
|
|
890
895
|
}) {
|
|
891
|
-
return a === "tablet" ? v :
|
|
896
|
+
return a === "tablet" ? v : I;
|
|
892
897
|
}
|
|
893
898
|
function d({
|
|
894
899
|
stackedStyle: v,
|
|
895
|
-
desktopStyle:
|
|
900
|
+
desktopStyle: I
|
|
896
901
|
}) {
|
|
897
|
-
return a === "never" ?
|
|
902
|
+
return a === "never" ? I : v;
|
|
898
903
|
}
|
|
899
|
-
const [
|
|
904
|
+
const [g, b] = useState(
|
|
900
905
|
() => e.stackColumnsAt === "never" ? "row" : e.reverseColumnsWhenStacked ? "column-reverse" : "column"
|
|
901
906
|
);
|
|
902
|
-
function
|
|
907
|
+
function y() {
|
|
903
908
|
return {
|
|
904
|
-
"--flex-dir":
|
|
909
|
+
"--flex-dir": g,
|
|
905
910
|
"--flex-dir-tablet": s({
|
|
906
|
-
stackedStyle:
|
|
911
|
+
stackedStyle: g,
|
|
907
912
|
desktopStyle: "row"
|
|
908
913
|
})
|
|
909
914
|
};
|
|
910
915
|
}
|
|
911
|
-
function
|
|
912
|
-
const
|
|
916
|
+
function f(v) {
|
|
917
|
+
const I = v === 0 ? 0 : t, T = c(v), w = `${I}px`, R = "100%", j = 0;
|
|
913
918
|
return {
|
|
914
919
|
width: T,
|
|
915
920
|
["marginLeft"]: w,
|
|
@@ -931,15 +936,15 @@ function Columns(e) {
|
|
|
931
936
|
})
|
|
932
937
|
};
|
|
933
938
|
}
|
|
934
|
-
function
|
|
939
|
+
function S(v) {
|
|
935
940
|
var T, w;
|
|
936
941
|
return getSizesForBreakpoints(
|
|
937
942
|
((w = (T = e.builderContext.content) == null ? void 0 : T.meta) == null ? void 0 : w.breakpoints) || {}
|
|
938
943
|
)[v].max;
|
|
939
944
|
}
|
|
940
|
-
function
|
|
945
|
+
function k() {
|
|
941
946
|
return `
|
|
942
|
-
@media (max-width: ${
|
|
947
|
+
@media (max-width: ${S("medium")}px) {
|
|
943
948
|
.${e.builderBlock.id}-breakpoints {
|
|
944
949
|
flex-direction: var(--flex-dir-tablet);
|
|
945
950
|
align-items: stretch;
|
|
@@ -951,7 +956,7 @@ function Columns(e) {
|
|
|
951
956
|
}
|
|
952
957
|
}
|
|
953
958
|
|
|
954
|
-
@media (max-width: ${
|
|
959
|
+
@media (max-width: ${S("small")}px) {
|
|
955
960
|
.${e.builderBlock.id}-breakpoints {
|
|
956
961
|
flex-direction: var(--flex-dir);
|
|
957
962
|
align-items: stretch;
|
|
@@ -969,20 +974,20 @@ function Columns(e) {
|
|
|
969
974
|
"div",
|
|
970
975
|
{
|
|
971
976
|
className: `builder-columns ${e.builderBlock.id}-breakpoints div-53636e90`,
|
|
972
|
-
style:
|
|
977
|
+
style: y(),
|
|
973
978
|
children: [
|
|
974
|
-
/* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(InlinedStyles, { styles:
|
|
975
|
-
(
|
|
979
|
+
/* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(InlinedStyles, { styles: k() }) }),
|
|
980
|
+
(C = e.columns) == null ? void 0 : C.map((v, I) => /* @__PURE__ */ createElement(
|
|
976
981
|
"div",
|
|
977
982
|
{
|
|
978
983
|
className: "builder-column div-53636e90-2",
|
|
979
|
-
style:
|
|
980
|
-
key:
|
|
984
|
+
style: f(I),
|
|
985
|
+
key: I
|
|
981
986
|
},
|
|
982
987
|
/* @__PURE__ */ jsx(
|
|
983
988
|
Blocks,
|
|
984
989
|
{
|
|
985
|
-
path: `component.options.columns.${
|
|
990
|
+
path: `component.options.columns.${I}.blocks`,
|
|
986
991
|
parent: e.builderBlock.id,
|
|
987
992
|
styleProp: {
|
|
988
993
|
flexGrow: "1"
|
|
@@ -1471,14 +1476,14 @@ function Embed(e) {
|
|
|
1471
1476
|
return;
|
|
1472
1477
|
const s = t.current.getElementsByTagName("script");
|
|
1473
1478
|
for (let d = 0; d < s.length; d++) {
|
|
1474
|
-
const
|
|
1475
|
-
if (
|
|
1476
|
-
n.push(
|
|
1479
|
+
const g = s[d];
|
|
1480
|
+
if (g.src && !n.includes(g.src)) {
|
|
1481
|
+
n.push(g.src);
|
|
1477
1482
|
const b = document.createElement("script");
|
|
1478
|
-
b.async = !0, b.src =
|
|
1479
|
-
} else if (isJsScript(
|
|
1483
|
+
b.async = !0, b.src = g.src, document.head.appendChild(b);
|
|
1484
|
+
} else if (isJsScript(g) && !o.includes(g.innerText))
|
|
1480
1485
|
try {
|
|
1481
|
-
o.push(
|
|
1486
|
+
o.push(g.innerText), new Function(g.innerText)();
|
|
1482
1487
|
} catch (b) {
|
|
1483
1488
|
console.warn("`Embed`: Error running script:", b);
|
|
1484
1489
|
}
|
|
@@ -1524,13 +1529,13 @@ const componentInfo$6 = {
|
|
|
1524
1529
|
function n(r, l = 6e4) {
|
|
1525
1530
|
return new Promise((c, s) => {
|
|
1526
1531
|
const d = document.createElement("img");
|
|
1527
|
-
let
|
|
1532
|
+
let g = !1;
|
|
1528
1533
|
d.onload = () => {
|
|
1529
|
-
|
|
1534
|
+
g = !0, c(d);
|
|
1530
1535
|
}, d.addEventListener("error", (b) => {
|
|
1531
1536
|
console.warn("Image load failed", b.error), s(b.error);
|
|
1532
1537
|
}), d.src = r, setTimeout(() => {
|
|
1533
|
-
|
|
1538
|
+
g || s(new Error("Image load timed out"));
|
|
1534
1539
|
}, l);
|
|
1535
1540
|
});
|
|
1536
1541
|
}
|
|
@@ -2111,7 +2116,7 @@ const findParentElement = (e, t, n = !0) => {
|
|
|
2111
2116
|
builderElementIndex: n && i ? [].slice.call(document.getElementsByClassName(i)).indexOf(n) : void 0
|
|
2112
2117
|
}
|
|
2113
2118
|
};
|
|
2114
|
-
}, SDK_VERSION = "0.7.
|
|
2119
|
+
}, SDK_VERSION = "0.7.6", registerInsertMenu = () => {
|
|
2115
2120
|
register("insertMenu", {
|
|
2116
2121
|
name: "_default",
|
|
2117
2122
|
default: !0,
|
|
@@ -2161,21 +2166,21 @@ const setupBrowserForEditing = (e = {}) => {
|
|
|
2161
2166
|
switch (i.type) {
|
|
2162
2167
|
case "builder.evaluate": {
|
|
2163
2168
|
const r = i.data.text, l = i.data.arguments || [], c = i.data.id, s = new Function(r);
|
|
2164
|
-
let d,
|
|
2169
|
+
let d, g = null;
|
|
2165
2170
|
try {
|
|
2166
2171
|
d = s.apply(null, l);
|
|
2167
2172
|
} catch (b) {
|
|
2168
|
-
|
|
2173
|
+
g = b;
|
|
2169
2174
|
}
|
|
2170
|
-
|
|
2175
|
+
g ? (o = window.parent) == null || o.postMessage({
|
|
2171
2176
|
type: "builder.evaluateError",
|
|
2172
2177
|
data: {
|
|
2173
2178
|
id: c,
|
|
2174
|
-
error:
|
|
2179
|
+
error: g.message
|
|
2175
2180
|
}
|
|
2176
2181
|
}, "*") : d && typeof d.then == "function" ? d.then((b) => {
|
|
2177
|
-
var
|
|
2178
|
-
(
|
|
2182
|
+
var y;
|
|
2183
|
+
(y = window.parent) == null || y.postMessage({
|
|
2179
2184
|
type: "builder.evaluateResult",
|
|
2180
2185
|
data: {
|
|
2181
2186
|
id: c,
|
|
@@ -2198,7 +2203,7 @@ function EnableEditor(e) {
|
|
|
2198
2203
|
var T, w, R, j, B, A, P;
|
|
2199
2204
|
const t = useRef(null), [n, i] = useState(() => 0);
|
|
2200
2205
|
function o(u) {
|
|
2201
|
-
var h, x, p,
|
|
2206
|
+
var h, x, p, E, F;
|
|
2202
2207
|
const m = {
|
|
2203
2208
|
...e.builderContextSignal.content,
|
|
2204
2209
|
...u,
|
|
@@ -2209,7 +2214,7 @@ function EnableEditor(e) {
|
|
|
2209
2214
|
meta: {
|
|
2210
2215
|
...(x = e.builderContextSignal.content) == null ? void 0 : x.meta,
|
|
2211
2216
|
...u == null ? void 0 : u.meta,
|
|
2212
|
-
breakpoints: ((p = u == null ? void 0 : u.meta) == null ? void 0 : p.breakpoints) || ((F = (
|
|
2217
|
+
breakpoints: ((p = u == null ? void 0 : u.meta) == null ? void 0 : p.breakpoints) || ((F = (E = e.builderContextSignal.content) == null ? void 0 : E.meta) == null ? void 0 : F.breakpoints)
|
|
2213
2218
|
}
|
|
2214
2219
|
};
|
|
2215
2220
|
e.setBuilderContextSignal((_) => ({
|
|
@@ -2227,8 +2232,8 @@ function EnableEditor(e) {
|
|
|
2227
2232
|
if (m)
|
|
2228
2233
|
switch (m.type) {
|
|
2229
2234
|
case "builder.configureSdk": {
|
|
2230
|
-
const x = m.data, { breakpoints: p, contentId:
|
|
2231
|
-
if (!
|
|
2235
|
+
const x = m.data, { breakpoints: p, contentId: E } = x;
|
|
2236
|
+
if (!E || E !== ((h = e.builderContextSignal.content) == null ? void 0 : h.id))
|
|
2232
2237
|
return;
|
|
2233
2238
|
p && o({
|
|
2234
2239
|
meta: {
|
|
@@ -2238,8 +2243,8 @@ function EnableEditor(e) {
|
|
|
2238
2243
|
break;
|
|
2239
2244
|
}
|
|
2240
2245
|
case "builder.contentUpdate": {
|
|
2241
|
-
const x = m.data, p = x.key || x.alias || x.entry || x.modelName,
|
|
2242
|
-
p === e.model && (o(
|
|
2246
|
+
const x = m.data, p = x.key || x.alias || x.entry || x.modelName, E = x.data;
|
|
2247
|
+
p === e.model && (o(E), i(n + 1));
|
|
2243
2248
|
break;
|
|
2244
2249
|
}
|
|
2245
2250
|
}
|
|
@@ -2255,8 +2260,8 @@ function EnableEditor(e) {
|
|
|
2255
2260
|
rootSetState: e.builderContextSignal.rootSetState
|
|
2256
2261
|
});
|
|
2257
2262
|
}
|
|
2258
|
-
const [s, d] = useState(() => ({})), [
|
|
2259
|
-
function
|
|
2263
|
+
const [s, d] = useState(() => ({})), [g, b] = useState(() => !1);
|
|
2264
|
+
function y(u) {
|
|
2260
2265
|
var m, h;
|
|
2261
2266
|
if (e.builderContextSignal.content) {
|
|
2262
2267
|
const x = (m = e.builderContextSignal.content) == null ? void 0 : m.testVariationId, p = (h = e.builderContextSignal.content) == null ? void 0 : h.id;
|
|
@@ -2267,12 +2272,12 @@ function EnableEditor(e) {
|
|
|
2267
2272
|
apiKey: e.apiKey,
|
|
2268
2273
|
variationId: x !== p ? x : void 0,
|
|
2269
2274
|
...getInteractionPropertiesForEvent(u),
|
|
2270
|
-
unique: !
|
|
2275
|
+
unique: !g
|
|
2271
2276
|
});
|
|
2272
2277
|
}
|
|
2273
|
-
|
|
2278
|
+
g || b(!0);
|
|
2274
2279
|
}
|
|
2275
|
-
function
|
|
2280
|
+
function f(u) {
|
|
2276
2281
|
return u.replace(
|
|
2277
2282
|
/{{([^}]+)}}/g,
|
|
2278
2283
|
(m, h) => evaluate({
|
|
@@ -2284,32 +2289,32 @@ function EnableEditor(e) {
|
|
|
2284
2289
|
})
|
|
2285
2290
|
);
|
|
2286
2291
|
}
|
|
2287
|
-
function
|
|
2292
|
+
function S({ url: u, key: m }) {
|
|
2288
2293
|
fetch$1(u).then((h) => h.json()).then((h) => {
|
|
2289
|
-
var p,
|
|
2294
|
+
var p, E;
|
|
2290
2295
|
const x = {
|
|
2291
2296
|
...e.builderContextSignal.rootState,
|
|
2292
2297
|
[m]: h
|
|
2293
2298
|
};
|
|
2294
|
-
(
|
|
2299
|
+
(E = (p = e.builderContextSignal).rootSetState) == null || E.call(p, x), s[m] = !0;
|
|
2295
2300
|
}).catch((h) => {
|
|
2296
2301
|
console.error("error fetching dynamic data", u, h);
|
|
2297
2302
|
});
|
|
2298
2303
|
}
|
|
2299
|
-
function
|
|
2304
|
+
function k() {
|
|
2300
2305
|
var m, h;
|
|
2301
2306
|
const u = ((h = (m = e.builderContextSignal.content) == null ? void 0 : m.data) == null ? void 0 : h.httpRequests) ?? {};
|
|
2302
2307
|
Object.entries(u).forEach(([x, p]) => {
|
|
2303
2308
|
if (p && (!s[x] || isEditing())) {
|
|
2304
|
-
const
|
|
2305
|
-
|
|
2306
|
-
url:
|
|
2309
|
+
const E = f(p);
|
|
2310
|
+
S({
|
|
2311
|
+
url: E,
|
|
2307
2312
|
key: x
|
|
2308
2313
|
});
|
|
2309
2314
|
}
|
|
2310
2315
|
});
|
|
2311
2316
|
}
|
|
2312
|
-
function
|
|
2317
|
+
function C() {
|
|
2313
2318
|
isEditing() && window.dispatchEvent(
|
|
2314
2319
|
new CustomEvent(
|
|
2315
2320
|
"builder:component:stateChange",
|
|
@@ -2343,10 +2348,10 @@ function EnableEditor(e) {
|
|
|
2343
2348
|
(x = window.parent) == null || x.postMessage(h, "*");
|
|
2344
2349
|
}), window.addEventListener(
|
|
2345
2350
|
"builder:component:stateChangeListenerActivated",
|
|
2346
|
-
|
|
2351
|
+
C
|
|
2347
2352
|
);
|
|
2348
2353
|
}
|
|
2349
|
-
function
|
|
2354
|
+
function I(u) {
|
|
2350
2355
|
const m = new URL(location.href).searchParams, h = m.get("builder.preview"), x = m.get(
|
|
2351
2356
|
`builder.preview.${h}`
|
|
2352
2357
|
), p = m.get("apiKey") || m.get("builder.space");
|
|
@@ -2354,8 +2359,8 @@ function EnableEditor(e) {
|
|
|
2354
2359
|
model: e.model,
|
|
2355
2360
|
apiKey: e.apiKey,
|
|
2356
2361
|
apiVersion: e.builderContextSignal.apiVersion
|
|
2357
|
-
}).then((
|
|
2358
|
-
|
|
2362
|
+
}).then((E) => {
|
|
2363
|
+
E && o(E);
|
|
2359
2364
|
});
|
|
2360
2365
|
}
|
|
2361
2366
|
return useEffect(() => {
|
|
@@ -2374,24 +2379,24 @@ function EnableEditor(e) {
|
|
|
2374
2379
|
var u;
|
|
2375
2380
|
return (u = t.current) == null || u.addEventListener(
|
|
2376
2381
|
"initpreviewingbldr",
|
|
2377
|
-
|
|
2382
|
+
I
|
|
2378
2383
|
), () => {
|
|
2379
2384
|
var m;
|
|
2380
2385
|
return (m = t.current) == null ? void 0 : m.removeEventListener(
|
|
2381
2386
|
"initpreviewingbldr",
|
|
2382
|
-
|
|
2387
|
+
I
|
|
2383
2388
|
);
|
|
2384
2389
|
};
|
|
2385
2390
|
}, []), useEffect(() => {
|
|
2386
2391
|
var u, m;
|
|
2387
2392
|
if (isBrowser()) {
|
|
2388
2393
|
if (isEditing() && t.current && t.current.dispatchEvent(new CustomEvent("initeditingbldr")), e.builderContextSignal.content && getDefaultCanTrack(e.canTrack)) {
|
|
2389
|
-
const x = (u = e.builderContextSignal.content) == null ? void 0 : u.testVariationId, p = (m = e.builderContextSignal.content) == null ? void 0 : m.id,
|
|
2394
|
+
const x = (u = e.builderContextSignal.content) == null ? void 0 : u.testVariationId, p = (m = e.builderContextSignal.content) == null ? void 0 : m.id, E = e.apiKey;
|
|
2390
2395
|
_track({
|
|
2391
2396
|
type: "impression",
|
|
2392
2397
|
canTrack: !0,
|
|
2393
2398
|
contentId: p,
|
|
2394
|
-
apiKey:
|
|
2399
|
+
apiKey: E,
|
|
2395
2400
|
variationId: x !== p ? x : void 0
|
|
2396
2401
|
});
|
|
2397
2402
|
}
|
|
@@ -2400,7 +2405,7 @@ function EnableEditor(e) {
|
|
|
2400
2405
|
}, []), useEffect(() => {
|
|
2401
2406
|
e.apiKey || logger.error(
|
|
2402
2407
|
"No API key provided to `RenderContent` component. This can cause issues. Please provide an API key using the `apiKey` prop."
|
|
2403
|
-
), c(),
|
|
2408
|
+
), c(), k(), C();
|
|
2404
2409
|
}, []), useEffect(() => {
|
|
2405
2410
|
e.content && o(e.content);
|
|
2406
2411
|
}, [e.content]), useEffect(() => {
|
|
@@ -2410,20 +2415,20 @@ function EnableEditor(e) {
|
|
|
2410
2415
|
(w = (T = e.builderContextSignal.content) == null ? void 0 : T.data) == null ? void 0 : w.jsCode,
|
|
2411
2416
|
e.builderContextSignal.rootState
|
|
2412
2417
|
]), useEffect(() => {
|
|
2413
|
-
|
|
2418
|
+
k();
|
|
2414
2419
|
}, [(j = (R = e.builderContextSignal.content) == null ? void 0 : R.data) == null ? void 0 : j.httpRequests]), useEffect(() => {
|
|
2415
|
-
|
|
2420
|
+
C();
|
|
2416
2421
|
}, [e.builderContextSignal.rootState]), useEffect(() => () => {
|
|
2417
2422
|
isBrowser() && (window.removeEventListener("message", l), window.removeEventListener(
|
|
2418
2423
|
"builder:component:stateChangeListenerActivated",
|
|
2419
|
-
|
|
2424
|
+
C
|
|
2420
2425
|
));
|
|
2421
2426
|
}, []), /* @__PURE__ */ jsx(builderContext.Provider, { value: e.builderContextSignal, children: e.builderContextSignal.content ? /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ createElement(
|
|
2422
2427
|
"div",
|
|
2423
2428
|
{
|
|
2424
2429
|
key: n,
|
|
2425
2430
|
ref: t,
|
|
2426
|
-
onClick: (u) =>
|
|
2431
|
+
onClick: (u) => y(u),
|
|
2427
2432
|
"builder-content-id": (B = e.builderContextSignal.content) == null ? void 0 : B.id,
|
|
2428
2433
|
"builder-model": e.model,
|
|
2429
2434
|
...e.showContent ? {} : {
|
|
@@ -2503,22 +2508,17 @@ const getContextStateInitialValue = ({
|
|
|
2503
2508
|
locale: n
|
|
2504
2509
|
}) => {
|
|
2505
2510
|
var a, r, l;
|
|
2506
|
-
const i = {};
|
|
2507
|
-
(
|
|
2508
|
-
|
|
2509
|
-
|
|
2510
|
-
|
|
2511
|
-
|
|
2512
|
-
...(l = e == null ? void 0 : e.data) == null ? void 0 : l.state,
|
|
2511
|
+
const i = {}, o = ((a = e == null ? void 0 : e.data) == null ? void 0 : a.state) || {};
|
|
2512
|
+
return (l = (r = e == null ? void 0 : e.data) == null ? void 0 : r.inputs) == null || l.forEach((c) => {
|
|
2513
|
+
c.name && c.defaultValue !== void 0 && (i[c.name] = c.defaultValue);
|
|
2514
|
+
}), {
|
|
2515
|
+
...i,
|
|
2516
|
+
...o,
|
|
2513
2517
|
...t,
|
|
2514
2518
|
...n ? {
|
|
2515
2519
|
locale: n
|
|
2516
2520
|
} : {}
|
|
2517
2521
|
};
|
|
2518
|
-
return {
|
|
2519
|
-
...i,
|
|
2520
|
-
...o
|
|
2521
|
-
};
|
|
2522
2522
|
}, getContentInitialValue = ({
|
|
2523
2523
|
content: e,
|
|
2524
2524
|
data: t
|
|
@@ -2531,22 +2531,22 @@ const getContextStateInitialValue = ({
|
|
|
2531
2531
|
meta: e == null ? void 0 : e.meta
|
|
2532
2532
|
} : void 0;
|
|
2533
2533
|
function ContentComponent(e) {
|
|
2534
|
-
var c, s, d,
|
|
2534
|
+
var c, s, d, g, b, y, f;
|
|
2535
2535
|
const [t, n] = useState(
|
|
2536
2536
|
() => {
|
|
2537
|
-
var
|
|
2537
|
+
var S, k;
|
|
2538
2538
|
return getUpdateVariantVisibilityScript({
|
|
2539
2539
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion, @typescript-eslint/no-non-null-asserted-optional-chain
|
|
2540
|
-
variationId: (
|
|
2540
|
+
variationId: (S = e.content) == null ? void 0 : S.testVariationId,
|
|
2541
2541
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion, @typescript-eslint/no-non-null-asserted-optional-chain
|
|
2542
|
-
contentId: (
|
|
2542
|
+
contentId: (k = e.content) == null ? void 0 : k.id
|
|
2543
2543
|
});
|
|
2544
2544
|
}
|
|
2545
2545
|
);
|
|
2546
|
-
function i(
|
|
2547
|
-
l((
|
|
2548
|
-
...
|
|
2549
|
-
rootState:
|
|
2546
|
+
function i(S) {
|
|
2547
|
+
l((k) => ({
|
|
2548
|
+
...k,
|
|
2549
|
+
rootState: S
|
|
2550
2550
|
}));
|
|
2551
2551
|
}
|
|
2552
2552
|
const [o, a] = useState(
|
|
@@ -2560,11 +2560,11 @@ function ContentComponent(e) {
|
|
|
2560
2560
|
...components,
|
|
2561
2561
|
...e.customComponents || []
|
|
2562
2562
|
].reduce(
|
|
2563
|
-
(
|
|
2564
|
-
...
|
|
2565
|
-
[
|
|
2566
|
-
component:
|
|
2567
|
-
...serializeComponentInfo(
|
|
2563
|
+
(S, { component: k, ...C }) => ({
|
|
2564
|
+
...S,
|
|
2565
|
+
[C.name]: {
|
|
2566
|
+
component: k,
|
|
2567
|
+
...serializeComponentInfo(C)
|
|
2568
2568
|
}
|
|
2569
2569
|
}),
|
|
2570
2570
|
{}
|
|
@@ -2594,9 +2594,9 @@ function ContentComponent(e) {
|
|
|
2594
2594
|
...components,
|
|
2595
2595
|
...e.customComponents || []
|
|
2596
2596
|
].reduce(
|
|
2597
|
-
(
|
|
2598
|
-
...
|
|
2599
|
-
[
|
|
2597
|
+
(S, { component: k, ...C }) => ({
|
|
2598
|
+
...S,
|
|
2599
|
+
[C.name]: serializeComponentInfo(C)
|
|
2600
2600
|
}),
|
|
2601
2601
|
{}
|
|
2602
2602
|
),
|
|
@@ -2629,13 +2629,13 @@ function ContentComponent(e) {
|
|
|
2629
2629
|
{
|
|
2630
2630
|
contentId: (c = r.content) == null ? void 0 : c.id,
|
|
2631
2631
|
cssCode: (d = (s = r.content) == null ? void 0 : s.data) == null ? void 0 : d.cssCode,
|
|
2632
|
-
customFonts: (b = (
|
|
2632
|
+
customFonts: (b = (g = r.content) == null ? void 0 : g.data) == null ? void 0 : b.customFonts
|
|
2633
2633
|
}
|
|
2634
2634
|
) }),
|
|
2635
2635
|
/* @__PURE__ */ jsx(
|
|
2636
2636
|
Blocks,
|
|
2637
2637
|
{
|
|
2638
|
-
blocks: (
|
|
2638
|
+
blocks: (f = (y = r.content) == null ? void 0 : y.data) == null ? void 0 : f.blocks,
|
|
2639
2639
|
context: r,
|
|
2640
2640
|
registeredComponents: o
|
|
2641
2641
|
}
|