@builder.io/sdk-react 0.7.5 → 0.8.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/lib/browser/index.cjs +8 -8
- package/lib/browser/index.mjs +161 -158
- package/lib/edge/index.cjs +9 -9
- package/lib/edge/index.mjs +174 -171
- package/lib/node/index.cjs +8 -8
- package/lib/node/index.mjs +130 -127
- package/package.json +7 -1
- package/types/constants/sdk-version.d.ts +1 -1
package/lib/node/index.mjs
CHANGED
|
@@ -178,17 +178,17 @@ output;
|
|
|
178
178
|
}), s = getIsolateContext(), d = s.global;
|
|
179
179
|
d.setSync("global", d.derefInto()), d.setSync("log", function(...y) {
|
|
180
180
|
console.log(...y);
|
|
181
|
-
}), d.setSync(BUILDER_SET_STATE_NAME, function(y,
|
|
182
|
-
set(r, y,
|
|
183
|
-
}), c.forEach(([y,
|
|
184
|
-
const
|
|
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
186
|
y === "builder" ? {
|
|
187
|
-
...
|
|
188
|
-
getUserAttributes: () =>
|
|
189
|
-
} :
|
|
187
|
+
...f,
|
|
188
|
+
getUserAttributes: () => f.getUserAttributes()
|
|
189
|
+
} : f
|
|
190
190
|
) : null;
|
|
191
|
-
d.setSync(getSyncValName(y),
|
|
191
|
+
d.setSync(getSyncValName(y), S);
|
|
192
192
|
}), d.setSync(INJECTED_IVM_GLOBAL, ivm);
|
|
193
193
|
const g = processCode({
|
|
194
194
|
code: e,
|
|
@@ -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,7 +421,7 @@ 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 "";
|
|
@@ -672,8 +672,8 @@ function Block(e) {
|
|
|
672
672
|
});
|
|
673
673
|
}
|
|
674
674
|
function i() {
|
|
675
|
-
var
|
|
676
|
-
return (
|
|
675
|
+
var f;
|
|
676
|
+
return (f = e.block.repeat) != null && f.collection ? e.block : getProcessedBlock({
|
|
677
677
|
block: e.block,
|
|
678
678
|
localState: e.context.localState,
|
|
679
679
|
rootState: e.context.rootState,
|
|
@@ -686,29 +686,32 @@ function Block(e) {
|
|
|
686
686
|
return e.block.tagName || "div";
|
|
687
687
|
}
|
|
688
688
|
function a() {
|
|
689
|
-
var
|
|
690
|
-
|
|
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;
|
|
691
694
|
}
|
|
692
695
|
function r() {
|
|
693
|
-
var
|
|
694
|
-
return !((
|
|
696
|
+
var S;
|
|
697
|
+
return !((S = t == null ? void 0 : t()) != null && S.component) && !n() ? i().children ?? [] : [];
|
|
695
698
|
}
|
|
696
699
|
function l() {
|
|
697
|
-
var
|
|
700
|
+
var f, S, k, C, v;
|
|
698
701
|
return {
|
|
699
702
|
blockChildren: i().children ?? [],
|
|
700
|
-
componentRef: (
|
|
703
|
+
componentRef: (f = t == null ? void 0 : t()) == null ? void 0 : f.component,
|
|
701
704
|
componentOptions: {
|
|
702
705
|
...getBlockComponentOptions(i()),
|
|
703
706
|
builderContext: e.context,
|
|
704
|
-
...((
|
|
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" ? {
|
|
705
708
|
builderComponents: e.registeredComponents
|
|
706
709
|
} : {}
|
|
707
710
|
},
|
|
708
711
|
context: c,
|
|
709
712
|
registeredComponents: e.registeredComponents,
|
|
710
713
|
builderBlock: i(),
|
|
711
|
-
includeBlockProps: ((
|
|
714
|
+
includeBlockProps: ((C = t == null ? void 0 : t()) == null ? void 0 : C.noWrap) === !0,
|
|
712
715
|
isInteractive: !((v = t == null ? void 0 : t()) != null && v.isRSC)
|
|
713
716
|
};
|
|
714
717
|
}
|
|
@@ -735,14 +738,14 @@ function Block(e) {
|
|
|
735
738
|
hasChildren: !1
|
|
736
739
|
}
|
|
737
740
|
) }) : null,
|
|
738
|
-
!isEmptyHtmlElement(o()) && n() ? /* @__PURE__ */ jsx(Fragment, { children: (g = n()) == null ? void 0 : g.map((
|
|
741
|
+
!isEmptyHtmlElement(o()) && n() ? /* @__PURE__ */ jsx(Fragment, { children: (g = n()) == null ? void 0 : g.map((f, S) => /* @__PURE__ */ jsx(
|
|
739
742
|
RepeatedBlock,
|
|
740
743
|
{
|
|
741
|
-
repeatContext:
|
|
742
|
-
block:
|
|
744
|
+
repeatContext: f.context,
|
|
745
|
+
block: f.block,
|
|
743
746
|
registeredComponents: e.registeredComponents
|
|
744
747
|
},
|
|
745
|
-
|
|
748
|
+
S
|
|
746
749
|
)) }) : null,
|
|
747
750
|
!isEmptyHtmlElement(o()) && !n() ? /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs(
|
|
748
751
|
BlockWrapper,
|
|
@@ -765,22 +768,22 @@ function Block(e) {
|
|
|
765
768
|
isInteractive: l().isInteractive
|
|
766
769
|
}
|
|
767
770
|
),
|
|
768
|
-
(b = r()) == null ? void 0 : b.map((
|
|
771
|
+
(b = r()) == null ? void 0 : b.map((f) => /* @__PURE__ */ jsx(
|
|
769
772
|
Block,
|
|
770
773
|
{
|
|
771
|
-
block:
|
|
774
|
+
block: f,
|
|
772
775
|
context: c,
|
|
773
776
|
registeredComponents: e.registeredComponents
|
|
774
777
|
},
|
|
775
|
-
"block-" +
|
|
778
|
+
"block-" + f.id
|
|
776
779
|
)),
|
|
777
|
-
(y = r()) == null ? void 0 : y.map((
|
|
780
|
+
(y = r()) == null ? void 0 : y.map((f) => /* @__PURE__ */ jsx(
|
|
778
781
|
BlockStyles,
|
|
779
782
|
{
|
|
780
|
-
block:
|
|
783
|
+
block: f,
|
|
781
784
|
context: c
|
|
782
785
|
},
|
|
783
|
-
"block-style-" +
|
|
786
|
+
"block-style-" + f.id
|
|
784
787
|
))
|
|
785
788
|
]
|
|
786
789
|
}
|
|
@@ -872,31 +875,31 @@ function Blocks(e) {
|
|
|
872
875
|
);
|
|
873
876
|
}
|
|
874
877
|
function Columns(e) {
|
|
875
|
-
var
|
|
878
|
+
var C;
|
|
876
879
|
const [t, n] = useState(
|
|
877
880
|
() => typeof e.space == "number" ? e.space || 0 : 20
|
|
878
881
|
), [i, o] = useState(() => e.columns || []), [a, r] = useState(
|
|
879
882
|
() => e.stackColumnsAt || "tablet"
|
|
880
883
|
);
|
|
881
884
|
function l(v) {
|
|
882
|
-
var
|
|
883
|
-
return ((
|
|
885
|
+
var I;
|
|
886
|
+
return ((I = i[v]) == null ? void 0 : I.width) || 100 / i.length;
|
|
884
887
|
}
|
|
885
888
|
function c(v) {
|
|
886
|
-
const
|
|
887
|
-
return `calc(${l(v)}% - ${
|
|
889
|
+
const I = t * (i.length - 1) / i.length;
|
|
890
|
+
return `calc(${l(v)}% - ${I}px)`;
|
|
888
891
|
}
|
|
889
892
|
function s({
|
|
890
893
|
stackedStyle: v,
|
|
891
|
-
desktopStyle:
|
|
894
|
+
desktopStyle: I
|
|
892
895
|
}) {
|
|
893
|
-
return a === "tablet" ? v :
|
|
896
|
+
return a === "tablet" ? v : I;
|
|
894
897
|
}
|
|
895
898
|
function d({
|
|
896
899
|
stackedStyle: v,
|
|
897
|
-
desktopStyle:
|
|
900
|
+
desktopStyle: I
|
|
898
901
|
}) {
|
|
899
|
-
return a === "never" ?
|
|
902
|
+
return a === "never" ? I : v;
|
|
900
903
|
}
|
|
901
904
|
const [g, b] = useState(
|
|
902
905
|
() => e.stackColumnsAt === "never" ? "row" : e.reverseColumnsWhenStacked ? "column-reverse" : "column"
|
|
@@ -910,8 +913,8 @@ function Columns(e) {
|
|
|
910
913
|
})
|
|
911
914
|
};
|
|
912
915
|
}
|
|
913
|
-
function
|
|
914
|
-
const
|
|
916
|
+
function f(v) {
|
|
917
|
+
const I = v === 0 ? 0 : t, T = c(v), w = `${I}px`, R = "100%", j = 0;
|
|
915
918
|
return {
|
|
916
919
|
width: T,
|
|
917
920
|
["marginLeft"]: w,
|
|
@@ -933,15 +936,15 @@ function Columns(e) {
|
|
|
933
936
|
})
|
|
934
937
|
};
|
|
935
938
|
}
|
|
936
|
-
function
|
|
939
|
+
function S(v) {
|
|
937
940
|
var T, w;
|
|
938
941
|
return getSizesForBreakpoints(
|
|
939
942
|
((w = (T = e.builderContext.content) == null ? void 0 : T.meta) == null ? void 0 : w.breakpoints) || {}
|
|
940
943
|
)[v].max;
|
|
941
944
|
}
|
|
942
|
-
function
|
|
945
|
+
function k() {
|
|
943
946
|
return `
|
|
944
|
-
@media (max-width: ${
|
|
947
|
+
@media (max-width: ${S("medium")}px) {
|
|
945
948
|
.${e.builderBlock.id}-breakpoints {
|
|
946
949
|
flex-direction: var(--flex-dir-tablet);
|
|
947
950
|
align-items: stretch;
|
|
@@ -953,7 +956,7 @@ function Columns(e) {
|
|
|
953
956
|
}
|
|
954
957
|
}
|
|
955
958
|
|
|
956
|
-
@media (max-width: ${
|
|
959
|
+
@media (max-width: ${S("small")}px) {
|
|
957
960
|
.${e.builderBlock.id}-breakpoints {
|
|
958
961
|
flex-direction: var(--flex-dir);
|
|
959
962
|
align-items: stretch;
|
|
@@ -973,18 +976,18 @@ function Columns(e) {
|
|
|
973
976
|
className: `builder-columns ${e.builderBlock.id}-breakpoints div-53636e90`,
|
|
974
977
|
style: y(),
|
|
975
978
|
children: [
|
|
976
|
-
/* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(InlinedStyles, { styles:
|
|
977
|
-
(
|
|
979
|
+
/* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(InlinedStyles, { styles: k() }) }),
|
|
980
|
+
(C = e.columns) == null ? void 0 : C.map((v, I) => /* @__PURE__ */ createElement(
|
|
978
981
|
"div",
|
|
979
982
|
{
|
|
980
983
|
className: "builder-column div-53636e90-2",
|
|
981
|
-
style:
|
|
982
|
-
key:
|
|
984
|
+
style: f(I),
|
|
985
|
+
key: I
|
|
983
986
|
},
|
|
984
987
|
/* @__PURE__ */ jsx(
|
|
985
988
|
Blocks,
|
|
986
989
|
{
|
|
987
|
-
path: `component.options.columns.${
|
|
990
|
+
path: `component.options.columns.${I}.blocks`,
|
|
988
991
|
parent: e.builderBlock.id,
|
|
989
992
|
styleProp: {
|
|
990
993
|
flexGrow: "1"
|
|
@@ -2113,7 +2116,7 @@ const findParentElement = (e, t, n = !0) => {
|
|
|
2113
2116
|
builderElementIndex: n && i ? [].slice.call(document.getElementsByClassName(i)).indexOf(n) : void 0
|
|
2114
2117
|
}
|
|
2115
2118
|
};
|
|
2116
|
-
}, SDK_VERSION = "0.
|
|
2119
|
+
}, SDK_VERSION = "0.8.0", registerInsertMenu = () => {
|
|
2117
2120
|
register("insertMenu", {
|
|
2118
2121
|
name: "_default",
|
|
2119
2122
|
default: !0,
|
|
@@ -2200,8 +2203,8 @@ function EnableEditor(e) {
|
|
|
2200
2203
|
var T, w, R, j, B, A, P;
|
|
2201
2204
|
const t = useRef(null), [n, i] = useState(() => 0);
|
|
2202
2205
|
function o(u) {
|
|
2203
|
-
var h,
|
|
2204
|
-
const
|
|
2206
|
+
var h, x, p, E, F;
|
|
2207
|
+
const m = {
|
|
2205
2208
|
...e.builderContextSignal.content,
|
|
2206
2209
|
...u,
|
|
2207
2210
|
data: {
|
|
@@ -2209,14 +2212,14 @@ function EnableEditor(e) {
|
|
|
2209
2212
|
...u == null ? void 0 : u.data
|
|
2210
2213
|
},
|
|
2211
2214
|
meta: {
|
|
2212
|
-
...(
|
|
2215
|
+
...(x = e.builderContextSignal.content) == null ? void 0 : x.meta,
|
|
2213
2216
|
...u == null ? void 0 : u.meta,
|
|
2214
|
-
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)
|
|
2215
2218
|
}
|
|
2216
2219
|
};
|
|
2217
2220
|
e.setBuilderContextSignal((_) => ({
|
|
2218
2221
|
..._,
|
|
2219
|
-
content:
|
|
2222
|
+
content: m
|
|
2220
2223
|
}));
|
|
2221
2224
|
}
|
|
2222
2225
|
useState(() => 0);
|
|
@@ -2225,12 +2228,12 @@ function EnableEditor(e) {
|
|
|
2225
2228
|
);
|
|
2226
2229
|
function l(u) {
|
|
2227
2230
|
var h;
|
|
2228
|
-
const { data:
|
|
2229
|
-
if (
|
|
2230
|
-
switch (
|
|
2231
|
+
const { data: m } = u;
|
|
2232
|
+
if (m)
|
|
2233
|
+
switch (m.type) {
|
|
2231
2234
|
case "builder.configureSdk": {
|
|
2232
|
-
const
|
|
2233
|
-
if (!
|
|
2235
|
+
const x = m.data, { breakpoints: p, contentId: E } = x;
|
|
2236
|
+
if (!E || E !== ((h = e.builderContextSignal.content) == null ? void 0 : h.id))
|
|
2234
2237
|
return;
|
|
2235
2238
|
p && o({
|
|
2236
2239
|
meta: {
|
|
@@ -2240,15 +2243,15 @@ function EnableEditor(e) {
|
|
|
2240
2243
|
break;
|
|
2241
2244
|
}
|
|
2242
2245
|
case "builder.contentUpdate": {
|
|
2243
|
-
const
|
|
2244
|
-
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));
|
|
2245
2248
|
break;
|
|
2246
2249
|
}
|
|
2247
2250
|
}
|
|
2248
2251
|
}
|
|
2249
2252
|
function c() {
|
|
2250
|
-
var
|
|
2251
|
-
const u = (h = (
|
|
2253
|
+
var m, h;
|
|
2254
|
+
const u = (h = (m = e.builderContextSignal.content) == null ? void 0 : m.data) == null ? void 0 : h.jsCode;
|
|
2252
2255
|
u && evaluate({
|
|
2253
2256
|
code: u,
|
|
2254
2257
|
context: e.context || {},
|
|
@@ -2259,25 +2262,25 @@ function EnableEditor(e) {
|
|
|
2259
2262
|
}
|
|
2260
2263
|
const [s, d] = useState(() => ({})), [g, b] = useState(() => !1);
|
|
2261
2264
|
function y(u) {
|
|
2262
|
-
var
|
|
2265
|
+
var m, h;
|
|
2263
2266
|
if (e.builderContextSignal.content) {
|
|
2264
|
-
const
|
|
2267
|
+
const x = (m = e.builderContextSignal.content) == null ? void 0 : m.testVariationId, p = (h = e.builderContextSignal.content) == null ? void 0 : h.id;
|
|
2265
2268
|
_track({
|
|
2266
2269
|
type: "click",
|
|
2267
2270
|
canTrack: getDefaultCanTrack(e.canTrack),
|
|
2268
2271
|
contentId: p,
|
|
2269
2272
|
apiKey: e.apiKey,
|
|
2270
|
-
variationId:
|
|
2273
|
+
variationId: x !== p ? x : void 0,
|
|
2271
2274
|
...getInteractionPropertiesForEvent(u),
|
|
2272
2275
|
unique: !g
|
|
2273
2276
|
});
|
|
2274
2277
|
}
|
|
2275
2278
|
g || b(!0);
|
|
2276
2279
|
}
|
|
2277
|
-
function
|
|
2280
|
+
function f(u) {
|
|
2278
2281
|
return u.replace(
|
|
2279
2282
|
/{{([^}]+)}}/g,
|
|
2280
|
-
(
|
|
2283
|
+
(m, h) => evaluate({
|
|
2281
2284
|
code: h,
|
|
2282
2285
|
context: e.context || {},
|
|
2283
2286
|
localState: void 0,
|
|
@@ -2286,32 +2289,32 @@ function EnableEditor(e) {
|
|
|
2286
2289
|
})
|
|
2287
2290
|
);
|
|
2288
2291
|
}
|
|
2289
|
-
function
|
|
2292
|
+
function S({ url: u, key: m }) {
|
|
2290
2293
|
fetch$1(u).then((h) => h.json()).then((h) => {
|
|
2291
|
-
var p,
|
|
2292
|
-
const
|
|
2294
|
+
var p, E;
|
|
2295
|
+
const x = {
|
|
2293
2296
|
...e.builderContextSignal.rootState,
|
|
2294
|
-
[
|
|
2297
|
+
[m]: h
|
|
2295
2298
|
};
|
|
2296
|
-
(
|
|
2299
|
+
(E = (p = e.builderContextSignal).rootSetState) == null || E.call(p, x), s[m] = !0;
|
|
2297
2300
|
}).catch((h) => {
|
|
2298
2301
|
console.error("error fetching dynamic data", u, h);
|
|
2299
2302
|
});
|
|
2300
2303
|
}
|
|
2301
|
-
function
|
|
2302
|
-
var
|
|
2303
|
-
const u = ((h = (
|
|
2304
|
-
Object.entries(u).forEach(([
|
|
2305
|
-
if (p && (!s[
|
|
2306
|
-
const
|
|
2307
|
-
|
|
2308
|
-
url:
|
|
2309
|
-
key:
|
|
2304
|
+
function k() {
|
|
2305
|
+
var m, h;
|
|
2306
|
+
const u = ((h = (m = e.builderContextSignal.content) == null ? void 0 : m.data) == null ? void 0 : h.httpRequests) ?? {};
|
|
2307
|
+
Object.entries(u).forEach(([x, p]) => {
|
|
2308
|
+
if (p && (!s[x] || isEditing())) {
|
|
2309
|
+
const E = f(p);
|
|
2310
|
+
S({
|
|
2311
|
+
url: E,
|
|
2312
|
+
key: x
|
|
2310
2313
|
});
|
|
2311
2314
|
}
|
|
2312
2315
|
});
|
|
2313
2316
|
}
|
|
2314
|
-
function
|
|
2317
|
+
function C() {
|
|
2315
2318
|
isEditing() && window.dispatchEvent(
|
|
2316
2319
|
new CustomEvent(
|
|
2317
2320
|
"builder:component:stateChange",
|
|
@@ -2339,25 +2342,25 @@ function EnableEditor(e) {
|
|
|
2339
2342
|
} : {}
|
|
2340
2343
|
}), Object.values(
|
|
2341
2344
|
e.builderContextSignal.componentInfos
|
|
2342
|
-
).forEach((
|
|
2343
|
-
var
|
|
2344
|
-
const h = createRegisterComponentMessage(
|
|
2345
|
-
(
|
|
2345
|
+
).forEach((m) => {
|
|
2346
|
+
var x;
|
|
2347
|
+
const h = createRegisterComponentMessage(m);
|
|
2348
|
+
(x = window.parent) == null || x.postMessage(h, "*");
|
|
2346
2349
|
}), window.addEventListener(
|
|
2347
2350
|
"builder:component:stateChangeListenerActivated",
|
|
2348
|
-
|
|
2351
|
+
C
|
|
2349
2352
|
);
|
|
2350
2353
|
}
|
|
2351
|
-
function
|
|
2352
|
-
const
|
|
2354
|
+
function I(u) {
|
|
2355
|
+
const m = new URL(location.href).searchParams, h = m.get("builder.preview"), x = m.get(
|
|
2353
2356
|
`builder.preview.${h}`
|
|
2354
|
-
), p =
|
|
2355
|
-
h === e.model && p === e.apiKey && (!e.content ||
|
|
2357
|
+
), p = m.get("apiKey") || m.get("builder.space");
|
|
2358
|
+
h === e.model && p === e.apiKey && (!e.content || x === e.content.id) && fetchOneEntry({
|
|
2356
2359
|
model: e.model,
|
|
2357
2360
|
apiKey: e.apiKey,
|
|
2358
2361
|
apiVersion: e.builderContextSignal.apiVersion
|
|
2359
|
-
}).then((
|
|
2360
|
-
|
|
2362
|
+
}).then((E) => {
|
|
2363
|
+
E && o(E);
|
|
2361
2364
|
});
|
|
2362
2365
|
}
|
|
2363
2366
|
return useEffect(() => {
|
|
@@ -2366,8 +2369,8 @@ function EnableEditor(e) {
|
|
|
2366
2369
|
"initeditingbldr",
|
|
2367
2370
|
v
|
|
2368
2371
|
), () => {
|
|
2369
|
-
var
|
|
2370
|
-
return (
|
|
2372
|
+
var m;
|
|
2373
|
+
return (m = t.current) == null ? void 0 : m.removeEventListener(
|
|
2371
2374
|
"initeditingbldr",
|
|
2372
2375
|
v
|
|
2373
2376
|
);
|
|
@@ -2376,25 +2379,25 @@ function EnableEditor(e) {
|
|
|
2376
2379
|
var u;
|
|
2377
2380
|
return (u = t.current) == null || u.addEventListener(
|
|
2378
2381
|
"initpreviewingbldr",
|
|
2379
|
-
|
|
2382
|
+
I
|
|
2380
2383
|
), () => {
|
|
2381
|
-
var
|
|
2382
|
-
return (
|
|
2384
|
+
var m;
|
|
2385
|
+
return (m = t.current) == null ? void 0 : m.removeEventListener(
|
|
2383
2386
|
"initpreviewingbldr",
|
|
2384
|
-
|
|
2387
|
+
I
|
|
2385
2388
|
);
|
|
2386
2389
|
};
|
|
2387
2390
|
}, []), useEffect(() => {
|
|
2388
|
-
var u,
|
|
2391
|
+
var u, m;
|
|
2389
2392
|
if (isBrowser()) {
|
|
2390
2393
|
if (isEditing() && t.current && t.current.dispatchEvent(new CustomEvent("initeditingbldr")), e.builderContextSignal.content && getDefaultCanTrack(e.canTrack)) {
|
|
2391
|
-
const
|
|
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;
|
|
2392
2395
|
_track({
|
|
2393
2396
|
type: "impression",
|
|
2394
2397
|
canTrack: !0,
|
|
2395
2398
|
contentId: p,
|
|
2396
|
-
apiKey:
|
|
2397
|
-
variationId:
|
|
2399
|
+
apiKey: E,
|
|
2400
|
+
variationId: x !== p ? x : void 0
|
|
2398
2401
|
});
|
|
2399
2402
|
}
|
|
2400
2403
|
isPreviewing() && t.current && t.current.dispatchEvent(new CustomEvent("initpreviewingbldr"));
|
|
@@ -2402,7 +2405,7 @@ function EnableEditor(e) {
|
|
|
2402
2405
|
}, []), useEffect(() => {
|
|
2403
2406
|
e.apiKey || logger.error(
|
|
2404
2407
|
"No API key provided to `RenderContent` component. This can cause issues. Please provide an API key using the `apiKey` prop."
|
|
2405
|
-
), c(),
|
|
2408
|
+
), c(), k(), C();
|
|
2406
2409
|
}, []), useEffect(() => {
|
|
2407
2410
|
e.content && o(e.content);
|
|
2408
2411
|
}, [e.content]), useEffect(() => {
|
|
@@ -2412,13 +2415,13 @@ function EnableEditor(e) {
|
|
|
2412
2415
|
(w = (T = e.builderContextSignal.content) == null ? void 0 : T.data) == null ? void 0 : w.jsCode,
|
|
2413
2416
|
e.builderContextSignal.rootState
|
|
2414
2417
|
]), useEffect(() => {
|
|
2415
|
-
|
|
2418
|
+
k();
|
|
2416
2419
|
}, [(j = (R = e.builderContextSignal.content) == null ? void 0 : R.data) == null ? void 0 : j.httpRequests]), useEffect(() => {
|
|
2417
|
-
|
|
2420
|
+
C();
|
|
2418
2421
|
}, [e.builderContextSignal.rootState]), useEffect(() => () => {
|
|
2419
2422
|
isBrowser() && (window.removeEventListener("message", l), window.removeEventListener(
|
|
2420
2423
|
"builder:component:stateChangeListenerActivated",
|
|
2421
|
-
|
|
2424
|
+
C
|
|
2422
2425
|
));
|
|
2423
2426
|
}, []), /* @__PURE__ */ jsx(builderContext.Provider, { value: e.builderContextSignal, children: e.builderContextSignal.content ? /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ createElement(
|
|
2424
2427
|
"div",
|
|
@@ -2528,22 +2531,22 @@ const getContextStateInitialValue = ({
|
|
|
2528
2531
|
meta: e == null ? void 0 : e.meta
|
|
2529
2532
|
} : void 0;
|
|
2530
2533
|
function ContentComponent(e) {
|
|
2531
|
-
var c, s, d, g, b, y,
|
|
2534
|
+
var c, s, d, g, b, y, f;
|
|
2532
2535
|
const [t, n] = useState(
|
|
2533
2536
|
() => {
|
|
2534
|
-
var
|
|
2537
|
+
var S, k;
|
|
2535
2538
|
return getUpdateVariantVisibilityScript({
|
|
2536
2539
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion, @typescript-eslint/no-non-null-asserted-optional-chain
|
|
2537
|
-
variationId: (
|
|
2540
|
+
variationId: (S = e.content) == null ? void 0 : S.testVariationId,
|
|
2538
2541
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion, @typescript-eslint/no-non-null-asserted-optional-chain
|
|
2539
|
-
contentId: (
|
|
2542
|
+
contentId: (k = e.content) == null ? void 0 : k.id
|
|
2540
2543
|
});
|
|
2541
2544
|
}
|
|
2542
2545
|
);
|
|
2543
|
-
function i(
|
|
2544
|
-
l((
|
|
2545
|
-
...
|
|
2546
|
-
rootState:
|
|
2546
|
+
function i(S) {
|
|
2547
|
+
l((k) => ({
|
|
2548
|
+
...k,
|
|
2549
|
+
rootState: S
|
|
2547
2550
|
}));
|
|
2548
2551
|
}
|
|
2549
2552
|
const [o, a] = useState(
|
|
@@ -2557,11 +2560,11 @@ function ContentComponent(e) {
|
|
|
2557
2560
|
...components,
|
|
2558
2561
|
...e.customComponents || []
|
|
2559
2562
|
].reduce(
|
|
2560
|
-
(
|
|
2561
|
-
...
|
|
2562
|
-
[
|
|
2563
|
-
component:
|
|
2564
|
-
...serializeComponentInfo(
|
|
2563
|
+
(S, { component: k, ...C }) => ({
|
|
2564
|
+
...S,
|
|
2565
|
+
[C.name]: {
|
|
2566
|
+
component: k,
|
|
2567
|
+
...serializeComponentInfo(C)
|
|
2565
2568
|
}
|
|
2566
2569
|
}),
|
|
2567
2570
|
{}
|
|
@@ -2591,9 +2594,9 @@ function ContentComponent(e) {
|
|
|
2591
2594
|
...components,
|
|
2592
2595
|
...e.customComponents || []
|
|
2593
2596
|
].reduce(
|
|
2594
|
-
(
|
|
2595
|
-
...
|
|
2596
|
-
[
|
|
2597
|
+
(S, { component: k, ...C }) => ({
|
|
2598
|
+
...S,
|
|
2599
|
+
[C.name]: serializeComponentInfo(C)
|
|
2597
2600
|
}),
|
|
2598
2601
|
{}
|
|
2599
2602
|
),
|
|
@@ -2632,7 +2635,7 @@ function ContentComponent(e) {
|
|
|
2632
2635
|
/* @__PURE__ */ jsx(
|
|
2633
2636
|
Blocks,
|
|
2634
2637
|
{
|
|
2635
|
-
blocks: (
|
|
2638
|
+
blocks: (f = (y = r.content) == null ? void 0 : y.data) == null ? void 0 : f.blocks,
|
|
2636
2639
|
context: r,
|
|
2637
2640
|
registeredComponents: o
|
|
2638
2641
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@builder.io/sdk-react",
|
|
3
3
|
"description": "Builder.io SDK for React",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.8.0",
|
|
5
|
+
"homepage": "https://github.com/BuilderIO/builder/tree/main/packages/sdks/output/react",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/BuilderIO/builder.git",
|
|
9
|
+
"directory": "packages/sdks/output/react"
|
|
10
|
+
},
|
|
5
11
|
"files": [
|
|
6
12
|
"lib",
|
|
7
13
|
"types"
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const SDK_VERSION = "0.
|
|
1
|
+
export declare const SDK_VERSION = "0.8.0";
|