@builder.io/sdk-react 0.12.5 → 0.12.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 +16 -16
- package/lib/browser/index.mjs +195 -181
- package/lib/edge/index.cjs +21 -21
- package/lib/edge/index.mjs +122 -108
- package/lib/node/index.cjs +9 -9
- package/lib/node/index.mjs +144 -130
- package/package.json +1 -1
- package/types/constants/sdk-version.d.ts +1 -1
- package/types/functions/evaluate/browser-runtime/browser.d.ts +5 -1
package/lib/node/index.mjs
CHANGED
|
@@ -92,26 +92,43 @@ const getFunctionArguments = ({
|
|
|
92
92
|
context: n,
|
|
93
93
|
event: i,
|
|
94
94
|
localState: o,
|
|
95
|
-
rootSetState:
|
|
96
|
-
rootState:
|
|
95
|
+
rootSetState: a,
|
|
96
|
+
rootState: r
|
|
97
97
|
}) => {
|
|
98
98
|
const s = getFunctionArguments({
|
|
99
99
|
builder: t,
|
|
100
100
|
context: n,
|
|
101
101
|
event: i,
|
|
102
|
-
state: flattenState(
|
|
102
|
+
state: flattenState({
|
|
103
|
+
rootState: r,
|
|
104
|
+
localState: o,
|
|
105
|
+
rootSetState: a
|
|
106
|
+
})
|
|
103
107
|
});
|
|
104
108
|
return new Function(...s.map(([c]) => c), e)(...s.map(([, c]) => c));
|
|
105
109
|
};
|
|
106
|
-
function flattenState(
|
|
107
|
-
|
|
108
|
-
|
|
110
|
+
function flattenState({
|
|
111
|
+
rootState: e,
|
|
112
|
+
localState: t,
|
|
113
|
+
rootSetState: n
|
|
114
|
+
}) {
|
|
109
115
|
return new Proxy(e, {
|
|
110
|
-
get: (i, o) =>
|
|
111
|
-
|
|
116
|
+
get: (i, o) => {
|
|
117
|
+
if (t && o in t)
|
|
118
|
+
return t[o];
|
|
119
|
+
const a = i[o];
|
|
120
|
+
return typeof a == "object" ? flattenState({
|
|
121
|
+
rootState: a,
|
|
122
|
+
localState: void 0,
|
|
123
|
+
rootSetState: n ? (r) => {
|
|
124
|
+
i[o] = r, n(i);
|
|
125
|
+
} : void 0
|
|
126
|
+
}) : a;
|
|
127
|
+
},
|
|
128
|
+
set: (i, o, a) => {
|
|
112
129
|
if (t && o in t)
|
|
113
130
|
throw new Error("Writing to local state is not allowed as it is read-only.");
|
|
114
|
-
return
|
|
131
|
+
return i[o] = a, n == null || n(i), !0;
|
|
115
132
|
}
|
|
116
133
|
});
|
|
117
134
|
}
|
|
@@ -119,7 +136,7 @@ const set = (e, t, n) => {
|
|
|
119
136
|
if (Object(e) !== e)
|
|
120
137
|
return e;
|
|
121
138
|
const i = Array.isArray(t) ? t : t.toString().match(/[^.[\]]+/g);
|
|
122
|
-
return i.slice(0, -1).reduce((o,
|
|
139
|
+
return i.slice(0, -1).reduce((o, a, r) => Object(o[a]) === o[a] ? o[a] : o[a] = Math.abs(Number(i[r + 1])) >> 0 === +i[r + 1] ? [] : {}, e)[i[i.length - 1]] = n, e;
|
|
123
140
|
}, noop = () => {
|
|
124
141
|
};
|
|
125
142
|
let safeDynamicRequire = noop;
|
|
@@ -185,11 +202,11 @@ output;
|
|
|
185
202
|
context: n,
|
|
186
203
|
event: i,
|
|
187
204
|
localState: o,
|
|
188
|
-
rootSetState:
|
|
189
|
-
rootState:
|
|
205
|
+
rootSetState: a,
|
|
206
|
+
rootState: r
|
|
190
207
|
}) => {
|
|
191
208
|
const s = fastClone({
|
|
192
|
-
...
|
|
209
|
+
...r,
|
|
193
210
|
...o
|
|
194
211
|
}), c = getFunctionArguments({
|
|
195
212
|
builder: t,
|
|
@@ -200,7 +217,7 @@ output;
|
|
|
200
217
|
d.setSync("global", d.derefInto()), d.setSync("log", function(...f) {
|
|
201
218
|
console.log(...f);
|
|
202
219
|
}), d.setSync(BUILDER_SET_STATE_NAME, function(f, h) {
|
|
203
|
-
set(
|
|
220
|
+
set(r, f, h), a == null || a(r);
|
|
204
221
|
}), c.forEach(([f, h]) => {
|
|
205
222
|
const y = typeof h == "object" ? new ivm.Reference(
|
|
206
223
|
// workaround: methods with default values for arguments is not being cloned over
|
|
@@ -238,8 +255,8 @@ function evaluate({
|
|
|
238
255
|
localState: n,
|
|
239
256
|
rootState: i,
|
|
240
257
|
rootSetState: o,
|
|
241
|
-
event:
|
|
242
|
-
isExpression:
|
|
258
|
+
event: a,
|
|
259
|
+
isExpression: r = !0
|
|
243
260
|
}) {
|
|
244
261
|
if (e === "") {
|
|
245
262
|
logger.warn("Skipping evaluation of empty code block.");
|
|
@@ -247,11 +264,11 @@ function evaluate({
|
|
|
247
264
|
}
|
|
248
265
|
const s = {
|
|
249
266
|
code: parseCode(e, {
|
|
250
|
-
isExpression:
|
|
267
|
+
isExpression: r
|
|
251
268
|
}),
|
|
252
269
|
builder: getBuilderGlobals(),
|
|
253
270
|
context: t,
|
|
254
|
-
event:
|
|
271
|
+
event: a,
|
|
255
272
|
rootSetState: o,
|
|
256
273
|
rootState: i,
|
|
257
274
|
localState: n
|
|
@@ -277,13 +294,13 @@ const evaluateBindings = ({
|
|
|
277
294
|
}) => {
|
|
278
295
|
if (!e.bindings)
|
|
279
296
|
return e;
|
|
280
|
-
const
|
|
281
|
-
...
|
|
297
|
+
const a = fastClone(e), r = {
|
|
298
|
+
...a,
|
|
282
299
|
properties: {
|
|
283
|
-
...
|
|
300
|
+
...a.properties
|
|
284
301
|
},
|
|
285
302
|
actions: {
|
|
286
|
-
...
|
|
303
|
+
...a.actions
|
|
287
304
|
}
|
|
288
305
|
};
|
|
289
306
|
for (const s in e.bindings) {
|
|
@@ -294,9 +311,9 @@ const evaluateBindings = ({
|
|
|
294
311
|
rootSetState: o,
|
|
295
312
|
context: t
|
|
296
313
|
});
|
|
297
|
-
set(
|
|
314
|
+
set(r, s, l);
|
|
298
315
|
}
|
|
299
|
-
return
|
|
316
|
+
return r;
|
|
300
317
|
};
|
|
301
318
|
function getProcessedBlock({
|
|
302
319
|
block: e,
|
|
@@ -304,31 +321,31 @@ function getProcessedBlock({
|
|
|
304
321
|
shouldEvaluateBindings: n,
|
|
305
322
|
localState: i,
|
|
306
323
|
rootState: o,
|
|
307
|
-
rootSetState:
|
|
324
|
+
rootSetState: a
|
|
308
325
|
}) {
|
|
309
|
-
const
|
|
326
|
+
const r = e;
|
|
310
327
|
return n ? evaluateBindings({
|
|
311
|
-
block:
|
|
328
|
+
block: r,
|
|
312
329
|
localState: i,
|
|
313
330
|
rootState: o,
|
|
314
|
-
rootSetState:
|
|
331
|
+
rootSetState: a,
|
|
315
332
|
context: t
|
|
316
|
-
}) :
|
|
333
|
+
}) : r;
|
|
317
334
|
}
|
|
318
335
|
const getComponent = ({
|
|
319
336
|
block: e,
|
|
320
337
|
context: t,
|
|
321
338
|
registeredComponents: n
|
|
322
339
|
}) => {
|
|
323
|
-
var
|
|
324
|
-
const i = (
|
|
340
|
+
var a;
|
|
341
|
+
const i = (a = getProcessedBlock({
|
|
325
342
|
block: e,
|
|
326
343
|
localState: t.localState,
|
|
327
344
|
rootState: t.rootState,
|
|
328
345
|
rootSetState: t.rootSetState,
|
|
329
346
|
context: t.context,
|
|
330
347
|
shouldEvaluateBindings: !1
|
|
331
|
-
}).component) == null ? void 0 :
|
|
348
|
+
}).component) == null ? void 0 : a.name;
|
|
332
349
|
if (!i)
|
|
333
350
|
return null;
|
|
334
351
|
const o = n[i];
|
|
@@ -356,7 +373,7 @@ const getComponent = ({
|
|
|
356
373
|
});
|
|
357
374
|
if (!Array.isArray(o))
|
|
358
375
|
return;
|
|
359
|
-
const
|
|
376
|
+
const a = n.collection.split(".").pop(), r = n.itemName || (a ? a + "Item" : "item");
|
|
360
377
|
return o.map((c, l) => ({
|
|
361
378
|
context: {
|
|
362
379
|
...t,
|
|
@@ -364,8 +381,8 @@ const getComponent = ({
|
|
|
364
381
|
...t.localState,
|
|
365
382
|
$index: l,
|
|
366
383
|
$item: c,
|
|
367
|
-
[
|
|
368
|
-
[`$${
|
|
384
|
+
[r]: c,
|
|
385
|
+
[`$${r}Index`]: l
|
|
369
386
|
}
|
|
370
387
|
},
|
|
371
388
|
block: i
|
|
@@ -405,12 +422,12 @@ const getComponent = ({
|
|
|
405
422
|
min: o,
|
|
406
423
|
default: o + 1
|
|
407
424
|
};
|
|
408
|
-
const
|
|
425
|
+
const a = n.medium.max + 1;
|
|
409
426
|
return n.large = {
|
|
410
427
|
max: 2e3,
|
|
411
428
|
// TODO: decide upper limit
|
|
412
|
-
min:
|
|
413
|
-
default:
|
|
429
|
+
min: a,
|
|
430
|
+
default: a + 1
|
|
414
431
|
}, n;
|
|
415
432
|
}, camelToKebabCase = (e) => e.replace(/([a-z0-9]|(?=[A-Z]))([A-Z])/g, "$1-$2").toLowerCase(), convertStyleMapToCSSArray = (e) => Object.entries(e).map(([n, i]) => {
|
|
416
433
|
if (typeof i == "string")
|
|
@@ -452,8 +469,8 @@ function BlockStyles(e) {
|
|
|
452
469
|
rootSetState: e.context.rootSetState,
|
|
453
470
|
context: e.context.context,
|
|
454
471
|
shouldEvaluateBindings: !0
|
|
455
|
-
}), o = i.responsiveStyles,
|
|
456
|
-
((h =
|
|
472
|
+
}), o = i.responsiveStyles, a = e.context.content, r = getSizesForBreakpoints(
|
|
473
|
+
((h = a == null ? void 0 : a.meta) == null ? void 0 : h.breakpoints) || {}
|
|
457
474
|
), s = o == null ? void 0 : o.large, c = o == null ? void 0 : o.medium, l = o == null ? void 0 : o.small, d = i.id;
|
|
458
475
|
if (!d)
|
|
459
476
|
return "";
|
|
@@ -465,14 +482,14 @@ function BlockStyles(e) {
|
|
|
465
482
|
styles: c,
|
|
466
483
|
mediaQuery: getMaxWidthQueryForSize(
|
|
467
484
|
"medium",
|
|
468
|
-
|
|
485
|
+
r
|
|
469
486
|
)
|
|
470
487
|
}) : "", f = l ? createCssClass({
|
|
471
488
|
className: d,
|
|
472
489
|
styles: l,
|
|
473
490
|
mediaQuery: getMaxWidthQueryForSize(
|
|
474
491
|
"small",
|
|
475
|
-
|
|
492
|
+
r
|
|
476
493
|
)
|
|
477
494
|
}) : "";
|
|
478
495
|
return [g, x, f].join(" ");
|
|
@@ -497,18 +514,18 @@ function getBlockActions(e) {
|
|
|
497
514
|
for (const o in n) {
|
|
498
515
|
if (!n.hasOwnProperty(o))
|
|
499
516
|
continue;
|
|
500
|
-
const
|
|
501
|
-
let
|
|
517
|
+
const a = n[o];
|
|
518
|
+
let r = getEventHandlerName(o);
|
|
502
519
|
if (e.stripPrefix)
|
|
503
520
|
switch (TARGET) {
|
|
504
521
|
case "vue":
|
|
505
|
-
|
|
522
|
+
r = r.replace("v-on:", "");
|
|
506
523
|
break;
|
|
507
524
|
case "svelte":
|
|
508
|
-
|
|
525
|
+
r = r.replace("on:", "");
|
|
509
526
|
break;
|
|
510
527
|
}
|
|
511
|
-
t[
|
|
528
|
+
t[r] = createEventHandler(a, e);
|
|
512
529
|
}
|
|
513
530
|
return t;
|
|
514
531
|
}
|
|
@@ -616,8 +633,8 @@ const getWrapperProps = ({
|
|
|
616
633
|
context: n,
|
|
617
634
|
componentRef: i,
|
|
618
635
|
includeBlockProps: o,
|
|
619
|
-
isInteractive:
|
|
620
|
-
contextValue:
|
|
636
|
+
isInteractive: a,
|
|
637
|
+
contextValue: r
|
|
621
638
|
}) => {
|
|
622
639
|
const s = {
|
|
623
640
|
...e,
|
|
@@ -628,11 +645,11 @@ const getWrapperProps = ({
|
|
|
628
645
|
...o ? {
|
|
629
646
|
attributes: getBlockProperties({
|
|
630
647
|
block: t,
|
|
631
|
-
context:
|
|
648
|
+
context: r
|
|
632
649
|
})
|
|
633
650
|
} : {}
|
|
634
651
|
};
|
|
635
|
-
return
|
|
652
|
+
return a ? {
|
|
636
653
|
Wrapper: i,
|
|
637
654
|
block: t,
|
|
638
655
|
context: n,
|
|
@@ -713,14 +730,14 @@ function Block(e) {
|
|
|
713
730
|
var h;
|
|
714
731
|
return e.block.tagName === "a" || ((h = i().properties) == null ? void 0 : h.href) || i().href ? e.linkComponent || "a" : e.block.tagName || "div";
|
|
715
732
|
}
|
|
716
|
-
function
|
|
733
|
+
function a() {
|
|
717
734
|
var y, I;
|
|
718
735
|
if ((y = e.block.repeat) != null && y.collection)
|
|
719
736
|
return !!((I = n == null ? void 0 : n()) != null && I.length);
|
|
720
737
|
const f = "hide" in i() ? i().hide : !1;
|
|
721
738
|
return ("show" in i() ? i().show : !0) && !f;
|
|
722
739
|
}
|
|
723
|
-
function
|
|
740
|
+
function r() {
|
|
724
741
|
var h, y;
|
|
725
742
|
return !((h = t == null ? void 0 : t()) != null && h.component) && !n() ? (y = i().children) != null ? y : [] : [];
|
|
726
743
|
}
|
|
@@ -748,7 +765,7 @@ function Block(e) {
|
|
|
748
765
|
};
|
|
749
766
|
}
|
|
750
767
|
const [c, l] = useState(() => e.context);
|
|
751
|
-
return /* @__PURE__ */ jsx(Fragment, { children:
|
|
768
|
+
return /* @__PURE__ */ jsx(Fragment, { children: a() ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
752
769
|
/* @__PURE__ */ jsx(BlockStyles, { block: e.block, context: e.context }),
|
|
753
770
|
(d = t == null ? void 0 : t()) != null && d.noWrap ? /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(
|
|
754
771
|
ComponentRef,
|
|
@@ -794,7 +811,7 @@ function Block(e) {
|
|
|
794
811
|
isInteractive: s().isInteractive
|
|
795
812
|
}
|
|
796
813
|
),
|
|
797
|
-
(g =
|
|
814
|
+
(g = r()) == null ? void 0 : g.map((f) => /* @__PURE__ */ jsx(
|
|
798
815
|
Block,
|
|
799
816
|
{
|
|
800
817
|
block: f,
|
|
@@ -815,8 +832,8 @@ function BlocksWrapper(e) {
|
|
|
815
832
|
return "builder-blocks" + ((o = e.blocks) != null && o.length ? "" : " no-blocks");
|
|
816
833
|
}
|
|
817
834
|
function n() {
|
|
818
|
-
var o,
|
|
819
|
-
isEditing() && !((o = e.blocks) != null && o.length) && ((
|
|
835
|
+
var o, a;
|
|
836
|
+
isEditing() && !((o = e.blocks) != null && o.length) && ((a = window.parent) == null || a.postMessage(
|
|
820
837
|
{
|
|
821
838
|
type: "builder.clickEmptyBlocks",
|
|
822
839
|
data: {
|
|
@@ -828,8 +845,8 @@ function BlocksWrapper(e) {
|
|
|
828
845
|
));
|
|
829
846
|
}
|
|
830
847
|
function i() {
|
|
831
|
-
var o,
|
|
832
|
-
isEditing() && !((o = e.blocks) != null && o.length) && ((
|
|
848
|
+
var o, a;
|
|
849
|
+
isEditing() && !((o = e.blocks) != null && o.length) && ((a = window.parent) == null || a.postMessage(
|
|
833
850
|
{
|
|
834
851
|
type: "builder.hoverEmptyBlocks",
|
|
835
852
|
data: {
|
|
@@ -863,7 +880,7 @@ function BlocksWrapper(e) {
|
|
|
863
880
|
] });
|
|
864
881
|
}
|
|
865
882
|
function Blocks(e) {
|
|
866
|
-
var i, o,
|
|
883
|
+
var i, o, a;
|
|
867
884
|
const t = useContext(builderContext), n = useContext(ComponentsContext);
|
|
868
885
|
return /* @__PURE__ */ jsx(
|
|
869
886
|
BlocksWrapper,
|
|
@@ -874,15 +891,15 @@ function Blocks(e) {
|
|
|
874
891
|
styleProp: e.styleProp,
|
|
875
892
|
BlocksWrapper: (i = e.context) == null ? void 0 : i.BlocksWrapper,
|
|
876
893
|
BlocksWrapperProps: (o = e.context) == null ? void 0 : o.BlocksWrapperProps,
|
|
877
|
-
children: e.blocks ? /* @__PURE__ */ jsx(Fragment, { children: (
|
|
894
|
+
children: e.blocks ? /* @__PURE__ */ jsx(Fragment, { children: (a = e.blocks) == null ? void 0 : a.map((r) => /* @__PURE__ */ jsx(
|
|
878
895
|
Block,
|
|
879
896
|
{
|
|
880
|
-
block:
|
|
897
|
+
block: r,
|
|
881
898
|
linkComponent: e.linkComponent,
|
|
882
899
|
context: e.context || t,
|
|
883
900
|
registeredComponents: e.registeredComponents || n.registeredComponents
|
|
884
901
|
},
|
|
885
|
-
|
|
902
|
+
r.id
|
|
886
903
|
)) }) : null
|
|
887
904
|
}
|
|
888
905
|
);
|
|
@@ -891,7 +908,7 @@ function Columns(e) {
|
|
|
891
908
|
var E;
|
|
892
909
|
const [t, n] = useState(
|
|
893
910
|
() => typeof e.space == "number" ? e.space || 0 : 20
|
|
894
|
-
), [i, o] = useState(() => e.columns || []), [
|
|
911
|
+
), [i, o] = useState(() => e.columns || []), [a, r] = useState(
|
|
895
912
|
() => e.stackColumnsAt || "tablet"
|
|
896
913
|
);
|
|
897
914
|
function s(v) {
|
|
@@ -906,13 +923,13 @@ function Columns(e) {
|
|
|
906
923
|
stackedStyle: v,
|
|
907
924
|
desktopStyle: C
|
|
908
925
|
}) {
|
|
909
|
-
return
|
|
926
|
+
return a === "tablet" ? v : C;
|
|
910
927
|
}
|
|
911
928
|
function d({
|
|
912
929
|
stackedStyle: v,
|
|
913
930
|
desktopStyle: C
|
|
914
931
|
}) {
|
|
915
|
-
return
|
|
932
|
+
return a === "never" ? C : v;
|
|
916
933
|
}
|
|
917
934
|
const [g, x] = useState(
|
|
918
935
|
() => e.stackColumnsAt === "never" ? "row" : e.reverseColumnsWhenStacked ? "column-reverse" : "column"
|
|
@@ -1050,8 +1067,8 @@ function getShopifyImageUrl(e, t) {
|
|
|
1050
1067
|
return removeProtocol(e);
|
|
1051
1068
|
const n = e.match(/(_\d+x(\d+)?)?(\.(jpg|jpeg|gif|png|bmp|bitmap|tiff|tif)(\?v=\d+)?)/i);
|
|
1052
1069
|
if (n) {
|
|
1053
|
-
const i = e.split(n[0]), o = n[3],
|
|
1054
|
-
return removeProtocol(`${i[0]}_${
|
|
1070
|
+
const i = e.split(n[0]), o = n[3], a = t.match("x") ? t : `${t}x`;
|
|
1071
|
+
return removeProtocol(`${i[0]}_${a}${o}`);
|
|
1055
1072
|
}
|
|
1056
1073
|
return null;
|
|
1057
1074
|
}
|
|
@@ -1067,7 +1084,7 @@ function getSrcSet(e) {
|
|
|
1067
1084
|
return e.match(/cdn\.shopify\.com/) ? t.map((n) => [getShopifyImageUrl(e, `${n}x${n}`), n]).filter(([n]) => !!n).map(([n, i]) => `${n} ${i}w`).concat([e]).join(", ") : e;
|
|
1068
1085
|
}
|
|
1069
1086
|
function Image(e) {
|
|
1070
|
-
var o,
|
|
1087
|
+
var o, a, r, s;
|
|
1071
1088
|
function t() {
|
|
1072
1089
|
var d;
|
|
1073
1090
|
const l = e.image || e.src;
|
|
@@ -1118,7 +1135,7 @@ function Image(e) {
|
|
|
1118
1135
|
}
|
|
1119
1136
|
)
|
|
1120
1137
|
] }),
|
|
1121
|
-
e.aspectRatio && !((
|
|
1138
|
+
e.aspectRatio && !((a = (o = e.builderBlock) == null ? void 0 : o.children) != null && a.length && e.fitContent) ? /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(
|
|
1122
1139
|
"div",
|
|
1123
1140
|
{
|
|
1124
1141
|
className: "builder-image-sizer div-40c70c9b",
|
|
@@ -1127,7 +1144,7 @@ function Image(e) {
|
|
|
1127
1144
|
}
|
|
1128
1145
|
}
|
|
1129
1146
|
) }) : null,
|
|
1130
|
-
(s = (
|
|
1147
|
+
(s = (r = e.builderBlock) == null ? void 0 : r.children) != null && s.length && e.fitContent ? /* @__PURE__ */ jsx(Fragment, { children: e.children }) : null,
|
|
1131
1148
|
!e.fitContent && e.children ? /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx("div", { className: "div-40c70c9b-2", children: e.children }) }) : null
|
|
1132
1149
|
] }),
|
|
1133
1150
|
/* @__PURE__ */ jsx("style", { children: `.img-40c70c9b {
|
|
@@ -1382,7 +1399,7 @@ const componentInfo$b = {
|
|
|
1382
1399
|
});
|
|
1383
1400
|
}
|
|
1384
1401
|
const n = e.get("columns");
|
|
1385
|
-
Array.isArray(n) && n.find((o) => o.get("width")) && (n.find((
|
|
1402
|
+
Array.isArray(n) && n.find((o) => o.get("width")) && (n.find((a) => !a.get("width")) || n.reduce((s, c) => s + c.get("width"), 0) !== 100) && t();
|
|
1386
1403
|
}
|
|
1387
1404
|
}, {
|
|
1388
1405
|
name: "space",
|
|
@@ -1428,14 +1445,14 @@ const componentInfo$b = {
|
|
|
1428
1445
|
}]
|
|
1429
1446
|
};
|
|
1430
1447
|
function CustomCode(e) {
|
|
1431
|
-
const t = useRef(null), [n, i] = useState(() => []), [o,
|
|
1448
|
+
const t = useRef(null), [n, i] = useState(() => []), [o, a] = useState(() => []);
|
|
1432
1449
|
return useEffect(() => {
|
|
1433
1450
|
var s;
|
|
1434
1451
|
if (!((s = t.current) != null && s.getElementsByTagName) || typeof window == "undefined")
|
|
1435
1452
|
return;
|
|
1436
|
-
const
|
|
1437
|
-
for (let c = 0; c <
|
|
1438
|
-
const l =
|
|
1453
|
+
const r = t.current.getElementsByTagName("script");
|
|
1454
|
+
for (let c = 0; c < r.length; c++) {
|
|
1455
|
+
const l = r[c];
|
|
1439
1456
|
if (l.src) {
|
|
1440
1457
|
if (n.includes(l.src))
|
|
1441
1458
|
continue;
|
|
@@ -1492,7 +1509,7 @@ const componentInfo$8 = {
|
|
|
1492
1509
|
}]
|
|
1493
1510
|
}, SCRIPT_MIME_TYPES = ["text/javascript", "application/javascript", "application/ecmascript"], isJsScript = (e) => SCRIPT_MIME_TYPES.includes(e.type);
|
|
1494
1511
|
function Embed(e) {
|
|
1495
|
-
const t = useRef(null), [n, i] = useState(() => []), [o,
|
|
1512
|
+
const t = useRef(null), [n, i] = useState(() => []), [o, a] = useState(() => []), [r, s] = useState(() => !1);
|
|
1496
1513
|
function c() {
|
|
1497
1514
|
if (!t.current || !t.current.getElementsByTagName)
|
|
1498
1515
|
return;
|
|
@@ -1512,8 +1529,8 @@ function Embed(e) {
|
|
|
1512
1529
|
}
|
|
1513
1530
|
}
|
|
1514
1531
|
return useEffect(() => {
|
|
1515
|
-
t.current && !
|
|
1516
|
-
}, [t.current,
|
|
1532
|
+
t.current && !r && (s(!0), c());
|
|
1533
|
+
}, [t.current, r]), /* @__PURE__ */ jsx(
|
|
1517
1534
|
"div",
|
|
1518
1535
|
{
|
|
1519
1536
|
className: "builder-embed",
|
|
@@ -1548,7 +1565,7 @@ const componentInfo$7 = {
|
|
|
1548
1565
|
defaultValue: "https://cdn.builder.io/api/v1/image/assets%2FYJIGb4i01jvw0SRdL5Bt%2F72c80f114dc149019051b6852a9e3b7a",
|
|
1549
1566
|
onChange: (e) => {
|
|
1550
1567
|
e.delete("srcset"), e.delete("noWebp");
|
|
1551
|
-
function n(
|
|
1568
|
+
function n(r, s = 6e4) {
|
|
1552
1569
|
return new Promise((c, l) => {
|
|
1553
1570
|
const d = document.createElement("img");
|
|
1554
1571
|
let g = !1;
|
|
@@ -1556,21 +1573,21 @@ const componentInfo$7 = {
|
|
|
1556
1573
|
g = !0, c(d);
|
|
1557
1574
|
}, d.addEventListener("error", (x) => {
|
|
1558
1575
|
console.warn("Image load failed", x.error), l(x.error);
|
|
1559
|
-
}), d.src =
|
|
1576
|
+
}), d.src = r, setTimeout(() => {
|
|
1560
1577
|
g || l(new Error("Image load timed out"));
|
|
1561
1578
|
}, s);
|
|
1562
1579
|
});
|
|
1563
1580
|
}
|
|
1564
|
-
function i(
|
|
1565
|
-
return Math.round(
|
|
1581
|
+
function i(r) {
|
|
1582
|
+
return Math.round(r * 1e3) / 1e3;
|
|
1566
1583
|
}
|
|
1567
|
-
const o = e.get("image"),
|
|
1568
|
-
if (fetch(o).then((
|
|
1569
|
-
|
|
1570
|
-
}), o && (!
|
|
1571
|
-
return n(o).then((
|
|
1584
|
+
const o = e.get("image"), a = e.get("aspectRatio");
|
|
1585
|
+
if (fetch(o).then((r) => r.blob()).then((r) => {
|
|
1586
|
+
r.type.includes("svg") && e.set("noWebp", !0);
|
|
1587
|
+
}), o && (!a || a === 0.7041))
|
|
1588
|
+
return n(o).then((r) => {
|
|
1572
1589
|
const s = e.get("aspectRatio");
|
|
1573
|
-
e.get("image") === o && (!s || s === 0.7041) &&
|
|
1590
|
+
e.get("image") === o && (!s || s === 0.7041) && r.width && r.height && (e.set("aspectRatio", i(r.height / r.width)), e.set("height", r.height), e.set("width", r.width));
|
|
1574
1591
|
});
|
|
1575
1592
|
}
|
|
1576
1593
|
}, {
|
|
@@ -1882,7 +1899,7 @@ const componentInfo = {
|
|
|
1882
1899
|
}]
|
|
1883
1900
|
};
|
|
1884
1901
|
function Video(e) {
|
|
1885
|
-
var i, o,
|
|
1902
|
+
var i, o, a, r, s, c, l;
|
|
1886
1903
|
function t() {
|
|
1887
1904
|
return {
|
|
1888
1905
|
...e.autoPlay === !0 ? {
|
|
@@ -1939,7 +1956,7 @@ function Video(e) {
|
|
|
1939
1956
|
children: e.lazyLoad ? null : /* @__PURE__ */ jsx("source", { type: "video/mp4", src: e.video })
|
|
1940
1957
|
}
|
|
1941
1958
|
),
|
|
1942
|
-
e.aspectRatio && !(e.fitContent && ((
|
|
1959
|
+
e.aspectRatio && !(e.fitContent && ((a = (o = e.builderBlock) == null ? void 0 : o.children) != null && a.length)) ? /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(
|
|
1943
1960
|
"div",
|
|
1944
1961
|
{
|
|
1945
1962
|
style: {
|
|
@@ -1950,7 +1967,7 @@ function Video(e) {
|
|
|
1950
1967
|
}
|
|
1951
1968
|
}
|
|
1952
1969
|
) }) : null,
|
|
1953
|
-
(s = (
|
|
1970
|
+
(s = (r = e.builderBlock) == null ? void 0 : r.children) != null && s.length && e.fitContent ? /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(
|
|
1954
1971
|
"div",
|
|
1955
1972
|
{
|
|
1956
1973
|
style: {
|
|
@@ -2162,10 +2179,10 @@ const findParentElement = (e, t, n = !0) => {
|
|
|
2162
2179
|
event: e,
|
|
2163
2180
|
target: t
|
|
2164
2181
|
}) => {
|
|
2165
|
-
const n = t.getBoundingClientRect(), i = e.clientX - n.left, o = e.clientY - n.top,
|
|
2182
|
+
const n = t.getBoundingClientRect(), i = e.clientX - n.left, o = e.clientY - n.top, a = round(i / n.width), r = round(o / n.height);
|
|
2166
2183
|
return {
|
|
2167
|
-
x:
|
|
2168
|
-
y:
|
|
2184
|
+
x: a,
|
|
2185
|
+
y: r
|
|
2169
2186
|
};
|
|
2170
2187
|
}, getInteractionPropertiesForEvent = (e) => {
|
|
2171
2188
|
const t = e.target, n = t && findBuilderParent(t), i = (n == null ? void 0 : n.getAttribute("builder-id")) || (n == null ? void 0 : n.id);
|
|
@@ -2183,7 +2200,7 @@ const findParentElement = (e, t, n = !0) => {
|
|
|
2183
2200
|
builderElementIndex: n && i ? [].slice.call(document.getElementsByClassName(i)).indexOf(n) : void 0
|
|
2184
2201
|
}
|
|
2185
2202
|
};
|
|
2186
|
-
}, SDK_VERSION = "0.12.
|
|
2203
|
+
}, SDK_VERSION = "0.12.6", registerInsertMenu = () => {
|
|
2187
2204
|
register("insertMenu", {
|
|
2188
2205
|
name: "_default",
|
|
2189
2206
|
default: !0,
|
|
@@ -2226,7 +2243,7 @@ const setupBrowserForEditing = (e = {}) => {
|
|
|
2226
2243
|
options: e
|
|
2227
2244
|
}
|
|
2228
2245
|
}, "*"), window.addEventListener("message", (i) => {
|
|
2229
|
-
var
|
|
2246
|
+
var a, r;
|
|
2230
2247
|
if (!isFromTrustedHost(e.trustedHosts, i))
|
|
2231
2248
|
return;
|
|
2232
2249
|
const {
|
|
@@ -2242,7 +2259,7 @@ const setupBrowserForEditing = (e = {}) => {
|
|
|
2242
2259
|
} catch (f) {
|
|
2243
2260
|
x = f;
|
|
2244
2261
|
}
|
|
2245
|
-
x ? (
|
|
2262
|
+
x ? (a = window.parent) == null || a.postMessage({
|
|
2246
2263
|
type: "builder.evaluateError",
|
|
2247
2264
|
data: {
|
|
2248
2265
|
id: l,
|
|
@@ -2257,7 +2274,7 @@ const setupBrowserForEditing = (e = {}) => {
|
|
|
2257
2274
|
result: f
|
|
2258
2275
|
}
|
|
2259
2276
|
}, "*");
|
|
2260
|
-
}).catch(console.error) : (
|
|
2277
|
+
}).catch(console.error) : (r = window.parent) == null || r.postMessage({
|
|
2261
2278
|
type: "builder.evaluateResult",
|
|
2262
2279
|
data: {
|
|
2263
2280
|
result: g,
|
|
@@ -2284,7 +2301,7 @@ function EnableEditor(e) {
|
|
|
2284
2301
|
rootState: m
|
|
2285
2302
|
}));
|
|
2286
2303
|
}
|
|
2287
|
-
function
|
|
2304
|
+
function a(u) {
|
|
2288
2305
|
var b, S, p, k, B;
|
|
2289
2306
|
const m = {
|
|
2290
2307
|
...e.builderContextSignal.content,
|
|
@@ -2305,7 +2322,7 @@ function EnableEditor(e) {
|
|
|
2305
2322
|
}));
|
|
2306
2323
|
}
|
|
2307
2324
|
useState(() => 0);
|
|
2308
|
-
const [
|
|
2325
|
+
const [r, s] = useState(
|
|
2309
2326
|
() => !1
|
|
2310
2327
|
), [c, l] = useState(
|
|
2311
2328
|
() => e.contentWrapper || "div"
|
|
@@ -2321,7 +2338,7 @@ function EnableEditor(e) {
|
|
|
2321
2338
|
const S = m.data, { breakpoints: p, contentId: k } = S;
|
|
2322
2339
|
if (!k || k !== ((b = e.builderContextSignal.content) == null ? void 0 : b.id))
|
|
2323
2340
|
return;
|
|
2324
|
-
p &&
|
|
2341
|
+
p && a({
|
|
2325
2342
|
meta: {
|
|
2326
2343
|
breakpoints: p
|
|
2327
2344
|
}
|
|
@@ -2330,7 +2347,7 @@ function EnableEditor(e) {
|
|
|
2330
2347
|
}
|
|
2331
2348
|
case "builder.contentUpdate": {
|
|
2332
2349
|
const S = m.data, p = S.key || S.alias || S.entry || S.modelName, k = S.data;
|
|
2333
|
-
p === e.model && (
|
|
2350
|
+
p === e.model && (a(k), i(n + 1));
|
|
2334
2351
|
break;
|
|
2335
2352
|
}
|
|
2336
2353
|
}
|
|
@@ -2449,7 +2466,7 @@ function EnableEditor(e) {
|
|
|
2449
2466
|
apiKey: e.apiKey,
|
|
2450
2467
|
apiVersion: e.builderContextSignal.apiVersion
|
|
2451
2468
|
}).then((k) => {
|
|
2452
|
-
k &&
|
|
2469
|
+
k && a(k);
|
|
2453
2470
|
});
|
|
2454
2471
|
}
|
|
2455
2472
|
return useEffect(() => {
|
|
@@ -2496,14 +2513,11 @@ function EnableEditor(e) {
|
|
|
2496
2513
|
"No API key provided to `RenderContent` component. This can cause issues. Please provide an API key using the `apiKey` prop."
|
|
2497
2514
|
), g(), C(), T();
|
|
2498
2515
|
}, []), useEffect(() => {
|
|
2499
|
-
e.content &&
|
|
2516
|
+
e.content && a(e.content);
|
|
2500
2517
|
}, [e.content]), useEffect(() => {
|
|
2501
|
-
}, [
|
|
2518
|
+
}, [r]), useEffect(() => {
|
|
2502
2519
|
g();
|
|
2503
|
-
}, [
|
|
2504
|
-
(P = (j = e.builderContextSignal.content) == null ? void 0 : j.data) == null ? void 0 : P.jsCode,
|
|
2505
|
-
e.builderContextSignal.rootState
|
|
2506
|
-
]), useEffect(() => {
|
|
2520
|
+
}, [(P = (j = e.builderContextSignal.content) == null ? void 0 : j.data) == null ? void 0 : P.jsCode]), useEffect(() => {
|
|
2507
2521
|
C();
|
|
2508
2522
|
}, [(F = (A = e.builderContextSignal.content) == null ? void 0 : A.data) == null ? void 0 : F.httpRequests]), useEffect(() => {
|
|
2509
2523
|
T();
|
|
@@ -2537,8 +2551,8 @@ function EnableEditor(e) {
|
|
|
2537
2551
|
) }) : null });
|
|
2538
2552
|
}
|
|
2539
2553
|
const getCssFromFont = (e) => {
|
|
2540
|
-
var
|
|
2541
|
-
const t = e.family + (e.kind && !e.kind.includes("#") ? ", " + e.kind : ""), n = t.split(",")[0], i = (
|
|
2554
|
+
var a, r;
|
|
2555
|
+
const t = e.family + (e.kind && !e.kind.includes("#") ? ", " + e.kind : ""), n = t.split(",")[0], i = (r = e.fileUrl) != null ? r : (a = e == null ? void 0 : e.files) == null ? void 0 : a.regular;
|
|
2542
2556
|
let o = "";
|
|
2543
2557
|
if (i && t && n && (o += `
|
|
2544
2558
|
@font-face {
|
|
@@ -2607,9 +2621,9 @@ const getRootStateInitialValue = ({
|
|
|
2607
2621
|
data: t,
|
|
2608
2622
|
locale: n
|
|
2609
2623
|
}) => {
|
|
2610
|
-
var
|
|
2611
|
-
const i = {}, o = ((
|
|
2612
|
-
return (s = (
|
|
2624
|
+
var a, r, s;
|
|
2625
|
+
const i = {}, o = ((a = e == null ? void 0 : e.data) == null ? void 0 : a.state) || {};
|
|
2626
|
+
return (s = (r = e == null ? void 0 : e.data) == null ? void 0 : r.inputs) == null || s.forEach((c) => {
|
|
2613
2627
|
c.name && c.defaultValue !== void 0 && (i[c.name] = c.defaultValue);
|
|
2614
2628
|
}), {
|
|
2615
2629
|
...i,
|
|
@@ -2649,7 +2663,7 @@ function ContentComponent(e) {
|
|
|
2649
2663
|
rootState: y
|
|
2650
2664
|
}));
|
|
2651
2665
|
}
|
|
2652
|
-
const [o,
|
|
2666
|
+
const [o, a] = useState(
|
|
2653
2667
|
() => [
|
|
2654
2668
|
...getDefaultRegisteredComponents(),
|
|
2655
2669
|
// While this `components` object is deprecated, we must maintain support for it.
|
|
@@ -2669,7 +2683,7 @@ function ContentComponent(e) {
|
|
|
2669
2683
|
}),
|
|
2670
2684
|
{}
|
|
2671
2685
|
)
|
|
2672
|
-
), [
|
|
2686
|
+
), [r, s] = useState(() => ({
|
|
2673
2687
|
content: getContentInitialValue({
|
|
2674
2688
|
content: e.content,
|
|
2675
2689
|
data: e.data
|
|
@@ -2723,7 +2737,7 @@ function ContentComponent(e) {
|
|
|
2723
2737
|
includeRefs: e.includeRefs,
|
|
2724
2738
|
enrich: e.enrich,
|
|
2725
2739
|
showContent: e.showContent,
|
|
2726
|
-
builderContextSignal:
|
|
2740
|
+
builderContextSignal: r,
|
|
2727
2741
|
contentWrapper: e.contentWrapper,
|
|
2728
2742
|
contentWrapperProps: e.contentWrapperProps,
|
|
2729
2743
|
linkComponent: e.linkComponent,
|
|
@@ -2734,16 +2748,16 @@ function ContentComponent(e) {
|
|
|
2734
2748
|
/* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(
|
|
2735
2749
|
ContentStyles,
|
|
2736
2750
|
{
|
|
2737
|
-
contentId: (c =
|
|
2738
|
-
cssCode: (d = (l =
|
|
2739
|
-
customFonts: (x = (g =
|
|
2751
|
+
contentId: (c = r.content) == null ? void 0 : c.id,
|
|
2752
|
+
cssCode: (d = (l = r.content) == null ? void 0 : l.data) == null ? void 0 : d.cssCode,
|
|
2753
|
+
customFonts: (x = (g = r.content) == null ? void 0 : g.data) == null ? void 0 : x.customFonts
|
|
2740
2754
|
}
|
|
2741
2755
|
) }),
|
|
2742
2756
|
/* @__PURE__ */ jsx(
|
|
2743
2757
|
Blocks,
|
|
2744
2758
|
{
|
|
2745
|
-
blocks: (h = (f =
|
|
2746
|
-
context:
|
|
2759
|
+
blocks: (h = (f = r.content) == null ? void 0 : f.data) == null ? void 0 : h.blocks,
|
|
2760
|
+
context: r,
|
|
2747
2761
|
registeredComponents: o,
|
|
2748
2762
|
linkComponent: e.linkComponent
|
|
2749
2763
|
}
|
|
@@ -2755,7 +2769,7 @@ function ContentComponent(e) {
|
|
|
2755
2769
|
);
|
|
2756
2770
|
}
|
|
2757
2771
|
function ContentVariants(e) {
|
|
2758
|
-
var
|
|
2772
|
+
var r, s;
|
|
2759
2773
|
const [t, n] = useState(
|
|
2760
2774
|
() => checkShouldRenderVariants({
|
|
2761
2775
|
canTrack: getDefaultCanTrack(e.canTrack),
|
|
@@ -2775,7 +2789,7 @@ function ContentVariants(e) {
|
|
|
2775
2789
|
function o() {
|
|
2776
2790
|
return getVariants(e.content).map((c) => `.variant-${c.testVariationId} { display: none; } `).join("");
|
|
2777
2791
|
}
|
|
2778
|
-
function
|
|
2792
|
+
function a() {
|
|
2779
2793
|
var c;
|
|
2780
2794
|
return t ? {
|
|
2781
2795
|
...e.content,
|
|
@@ -2792,7 +2806,7 @@ function ContentVariants(e) {
|
|
|
2792
2806
|
/* @__PURE__ */ jsx(
|
|
2793
2807
|
InlinedStyles,
|
|
2794
2808
|
{
|
|
2795
|
-
id: `variants-styles-${(
|
|
2809
|
+
id: `variants-styles-${(r = e.content) == null ? void 0 : r.id}`,
|
|
2796
2810
|
styles: o()
|
|
2797
2811
|
}
|
|
2798
2812
|
),
|
|
@@ -2826,7 +2840,7 @@ function ContentVariants(e) {
|
|
|
2826
2840
|
/* @__PURE__ */ jsx(
|
|
2827
2841
|
ContentComponent,
|
|
2828
2842
|
{
|
|
2829
|
-
content:
|
|
2843
|
+
content: a(),
|
|
2830
2844
|
showContent: !0,
|
|
2831
2845
|
model: e.model,
|
|
2832
2846
|
data: e.data,
|
|
@@ -2869,7 +2883,7 @@ const fetchSymbolContent = async ({
|
|
|
2869
2883
|
});
|
|
2870
2884
|
};
|
|
2871
2885
|
function Symbol$1(e) {
|
|
2872
|
-
var
|
|
2886
|
+
var a, r, s, c;
|
|
2873
2887
|
function t() {
|
|
2874
2888
|
var l, d;
|
|
2875
2889
|
return [
|
|
@@ -2902,11 +2916,11 @@ function Symbol$1(e) {
|
|
|
2902
2916
|
apiKey: e.builderContext.apiKey,
|
|
2903
2917
|
context: {
|
|
2904
2918
|
...e.builderContext.context,
|
|
2905
|
-
symbolId: (
|
|
2919
|
+
symbolId: (a = e.builderBlock) == null ? void 0 : a.id
|
|
2906
2920
|
},
|
|
2907
2921
|
customComponents: Object.values(e.builderComponents),
|
|
2908
2922
|
data: {
|
|
2909
|
-
...(
|
|
2923
|
+
...(r = e.symbol) == null ? void 0 : r.data,
|
|
2910
2924
|
...e.builderContext.localState,
|
|
2911
2925
|
...(s = n == null ? void 0 : n.data) == null ? void 0 : s.state
|
|
2912
2926
|
},
|