@builder.io/sdk-qwik 0.1.4-0 → 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/lib/index.qwik.cjs +944 -872
- package/lib/index.qwik.mjs +945 -873
- package/package.json +1 -1
- package/types/components/render-block/render-block.d.ts +3 -0
- package/types/components/render-block/render-component.d.ts +8 -1
- package/types/components/render-content/components/render-styles.d.ts +2 -13
- package/types/components/render-content/components/render-styles.helpers.d.ts +15 -0
- package/types/components/render-content/render-content.d.ts +6 -18
- package/types/components/render-content/render-content.helpers.d.ts +7 -0
- package/types/components/render-content/render-content.types.d.ts +27 -0
- package/types/context/types.d.ts +1 -0
- package/types/index-helpers/blocks-exports.d.ts +6 -6
- package/types/types/builder-content.d.ts +1 -2
- package/types/types/input.d.ts +117 -0
package/lib/index.qwik.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { componentQrl, inlinedQrl, useStylesScopedQrl, _wrapSignal, _IMMUTABLE, createContext, useLexicalScope, useContextProvider, useStore, useContext, Slot, Fragment as Fragment$1, useTaskQrl, useRef, useClientEffectQrl, useCleanupQrl } from "@builder.io/qwik";
|
|
2
2
|
import { jsx, Fragment, jsxs } from "@builder.io/qwik/jsx-runtime";
|
|
3
3
|
const TARGET = "qwik";
|
|
4
4
|
function isBrowser() {
|
|
@@ -130,7 +130,35 @@ const setupBrowserForEditing = (options = {}) => {
|
|
|
130
130
|
});
|
|
131
131
|
}
|
|
132
132
|
};
|
|
133
|
-
const
|
|
133
|
+
const Button = /* @__PURE__ */ componentQrl(inlinedQrl((props) => {
|
|
134
|
+
useStylesScopedQrl(inlinedQrl(STYLES$3, "Button_component_useStylesScoped_a1JZ0Q0Q2Oc"));
|
|
135
|
+
return /* @__PURE__ */ jsx(Fragment, {
|
|
136
|
+
children: props.link ? /* @__PURE__ */ jsx("a", {
|
|
137
|
+
role: "button",
|
|
138
|
+
...props.attributes,
|
|
139
|
+
get href() {
|
|
140
|
+
return props.link;
|
|
141
|
+
},
|
|
142
|
+
target: props.openLinkInNewTab ? "_blank" : void 0,
|
|
143
|
+
children: _wrapSignal(props, "text"),
|
|
144
|
+
[_IMMUTABLE]: {
|
|
145
|
+
href: _wrapSignal(props, "link")
|
|
146
|
+
}
|
|
147
|
+
}) : /* @__PURE__ */ jsx("button", {
|
|
148
|
+
class: "button-Button",
|
|
149
|
+
...props.attributes,
|
|
150
|
+
children: _wrapSignal(props, "text")
|
|
151
|
+
}),
|
|
152
|
+
[_IMMUTABLE]: {
|
|
153
|
+
children: false
|
|
154
|
+
}
|
|
155
|
+
}, "jc_0");
|
|
156
|
+
}, "Button_component_gJoMUICXoUQ"));
|
|
157
|
+
const STYLES$3 = `
|
|
158
|
+
.button-Button {
|
|
159
|
+
all: unset;
|
|
160
|
+
}`;
|
|
161
|
+
const builderContext = createContext("Builder");
|
|
134
162
|
function isIframe() {
|
|
135
163
|
return isBrowser() && window.self !== window.top;
|
|
136
164
|
}
|
|
@@ -273,8 +301,13 @@ const RenderInlinedStyles = (props) => {
|
|
|
273
301
|
const state = {};
|
|
274
302
|
state.tag = tag$1();
|
|
275
303
|
return /* @__PURE__ */ jsx(Fragment, {
|
|
276
|
-
children: /* @__PURE__ */ jsx(
|
|
277
|
-
|
|
304
|
+
children: /* @__PURE__ */ jsx("style", {
|
|
305
|
+
get dangerouslySetInnerHTML() {
|
|
306
|
+
return props.styles;
|
|
307
|
+
},
|
|
308
|
+
[_IMMUTABLE]: {
|
|
309
|
+
dangerouslySetInnerHTML: _wrapSignal(props, "styles")
|
|
310
|
+
}
|
|
278
311
|
}),
|
|
279
312
|
[_IMMUTABLE]: {
|
|
280
313
|
children: false
|
|
@@ -499,7 +532,7 @@ const RenderComponent = (props) => {
|
|
|
499
532
|
}, "R9_0");
|
|
500
533
|
};
|
|
501
534
|
const RenderRepeatedBlock = /* @__PURE__ */ componentQrl(inlinedQrl((props) => {
|
|
502
|
-
useContextProvider(
|
|
535
|
+
useContextProvider(builderContext, useStore({
|
|
503
536
|
content: props.repeatContext.content,
|
|
504
537
|
state: props.repeatContext.state,
|
|
505
538
|
context: props.repeatContext.context,
|
|
@@ -537,10 +570,24 @@ const useBlock = function useBlock22(props, state) {
|
|
|
537
570
|
shouldEvaluateBindings: true
|
|
538
571
|
});
|
|
539
572
|
};
|
|
573
|
+
const proxyState = function proxyState2(props, state) {
|
|
574
|
+
if (typeof Proxy === "undefined") {
|
|
575
|
+
console.error("no Proxy available in this environment, cannot proxy state.");
|
|
576
|
+
return props.context.state;
|
|
577
|
+
}
|
|
578
|
+
const useState = new Proxy(props.context.state, {
|
|
579
|
+
set: (obj, prop, value) => {
|
|
580
|
+
obj[prop] = value;
|
|
581
|
+
props.context.setState?.(obj);
|
|
582
|
+
return true;
|
|
583
|
+
}
|
|
584
|
+
});
|
|
585
|
+
return useState;
|
|
586
|
+
};
|
|
540
587
|
const actions = function actions2(props, state) {
|
|
541
588
|
return getBlockActions({
|
|
542
589
|
block: useBlock(props),
|
|
543
|
-
state: props
|
|
590
|
+
state: proxyState(props),
|
|
544
591
|
context: props.context.context
|
|
545
592
|
});
|
|
546
593
|
};
|
|
@@ -587,6 +634,7 @@ const childrenContext = function childrenContext2(props, state) {
|
|
|
587
634
|
state: props.context.state,
|
|
588
635
|
content: props.context.content,
|
|
589
636
|
context: props.context.context,
|
|
637
|
+
setState: props.context.setState,
|
|
590
638
|
registeredComponents: props.context.registeredComponents,
|
|
591
639
|
inheritedStyles: getInheritedTextStyles()
|
|
592
640
|
};
|
|
@@ -649,10 +697,10 @@ const RenderBlock = (props) => {
|
|
|
649
697
|
}, "9d_3");
|
|
650
698
|
};
|
|
651
699
|
const RenderBlock$1 = RenderBlock;
|
|
652
|
-
const className$1 = function className2(props, state,
|
|
700
|
+
const className$1 = function className2(props, state, builderContext2) {
|
|
653
701
|
return "builder-blocks" + (!props.blocks?.length ? " no-blocks" : "");
|
|
654
702
|
};
|
|
655
|
-
const onClick$1 = function onClick2(props, state,
|
|
703
|
+
const onClick$1 = function onClick2(props, state, builderContext2) {
|
|
656
704
|
if (isEditing() && !props.blocks?.length)
|
|
657
705
|
window.parent?.postMessage({
|
|
658
706
|
type: "builder.clickEmptyBlocks",
|
|
@@ -662,7 +710,7 @@ const onClick$1 = function onClick2(props, state, builderContext) {
|
|
|
662
710
|
}
|
|
663
711
|
}, "*");
|
|
664
712
|
};
|
|
665
|
-
const onMouseEnter = function onMouseEnter2(props, state,
|
|
713
|
+
const onMouseEnter = function onMouseEnter2(props, state, builderContext2) {
|
|
666
714
|
if (isEditing() && !props.blocks?.length)
|
|
667
715
|
window.parent?.postMessage({
|
|
668
716
|
type: "builder.hoverEmptyBlocks",
|
|
@@ -673,8 +721,8 @@ const onMouseEnter = function onMouseEnter2(props, state, builderContext) {
|
|
|
673
721
|
}, "*");
|
|
674
722
|
};
|
|
675
723
|
const RenderBlocks = /* @__PURE__ */ componentQrl(inlinedQrl((props) => {
|
|
676
|
-
useStylesScopedQrl(inlinedQrl(STYLES$
|
|
677
|
-
const builderContext = useContext(
|
|
724
|
+
useStylesScopedQrl(inlinedQrl(STYLES$2, "RenderBlocks_component_useStylesScoped_0XKYzaR059E"));
|
|
725
|
+
const builderContext$1 = useContext(builderContext);
|
|
678
726
|
const state = {};
|
|
679
727
|
return /* @__PURE__ */ jsxs("div", {
|
|
680
728
|
class: className$1(props) + " div-RenderBlocks",
|
|
@@ -691,7 +739,7 @@ const RenderBlocks = /* @__PURE__ */ componentQrl(inlinedQrl((props) => {
|
|
|
691
739
|
const [builderContext2, props2, state2] = useLexicalScope();
|
|
692
740
|
return onClick$1(props2);
|
|
693
741
|
}, "RenderBlocks_component_div_onClick_RzhhZa265Yg", [
|
|
694
|
-
builderContext,
|
|
742
|
+
builderContext$1,
|
|
695
743
|
props,
|
|
696
744
|
state
|
|
697
745
|
]),
|
|
@@ -699,7 +747,7 @@ const RenderBlocks = /* @__PURE__ */ componentQrl(inlinedQrl((props) => {
|
|
|
699
747
|
const [builderContext2, props2, state2] = useLexicalScope();
|
|
700
748
|
return onMouseEnter(props2);
|
|
701
749
|
}, "RenderBlocks_component_div_onMouseEnter_nG7I7RYG3JQ", [
|
|
702
|
-
builderContext,
|
|
750
|
+
builderContext$1,
|
|
703
751
|
props,
|
|
704
752
|
state
|
|
705
753
|
]),
|
|
@@ -707,13 +755,13 @@ const RenderBlocks = /* @__PURE__ */ componentQrl(inlinedQrl((props) => {
|
|
|
707
755
|
props.blocks ? (props.blocks || []).map(function(block) {
|
|
708
756
|
return /* @__PURE__ */ jsx(RenderBlock$1, {
|
|
709
757
|
block,
|
|
710
|
-
context: builderContext
|
|
758
|
+
context: builderContext$1
|
|
711
759
|
}, "render-block-" + block.id);
|
|
712
760
|
}) : null,
|
|
713
761
|
props.blocks ? (props.blocks || []).map(function(block) {
|
|
714
762
|
return /* @__PURE__ */ jsx(BlockStyles, {
|
|
715
763
|
block,
|
|
716
|
-
context: builderContext
|
|
764
|
+
context: builderContext$1
|
|
717
765
|
}, "block-style-" + block.id);
|
|
718
766
|
}) : null
|
|
719
767
|
],
|
|
@@ -725,7 +773,7 @@ const RenderBlocks = /* @__PURE__ */ componentQrl(inlinedQrl((props) => {
|
|
|
725
773
|
}
|
|
726
774
|
});
|
|
727
775
|
}, "RenderBlocks_component_MYUZ0j1uLsw"));
|
|
728
|
-
const STYLES$
|
|
776
|
+
const STYLES$2 = `
|
|
729
777
|
.div-RenderBlocks {
|
|
730
778
|
display: flex;
|
|
731
779
|
flex-direction: column;
|
|
@@ -820,7 +868,7 @@ const columnsStyles = function columnsStyles2(props, state) {
|
|
|
820
868
|
`;
|
|
821
869
|
};
|
|
822
870
|
const Columns = /* @__PURE__ */ componentQrl(inlinedQrl((props) => {
|
|
823
|
-
useStylesScopedQrl(inlinedQrl(STYLES$
|
|
871
|
+
useStylesScopedQrl(inlinedQrl(STYLES$1, "Columns_component_useStylesScoped_s7JLZz7MCCQ"));
|
|
824
872
|
const state = {};
|
|
825
873
|
return /* @__PURE__ */ jsxs("div", {
|
|
826
874
|
class: `builder-columns ${props.builderBlock.id}-breakpoints div-Columns`,
|
|
@@ -865,7 +913,7 @@ const Columns = /* @__PURE__ */ componentQrl(inlinedQrl((props) => {
|
|
|
865
913
|
}
|
|
866
914
|
});
|
|
867
915
|
}, "Columns_component_7yLj4bxdI6c"));
|
|
868
|
-
const STYLES$
|
|
916
|
+
const STYLES$1 = `
|
|
869
917
|
.div-Columns {
|
|
870
918
|
display: flex;
|
|
871
919
|
line-height: normal;
|
|
@@ -874,6 +922,11 @@ const STYLES$2 = `
|
|
|
874
922
|
flex-direction: column;
|
|
875
923
|
align-items: stretch;
|
|
876
924
|
}`;
|
|
925
|
+
const FragmentComponent = /* @__PURE__ */ componentQrl(inlinedQrl((props) => {
|
|
926
|
+
return /* @__PURE__ */ jsx("span", {
|
|
927
|
+
children: /* @__PURE__ */ jsx(Slot, {}, "oj_0")
|
|
928
|
+
});
|
|
929
|
+
}, "FragmentComponent_component_T0AypnadAK0"));
|
|
877
930
|
function removeProtocol(path) {
|
|
878
931
|
return path.replace(/http(s)?:/, "");
|
|
879
932
|
}
|
|
@@ -960,7 +1013,7 @@ const aspectRatioCss = function aspectRatioCss2(props, state) {
|
|
|
960
1013
|
return out;
|
|
961
1014
|
};
|
|
962
1015
|
const Image = /* @__PURE__ */ componentQrl(inlinedQrl((props) => {
|
|
963
|
-
useStylesScopedQrl(inlinedQrl(STYLES
|
|
1016
|
+
useStylesScopedQrl(inlinedQrl(STYLES, "Image_component_useStylesScoped_fBMYiVf9fuU"));
|
|
964
1017
|
return /* @__PURE__ */ jsxs(Fragment$1, {
|
|
965
1018
|
children: [
|
|
966
1019
|
/* @__PURE__ */ jsxs("picture", {
|
|
@@ -1016,7 +1069,7 @@ const Image = /* @__PURE__ */ componentQrl(inlinedQrl((props) => {
|
|
|
1016
1069
|
}
|
|
1017
1070
|
}, "0A_2");
|
|
1018
1071
|
}, "Image_component_LRxDkFa1EfU"));
|
|
1019
|
-
const STYLES
|
|
1072
|
+
const STYLES = `
|
|
1020
1073
|
.img-Image {
|
|
1021
1074
|
opacity: 1;
|
|
1022
1075
|
transition: opacity 0.2s ease-in-out;
|
|
@@ -1034,90 +1087,6 @@ const STYLES$1 = `
|
|
|
1034
1087
|
width: 100%;
|
|
1035
1088
|
height: 100%;
|
|
1036
1089
|
}`;
|
|
1037
|
-
const Text = /* @__PURE__ */ componentQrl(inlinedQrl((props) => {
|
|
1038
|
-
return /* @__PURE__ */ jsx("span", {
|
|
1039
|
-
class: "builder-text",
|
|
1040
|
-
get dangerouslySetInnerHTML() {
|
|
1041
|
-
return props.text;
|
|
1042
|
-
},
|
|
1043
|
-
[_IMMUTABLE]: {
|
|
1044
|
-
dangerouslySetInnerHTML: _wrapSignal(props, "text")
|
|
1045
|
-
}
|
|
1046
|
-
});
|
|
1047
|
-
}, "Text_component_15p0cKUxgIE"));
|
|
1048
|
-
const videoProps = function videoProps2(props, state) {
|
|
1049
|
-
return {
|
|
1050
|
-
...props.autoPlay === true ? {
|
|
1051
|
-
autoPlay: true
|
|
1052
|
-
} : {},
|
|
1053
|
-
...props.muted === true ? {
|
|
1054
|
-
muted: true
|
|
1055
|
-
} : {},
|
|
1056
|
-
...props.controls === true ? {
|
|
1057
|
-
controls: true
|
|
1058
|
-
} : {},
|
|
1059
|
-
...props.loop === true ? {
|
|
1060
|
-
loop: true
|
|
1061
|
-
} : {},
|
|
1062
|
-
...props.playsInline === true ? {
|
|
1063
|
-
playsInline: true
|
|
1064
|
-
} : {}
|
|
1065
|
-
};
|
|
1066
|
-
};
|
|
1067
|
-
const spreadProps = function spreadProps2(props, state) {
|
|
1068
|
-
return {
|
|
1069
|
-
...props.attributes,
|
|
1070
|
-
...videoProps(props)
|
|
1071
|
-
};
|
|
1072
|
-
};
|
|
1073
|
-
const Video = /* @__PURE__ */ componentQrl(inlinedQrl((props) => {
|
|
1074
|
-
return /* @__PURE__ */ jsx("video", {
|
|
1075
|
-
...spreadProps(props),
|
|
1076
|
-
style: {
|
|
1077
|
-
width: "100%",
|
|
1078
|
-
height: "100%",
|
|
1079
|
-
...props.attributes?.style,
|
|
1080
|
-
objectFit: props.fit,
|
|
1081
|
-
objectPosition: props.position,
|
|
1082
|
-
borderRadius: 1
|
|
1083
|
-
},
|
|
1084
|
-
src: props.video || "no-src",
|
|
1085
|
-
get poster() {
|
|
1086
|
-
return props.posterImage;
|
|
1087
|
-
},
|
|
1088
|
-
[_IMMUTABLE]: {
|
|
1089
|
-
poster: _wrapSignal(props, "posterImage")
|
|
1090
|
-
}
|
|
1091
|
-
});
|
|
1092
|
-
}, "Video_component_qdcTZflYyoQ"));
|
|
1093
|
-
const Button = /* @__PURE__ */ componentQrl(inlinedQrl((props) => {
|
|
1094
|
-
useStylesScopedQrl(inlinedQrl(STYLES, "Button_component_useStylesScoped_a1JZ0Q0Q2Oc"));
|
|
1095
|
-
return /* @__PURE__ */ jsx(Fragment, {
|
|
1096
|
-
children: props.link ? /* @__PURE__ */ jsx("a", {
|
|
1097
|
-
role: "button",
|
|
1098
|
-
...props.attributes,
|
|
1099
|
-
get href() {
|
|
1100
|
-
return props.link;
|
|
1101
|
-
},
|
|
1102
|
-
target: props.openLinkInNewTab ? "_blank" : void 0,
|
|
1103
|
-
children: _wrapSignal(props, "text"),
|
|
1104
|
-
[_IMMUTABLE]: {
|
|
1105
|
-
href: _wrapSignal(props, "link")
|
|
1106
|
-
}
|
|
1107
|
-
}) : /* @__PURE__ */ jsx("button", {
|
|
1108
|
-
class: "button-Button",
|
|
1109
|
-
...props.attributes,
|
|
1110
|
-
children: _wrapSignal(props, "text")
|
|
1111
|
-
}),
|
|
1112
|
-
[_IMMUTABLE]: {
|
|
1113
|
-
children: false
|
|
1114
|
-
}
|
|
1115
|
-
}, "jc_0");
|
|
1116
|
-
}, "Button_component_gJoMUICXoUQ"));
|
|
1117
|
-
const STYLES = `
|
|
1118
|
-
.button-Button {
|
|
1119
|
-
all: unset;
|
|
1120
|
-
}`;
|
|
1121
1090
|
const componentInfo$a = {
|
|
1122
1091
|
name: "Core:Button",
|
|
1123
1092
|
builtIn: true,
|
|
@@ -1410,11 +1379,6 @@ const componentInfo$8 = {
|
|
|
1410
1379
|
canHaveChildren: true,
|
|
1411
1380
|
noWrap: true
|
|
1412
1381
|
};
|
|
1413
|
-
const FragmentComponent = /* @__PURE__ */ componentQrl(inlinedQrl((props) => {
|
|
1414
|
-
return /* @__PURE__ */ jsx("span", {
|
|
1415
|
-
children: /* @__PURE__ */ jsx(Slot, {}, "oj_0")
|
|
1416
|
-
});
|
|
1417
|
-
}, "FragmentComponent_component_T0AypnadAK0"));
|
|
1418
1382
|
const componentInfo$7 = {
|
|
1419
1383
|
name: "Image",
|
|
1420
1384
|
static: true,
|
|
@@ -1668,667 +1632,787 @@ const componentInfo$5 = {
|
|
|
1668
1632
|
}
|
|
1669
1633
|
]
|
|
1670
1634
|
};
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1635
|
+
function getGlobalThis() {
|
|
1636
|
+
if (typeof globalThis !== "undefined")
|
|
1637
|
+
return globalThis;
|
|
1638
|
+
if (typeof window !== "undefined")
|
|
1639
|
+
return window;
|
|
1640
|
+
if (typeof global !== "undefined")
|
|
1641
|
+
return global;
|
|
1642
|
+
if (typeof self !== "undefined")
|
|
1643
|
+
return self;
|
|
1644
|
+
return globalThis;
|
|
1645
|
+
}
|
|
1646
|
+
function getFetch() {
|
|
1647
|
+
const globalFetch = getGlobalThis().fetch;
|
|
1648
|
+
if (typeof globalFetch === "undefined") {
|
|
1649
|
+
console.warn(`Builder SDK could not find a global fetch function. Make sure you have a polyfill for fetch in your project.
|
|
1650
|
+
For more information, read https://github.com/BuilderIO/this-package-uses-fetch`);
|
|
1651
|
+
throw new Error("Builder SDK could not find a global `fetch` function");
|
|
1652
|
+
}
|
|
1653
|
+
return globalFetch;
|
|
1654
|
+
}
|
|
1655
|
+
const fetch$1 = getFetch();
|
|
1656
|
+
const getTopLevelDomain = (host) => {
|
|
1657
|
+
if (host === "localhost" || host === "127.0.0.1")
|
|
1658
|
+
return host;
|
|
1659
|
+
const parts = host.split(".");
|
|
1660
|
+
if (parts.length > 2)
|
|
1661
|
+
return parts.slice(1).join(".");
|
|
1662
|
+
return host;
|
|
1663
|
+
};
|
|
1664
|
+
const getCookie = async ({ name, canTrack }) => {
|
|
1665
|
+
try {
|
|
1666
|
+
if (!canTrack)
|
|
1667
|
+
return void 0;
|
|
1668
|
+
return document.cookie.split("; ").find((row) => row.startsWith(`${name}=`))?.split("=")[1];
|
|
1669
|
+
} catch (err) {
|
|
1670
|
+
console.debug("[COOKIE] GET error: ", err);
|
|
1671
|
+
return void 0;
|
|
1672
|
+
}
|
|
1673
|
+
};
|
|
1674
|
+
const stringifyCookie = (cookie) => cookie.map(([key, value]) => value ? `${key}=${value}` : key).filter(checkIsDefined).join("; ");
|
|
1675
|
+
const SECURE_CONFIG = [
|
|
1676
|
+
[
|
|
1677
|
+
"secure",
|
|
1678
|
+
""
|
|
1685
1679
|
],
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
|
|
1680
|
+
[
|
|
1681
|
+
"SameSite",
|
|
1682
|
+
"None"
|
|
1683
|
+
]
|
|
1684
|
+
];
|
|
1685
|
+
const createCookieString = ({ name, value, expires }) => {
|
|
1686
|
+
const secure = isBrowser() ? location.protocol === "https:" : true;
|
|
1687
|
+
const secureObj = secure ? SECURE_CONFIG : [
|
|
1688
|
+
[]
|
|
1689
|
+
];
|
|
1690
|
+
const expiresObj = expires ? [
|
|
1691
|
+
[
|
|
1692
|
+
"expires",
|
|
1693
|
+
expires.toUTCString()
|
|
1694
|
+
]
|
|
1695
|
+
] : [
|
|
1696
|
+
[]
|
|
1697
|
+
];
|
|
1698
|
+
const cookieValue = [
|
|
1699
|
+
[
|
|
1700
|
+
name,
|
|
1701
|
+
value
|
|
1702
|
+
],
|
|
1703
|
+
...expiresObj,
|
|
1704
|
+
[
|
|
1705
|
+
"path",
|
|
1706
|
+
"/"
|
|
1707
|
+
],
|
|
1708
|
+
[
|
|
1709
|
+
"domain",
|
|
1710
|
+
getTopLevelDomain(window.location.hostname)
|
|
1711
|
+
],
|
|
1712
|
+
...secureObj
|
|
1713
|
+
];
|
|
1714
|
+
const cookie = stringifyCookie(cookieValue);
|
|
1715
|
+
return cookie;
|
|
1716
|
+
};
|
|
1717
|
+
const setCookie = async ({ name, value, expires, canTrack }) => {
|
|
1718
|
+
try {
|
|
1719
|
+
if (!canTrack)
|
|
1720
|
+
return;
|
|
1721
|
+
const cookie = createCookieString({
|
|
1722
|
+
name,
|
|
1723
|
+
value,
|
|
1724
|
+
expires
|
|
1725
|
+
});
|
|
1726
|
+
document.cookie = cookie;
|
|
1727
|
+
} catch (err) {
|
|
1728
|
+
console.warn("[COOKIE] SET error: ", err);
|
|
1690
1729
|
}
|
|
1691
1730
|
};
|
|
1692
|
-
const
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
type: "file",
|
|
1715
|
-
allowedFileTypes: [
|
|
1716
|
-
"jpeg",
|
|
1717
|
-
"png"
|
|
1718
|
-
],
|
|
1719
|
-
helperText: "Image to show before the video plays"
|
|
1720
|
-
},
|
|
1721
|
-
{
|
|
1722
|
-
name: "autoPlay",
|
|
1723
|
-
type: "boolean",
|
|
1724
|
-
defaultValue: true
|
|
1725
|
-
},
|
|
1726
|
-
{
|
|
1727
|
-
name: "controls",
|
|
1728
|
-
type: "boolean",
|
|
1729
|
-
defaultValue: false
|
|
1730
|
-
},
|
|
1731
|
-
{
|
|
1732
|
-
name: "muted",
|
|
1733
|
-
type: "boolean",
|
|
1734
|
-
defaultValue: true
|
|
1735
|
-
},
|
|
1736
|
-
{
|
|
1737
|
-
name: "loop",
|
|
1738
|
-
type: "boolean",
|
|
1739
|
-
defaultValue: true
|
|
1740
|
-
},
|
|
1741
|
-
{
|
|
1742
|
-
name: "playsInline",
|
|
1743
|
-
type: "boolean",
|
|
1744
|
-
defaultValue: true
|
|
1745
|
-
},
|
|
1746
|
-
{
|
|
1747
|
-
name: "fit",
|
|
1748
|
-
type: "text",
|
|
1749
|
-
defaultValue: "cover",
|
|
1750
|
-
enum: [
|
|
1751
|
-
"contain",
|
|
1752
|
-
"cover",
|
|
1753
|
-
"fill",
|
|
1754
|
-
"auto"
|
|
1755
|
-
]
|
|
1756
|
-
},
|
|
1757
|
-
{
|
|
1758
|
-
name: "fitContent",
|
|
1759
|
-
type: "boolean",
|
|
1760
|
-
helperText: "When child blocks are provided, fit to them instead of using the aspect ratio",
|
|
1761
|
-
defaultValue: true,
|
|
1762
|
-
advanced: true
|
|
1763
|
-
},
|
|
1764
|
-
{
|
|
1765
|
-
name: "position",
|
|
1766
|
-
type: "text",
|
|
1767
|
-
defaultValue: "center",
|
|
1768
|
-
enum: [
|
|
1769
|
-
"center",
|
|
1770
|
-
"top",
|
|
1771
|
-
"left",
|
|
1772
|
-
"right",
|
|
1773
|
-
"bottom",
|
|
1774
|
-
"top left",
|
|
1775
|
-
"top right",
|
|
1776
|
-
"bottom left",
|
|
1777
|
-
"bottom right"
|
|
1778
|
-
]
|
|
1779
|
-
},
|
|
1780
|
-
{
|
|
1781
|
-
name: "height",
|
|
1782
|
-
type: "number",
|
|
1783
|
-
advanced: true
|
|
1784
|
-
},
|
|
1785
|
-
{
|
|
1786
|
-
name: "width",
|
|
1787
|
-
type: "number",
|
|
1788
|
-
advanced: true
|
|
1789
|
-
},
|
|
1790
|
-
{
|
|
1791
|
-
name: "aspectRatio",
|
|
1792
|
-
type: "number",
|
|
1793
|
-
advanced: true,
|
|
1794
|
-
defaultValue: 0.7004048582995948
|
|
1795
|
-
},
|
|
1796
|
-
{
|
|
1797
|
-
name: "lazyLoad",
|
|
1798
|
-
type: "boolean",
|
|
1799
|
-
helperText: 'Load this video "lazily" - as in only when a user scrolls near the video. Recommended for optmized performance and bandwidth consumption',
|
|
1800
|
-
defaultValue: true,
|
|
1801
|
-
advanced: true
|
|
1802
|
-
}
|
|
1803
|
-
]
|
|
1731
|
+
const BUILDER_STORE_PREFIX = "builderio.variations";
|
|
1732
|
+
const getContentTestKey = (id) => `${BUILDER_STORE_PREFIX}.${id}`;
|
|
1733
|
+
const getContentVariationCookie = ({ contentId, canTrack }) => getCookie({
|
|
1734
|
+
name: getContentTestKey(contentId),
|
|
1735
|
+
canTrack
|
|
1736
|
+
});
|
|
1737
|
+
const setContentVariationCookie = ({ contentId, canTrack, value }) => setCookie({
|
|
1738
|
+
name: getContentTestKey(contentId),
|
|
1739
|
+
value,
|
|
1740
|
+
canTrack
|
|
1741
|
+
});
|
|
1742
|
+
const checkIsBuilderContentWithVariations = (item) => checkIsDefined(item.id) && checkIsDefined(item.variations) && Object.keys(item.variations).length > 0;
|
|
1743
|
+
const getRandomVariationId = ({ id, variations }) => {
|
|
1744
|
+
let n = 0;
|
|
1745
|
+
const random = Math.random();
|
|
1746
|
+
for (const id1 in variations) {
|
|
1747
|
+
const testRatio = variations[id1]?.testRatio;
|
|
1748
|
+
n += testRatio;
|
|
1749
|
+
if (random < n)
|
|
1750
|
+
return id1;
|
|
1751
|
+
}
|
|
1752
|
+
return id;
|
|
1804
1753
|
};
|
|
1805
|
-
const
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
|
|
1812
|
-
|
|
1813
|
-
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
|
|
1817
|
-
|
|
1818
|
-
if (url) {
|
|
1819
|
-
options.set("content", "Loading...");
|
|
1820
|
-
const apiKey = "ae0e60e78201a3f2b0de4b";
|
|
1821
|
-
return fetch(`https://iframe.ly/api/iframely?url=${url}&api_key=${apiKey}`).then((res) => res.json()).then((data) => {
|
|
1822
|
-
if (options.get("url") === url) {
|
|
1823
|
-
if (data.html)
|
|
1824
|
-
options.set("content", data.html);
|
|
1825
|
-
else
|
|
1826
|
-
options.set("content", "Invalid url, please try another");
|
|
1827
|
-
}
|
|
1828
|
-
}).catch((_err) => {
|
|
1829
|
-
options.set("content", "There was an error embedding this URL, please try again or another URL");
|
|
1830
|
-
});
|
|
1831
|
-
} else
|
|
1832
|
-
options.delete("content");
|
|
1833
|
-
})
|
|
1834
|
-
},
|
|
1835
|
-
{
|
|
1836
|
-
name: "content",
|
|
1837
|
-
type: "html",
|
|
1838
|
-
defaultValue: '<div style="padding: 20px; text-align: center">(Choose an embed URL)<div>',
|
|
1839
|
-
hideFromUI: true
|
|
1840
|
-
}
|
|
1841
|
-
]
|
|
1754
|
+
const getTestFields = ({ item, testGroupId }) => {
|
|
1755
|
+
const variationValue = item.variations[testGroupId];
|
|
1756
|
+
if (testGroupId === item.id || !variationValue)
|
|
1757
|
+
return {
|
|
1758
|
+
testVariationId: item.id,
|
|
1759
|
+
testVariationName: "Default"
|
|
1760
|
+
};
|
|
1761
|
+
else
|
|
1762
|
+
return {
|
|
1763
|
+
data: variationValue.data,
|
|
1764
|
+
testVariationId: variationValue.id,
|
|
1765
|
+
testVariationName: variationValue.name || (variationValue.id === item.id ? "Default" : "")
|
|
1766
|
+
};
|
|
1842
1767
|
};
|
|
1843
|
-
const
|
|
1844
|
-
|
|
1845
|
-
|
|
1846
|
-
|
|
1847
|
-
|
|
1848
|
-
const
|
|
1849
|
-
|
|
1850
|
-
|
|
1768
|
+
const getContentVariation = async ({ item, canTrack }) => {
|
|
1769
|
+
const testGroupId = await getContentVariationCookie({
|
|
1770
|
+
canTrack,
|
|
1771
|
+
contentId: item.id
|
|
1772
|
+
});
|
|
1773
|
+
const testFields = testGroupId ? getTestFields({
|
|
1774
|
+
item,
|
|
1775
|
+
testGroupId
|
|
1776
|
+
}) : void 0;
|
|
1777
|
+
if (testFields)
|
|
1778
|
+
return testFields;
|
|
1779
|
+
else {
|
|
1780
|
+
const randomVariationId = getRandomVariationId({
|
|
1781
|
+
variations: item.variations,
|
|
1782
|
+
id: item.id
|
|
1783
|
+
});
|
|
1784
|
+
setContentVariationCookie({
|
|
1785
|
+
contentId: item.id,
|
|
1786
|
+
value: randomVariationId,
|
|
1787
|
+
canTrack
|
|
1788
|
+
}).catch((err) => {
|
|
1789
|
+
console.error("could not store A/B test variation: ", err);
|
|
1790
|
+
});
|
|
1791
|
+
return getTestFields({
|
|
1792
|
+
item,
|
|
1793
|
+
testGroupId: randomVariationId
|
|
1794
|
+
});
|
|
1795
|
+
}
|
|
1796
|
+
};
|
|
1797
|
+
const handleABTesting = async ({ item, canTrack }) => {
|
|
1798
|
+
if (!checkIsBuilderContentWithVariations(item))
|
|
1851
1799
|
return;
|
|
1852
|
-
const
|
|
1853
|
-
|
|
1854
|
-
|
|
1855
|
-
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
|
|
1863
|
-
|
|
1864
|
-
|
|
1865
|
-
|
|
1866
|
-
|
|
1867
|
-
|
|
1800
|
+
const variationValue = await getContentVariation({
|
|
1801
|
+
item,
|
|
1802
|
+
canTrack
|
|
1803
|
+
});
|
|
1804
|
+
Object.assign(item, variationValue);
|
|
1805
|
+
};
|
|
1806
|
+
function flatten(object, path = null, separator = ".") {
|
|
1807
|
+
return Object.keys(object).reduce((acc, key) => {
|
|
1808
|
+
const value = object[key];
|
|
1809
|
+
const newPath = [
|
|
1810
|
+
path,
|
|
1811
|
+
key
|
|
1812
|
+
].filter(Boolean).join(separator);
|
|
1813
|
+
const isObject = [
|
|
1814
|
+
typeof value === "object",
|
|
1815
|
+
value !== null,
|
|
1816
|
+
!(Array.isArray(value) && value.length === 0)
|
|
1817
|
+
].every(Boolean);
|
|
1818
|
+
return isObject ? {
|
|
1819
|
+
...acc,
|
|
1820
|
+
...flatten(value, newPath, separator)
|
|
1821
|
+
} : {
|
|
1822
|
+
...acc,
|
|
1823
|
+
[newPath]: value
|
|
1824
|
+
};
|
|
1825
|
+
}, {});
|
|
1826
|
+
}
|
|
1827
|
+
const BUILDER_SEARCHPARAMS_PREFIX = "builder.";
|
|
1828
|
+
const BUILDER_OPTIONS_PREFIX = "options.";
|
|
1829
|
+
const convertSearchParamsToQueryObject = (searchParams) => {
|
|
1830
|
+
const options = {};
|
|
1831
|
+
searchParams.forEach((value, key) => {
|
|
1832
|
+
options[key] = value;
|
|
1833
|
+
});
|
|
1834
|
+
return options;
|
|
1835
|
+
};
|
|
1836
|
+
const getBuilderSearchParams = (_options) => {
|
|
1837
|
+
if (!_options)
|
|
1838
|
+
return {};
|
|
1839
|
+
const options = normalizeSearchParams(_options);
|
|
1840
|
+
const newOptions = {};
|
|
1841
|
+
Object.keys(options).forEach((key) => {
|
|
1842
|
+
if (key.startsWith(BUILDER_SEARCHPARAMS_PREFIX)) {
|
|
1843
|
+
const trimmedKey = key.replace(BUILDER_SEARCHPARAMS_PREFIX, "").replace(BUILDER_OPTIONS_PREFIX, "");
|
|
1844
|
+
newOptions[trimmedKey] = options[key];
|
|
1845
|
+
}
|
|
1846
|
+
});
|
|
1847
|
+
return newOptions;
|
|
1848
|
+
};
|
|
1849
|
+
const getBuilderSearchParamsFromWindow = () => {
|
|
1850
|
+
if (!isBrowser())
|
|
1851
|
+
return {};
|
|
1852
|
+
const searchParams = new URLSearchParams(window.location.search);
|
|
1853
|
+
return getBuilderSearchParams(searchParams);
|
|
1854
|
+
};
|
|
1855
|
+
const normalizeSearchParams = (searchParams) => searchParams instanceof URLSearchParams ? convertSearchParamsToQueryObject(searchParams) : searchParams;
|
|
1856
|
+
const generateContentUrl = (options) => {
|
|
1857
|
+
const { limit = 30, userAttributes, query, noTraverse = false, model, apiKey, includeRefs = true, locale } = options;
|
|
1858
|
+
if (!apiKey)
|
|
1859
|
+
throw new Error("Missing API key");
|
|
1860
|
+
const url = new URL(`https://cdn.builder.io/api/v2/content/${model}?apiKey=${apiKey}&limit=${limit}&noTraverse=${noTraverse}&includeRefs=${includeRefs}${locale ? `&locale=${locale}` : ""}`);
|
|
1861
|
+
const queryOptions = {
|
|
1862
|
+
...getBuilderSearchParamsFromWindow(),
|
|
1863
|
+
...normalizeSearchParams(options.options || {})
|
|
1864
|
+
};
|
|
1865
|
+
const flattened = flatten(queryOptions);
|
|
1866
|
+
for (const key in flattened)
|
|
1867
|
+
url.searchParams.set(key, String(flattened[key]));
|
|
1868
|
+
if (userAttributes)
|
|
1869
|
+
url.searchParams.set("userAttributes", JSON.stringify(userAttributes));
|
|
1870
|
+
if (query) {
|
|
1871
|
+
const flattened1 = flatten({
|
|
1872
|
+
query
|
|
1873
|
+
});
|
|
1874
|
+
for (const key1 in flattened1)
|
|
1875
|
+
url.searchParams.set(key1, JSON.stringify(flattened1[key1]));
|
|
1868
1876
|
}
|
|
1877
|
+
return url;
|
|
1869
1878
|
};
|
|
1870
|
-
|
|
1871
|
-
|
|
1879
|
+
async function getContent(options) {
|
|
1880
|
+
return (await getAllContent({
|
|
1881
|
+
...options,
|
|
1882
|
+
limit: 1
|
|
1883
|
+
})).results[0] || null;
|
|
1884
|
+
}
|
|
1885
|
+
async function getAllContent(options) {
|
|
1886
|
+
const url = generateContentUrl(options);
|
|
1887
|
+
const res = await fetch$1(url.href);
|
|
1888
|
+
const content = await res.json();
|
|
1889
|
+
const canTrack = options.canTrack !== false;
|
|
1890
|
+
if (canTrack && Array.isArray(content.results))
|
|
1891
|
+
for (const item of content.results)
|
|
1892
|
+
await handleABTesting({
|
|
1893
|
+
item,
|
|
1894
|
+
canTrack
|
|
1895
|
+
});
|
|
1896
|
+
return content;
|
|
1897
|
+
}
|
|
1898
|
+
const className = function className22(props, state, builderContext2) {
|
|
1899
|
+
return [
|
|
1900
|
+
...[
|
|
1901
|
+
props.attributes.class
|
|
1902
|
+
],
|
|
1903
|
+
"builder-symbol",
|
|
1904
|
+
props.symbol?.inline ? "builder-inline-symbol" : void 0,
|
|
1905
|
+
props.symbol?.dynamic || props.dynamic ? "builder-dynamic-symbol" : void 0
|
|
1906
|
+
].filter(Boolean).join(" ");
|
|
1907
|
+
};
|
|
1908
|
+
const contentToUse = function contentToUse2(props, state, builderContext2) {
|
|
1909
|
+
return props.symbol?.content || state.fetchedContent;
|
|
1910
|
+
};
|
|
1911
|
+
const Symbol$1 = /* @__PURE__ */ componentQrl(inlinedQrl((props) => {
|
|
1912
|
+
const builderContext$1 = useContext(builderContext);
|
|
1872
1913
|
const state = useStore({
|
|
1873
|
-
|
|
1874
|
-
scriptsInserted: [],
|
|
1875
|
-
scriptsRun: []
|
|
1914
|
+
fetchedContent: null
|
|
1876
1915
|
});
|
|
1877
|
-
|
|
1878
|
-
const [
|
|
1879
|
-
|
|
1880
|
-
|
|
1881
|
-
|
|
1882
|
-
|
|
1883
|
-
|
|
1884
|
-
|
|
1885
|
-
|
|
1916
|
+
useTaskQrl(inlinedQrl(({ track: track2 }) => {
|
|
1917
|
+
const [builderContext2, props2, state2] = useLexicalScope();
|
|
1918
|
+
track2(() => props2.symbol);
|
|
1919
|
+
track2(() => state2.fetchedContent);
|
|
1920
|
+
const symbolToUse = props2.symbol;
|
|
1921
|
+
if (symbolToUse && !symbolToUse.content && !state2.fetchedContent && symbolToUse.model && builderContext2?.apiKey)
|
|
1922
|
+
getContent({
|
|
1923
|
+
model: symbolToUse.model,
|
|
1924
|
+
apiKey: builderContext2.apiKey,
|
|
1925
|
+
query: {
|
|
1926
|
+
id: symbolToUse.entry
|
|
1927
|
+
}
|
|
1928
|
+
}).then((response) => {
|
|
1929
|
+
state2.fetchedContent = response;
|
|
1930
|
+
});
|
|
1931
|
+
}, "Symbol_component_useTask_NIAWAC1bMBo", [
|
|
1932
|
+
builderContext$1,
|
|
1886
1933
|
props,
|
|
1887
1934
|
state
|
|
1888
1935
|
]));
|
|
1889
1936
|
return /* @__PURE__ */ jsx("div", {
|
|
1890
|
-
|
|
1891
|
-
|
|
1937
|
+
...props.attributes,
|
|
1938
|
+
class: className(props),
|
|
1939
|
+
children: /* @__PURE__ */ jsx(RenderContent$1, {
|
|
1940
|
+
get apiKey() {
|
|
1941
|
+
return builderContext$1.apiKey;
|
|
1942
|
+
},
|
|
1943
|
+
get context() {
|
|
1944
|
+
return builderContext$1.context;
|
|
1945
|
+
},
|
|
1946
|
+
customComponents: Object.values(builderContext$1.registeredComponents),
|
|
1947
|
+
data: {
|
|
1948
|
+
...props.symbol?.data,
|
|
1949
|
+
...builderContext$1.state,
|
|
1950
|
+
...props.symbol?.content?.data?.state
|
|
1951
|
+
},
|
|
1952
|
+
model: props.symbol?.model,
|
|
1953
|
+
content: contentToUse(props, state),
|
|
1954
|
+
[_IMMUTABLE]: {
|
|
1955
|
+
apiKey: _wrapSignal(builderContext$1, "apiKey"),
|
|
1956
|
+
context: _wrapSignal(builderContext$1, "context")
|
|
1957
|
+
}
|
|
1958
|
+
}, "Wt_0")
|
|
1959
|
+
});
|
|
1960
|
+
}, "Symbol_component_WVvggdkUPdk"));
|
|
1961
|
+
const componentInfo$4 = {
|
|
1962
|
+
name: "Text",
|
|
1963
|
+
static: true,
|
|
1964
|
+
builtIn: true,
|
|
1965
|
+
image: "https://firebasestorage.googleapis.com/v0/b/builder-3b0a2.appspot.com/o/images%2Fbaseline-text_fields-24px%20(1).svg?alt=media&token=12177b73-0ee3-42ca-98c6-0dd003de1929",
|
|
1966
|
+
inputs: [
|
|
1967
|
+
{
|
|
1968
|
+
name: "text",
|
|
1969
|
+
type: "html",
|
|
1970
|
+
required: true,
|
|
1971
|
+
autoFocus: true,
|
|
1972
|
+
bubble: true,
|
|
1973
|
+
defaultValue: "Enter some text..."
|
|
1974
|
+
}
|
|
1975
|
+
],
|
|
1976
|
+
defaultStyles: {
|
|
1977
|
+
lineHeight: "normal",
|
|
1978
|
+
height: "auto",
|
|
1979
|
+
textAlign: "center"
|
|
1980
|
+
}
|
|
1981
|
+
};
|
|
1982
|
+
const Text = /* @__PURE__ */ componentQrl(inlinedQrl((props) => {
|
|
1983
|
+
return /* @__PURE__ */ jsx("span", {
|
|
1984
|
+
class: "builder-text",
|
|
1892
1985
|
get dangerouslySetInnerHTML() {
|
|
1893
|
-
return props.
|
|
1986
|
+
return props.text;
|
|
1894
1987
|
},
|
|
1895
1988
|
[_IMMUTABLE]: {
|
|
1896
|
-
dangerouslySetInnerHTML: _wrapSignal(props, "
|
|
1989
|
+
dangerouslySetInnerHTML: _wrapSignal(props, "text")
|
|
1897
1990
|
}
|
|
1898
1991
|
});
|
|
1899
|
-
}, "
|
|
1900
|
-
const
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
objectFit: props.backgroundSize || "cover",
|
|
1904
|
-
objectPosition: props.backgroundPosition || "center"
|
|
1905
|
-
},
|
|
1906
|
-
get alt() {
|
|
1907
|
-
return props.altText;
|
|
1908
|
-
},
|
|
1909
|
-
src: props.imgSrc || props.image,
|
|
1910
|
-
...props.attributes,
|
|
1911
|
-
[_IMMUTABLE]: {
|
|
1912
|
-
alt: _wrapSignal(props, "altText")
|
|
1913
|
-
}
|
|
1914
|
-
}, isEditing() && props.imgSrc || "default-key");
|
|
1915
|
-
}, "ImgComponent_component_FXvIDBSffO8"));
|
|
1916
|
-
const componentInfo$1 = {
|
|
1917
|
-
name: "Raw:Img",
|
|
1918
|
-
hideFromInsertMenu: true,
|
|
1992
|
+
}, "Text_component_15p0cKUxgIE"));
|
|
1993
|
+
const componentInfo$3 = {
|
|
1994
|
+
name: "Video",
|
|
1995
|
+
canHaveChildren: true,
|
|
1919
1996
|
builtIn: true,
|
|
1920
|
-
|
|
1997
|
+
defaultStyles: {
|
|
1998
|
+
minHeight: "20px",
|
|
1999
|
+
minWidth: "20px"
|
|
2000
|
+
},
|
|
2001
|
+
image: "https://firebasestorage.googleapis.com/v0/b/builder-3b0a2.appspot.com/o/images%2Fbaseline-videocam-24px%20(1).svg?alt=media&token=49a84e4a-b20e-4977-a650-047f986874bb",
|
|
1921
2002
|
inputs: [
|
|
1922
2003
|
{
|
|
1923
|
-
name: "
|
|
2004
|
+
name: "video",
|
|
2005
|
+
type: "file",
|
|
2006
|
+
allowedFileTypes: [
|
|
2007
|
+
"mp4"
|
|
2008
|
+
],
|
|
1924
2009
|
bubble: true,
|
|
2010
|
+
defaultValue: "https://firebasestorage.googleapis.com/v0/b/builder-3b0a2.appspot.com/o/assets%2FKQlEmWDxA0coC3PK6UvkrjwkIGI2%2F28cb070609f546cdbe5efa20e931aa4b?alt=media&token=912e9551-7a7c-4dfb-86b6-3da1537d1a7f",
|
|
2011
|
+
required: true
|
|
2012
|
+
},
|
|
2013
|
+
{
|
|
2014
|
+
name: "posterImage",
|
|
1925
2015
|
type: "file",
|
|
1926
2016
|
allowedFileTypes: [
|
|
1927
2017
|
"jpeg",
|
|
1928
|
-
"
|
|
1929
|
-
"png",
|
|
1930
|
-
"svg"
|
|
2018
|
+
"png"
|
|
1931
2019
|
],
|
|
1932
|
-
|
|
1933
|
-
}
|
|
1934
|
-
|
|
1935
|
-
|
|
1936
|
-
|
|
1937
|
-
|
|
1938
|
-
const findAndRunScripts = function findAndRunScripts22(props, state, elem) {
|
|
1939
|
-
if (elem && elem.getElementsByTagName && typeof window !== "undefined") {
|
|
1940
|
-
const scripts = elem.getElementsByTagName("script");
|
|
1941
|
-
for (let i = 0; i < scripts.length; i++) {
|
|
1942
|
-
const script = scripts[i];
|
|
1943
|
-
if (script.src) {
|
|
1944
|
-
if (state.scriptsInserted.includes(script.src))
|
|
1945
|
-
continue;
|
|
1946
|
-
state.scriptsInserted.push(script.src);
|
|
1947
|
-
const newScript = document.createElement("script");
|
|
1948
|
-
newScript.async = true;
|
|
1949
|
-
newScript.src = script.src;
|
|
1950
|
-
document.head.appendChild(newScript);
|
|
1951
|
-
} else if (!script.type || [
|
|
1952
|
-
"text/javascript",
|
|
1953
|
-
"application/javascript",
|
|
1954
|
-
"application/ecmascript"
|
|
1955
|
-
].includes(script.type)) {
|
|
1956
|
-
if (state.scriptsRun.includes(script.innerText))
|
|
1957
|
-
continue;
|
|
1958
|
-
try {
|
|
1959
|
-
state.scriptsRun.push(script.innerText);
|
|
1960
|
-
new Function(script.innerText)();
|
|
1961
|
-
} catch (error) {
|
|
1962
|
-
console.warn("`CustomCode`: Error running script:", error);
|
|
1963
|
-
}
|
|
1964
|
-
}
|
|
1965
|
-
}
|
|
1966
|
-
}
|
|
1967
|
-
};
|
|
1968
|
-
const CustomCode = /* @__PURE__ */ componentQrl(inlinedQrl((props) => {
|
|
1969
|
-
const elem = useRef();
|
|
1970
|
-
const state = useStore({
|
|
1971
|
-
scriptsInserted: [],
|
|
1972
|
-
scriptsRun: []
|
|
1973
|
-
});
|
|
1974
|
-
useClientEffectQrl(inlinedQrl(() => {
|
|
1975
|
-
const [elem2, props2, state2] = useLexicalScope();
|
|
1976
|
-
findAndRunScripts(props2, state2, elem2);
|
|
1977
|
-
}, "CustomCode_component_useClientEffect_4w4c951ufB4", [
|
|
1978
|
-
elem,
|
|
1979
|
-
props,
|
|
1980
|
-
state
|
|
1981
|
-
]));
|
|
1982
|
-
return /* @__PURE__ */ jsx("div", {
|
|
1983
|
-
ref: elem,
|
|
1984
|
-
class: "builder-custom-code" + (props.replaceNodes ? " replace-nodes" : ""),
|
|
1985
|
-
get dangerouslySetInnerHTML() {
|
|
1986
|
-
return props.code;
|
|
2020
|
+
helperText: "Image to show before the video plays"
|
|
2021
|
+
},
|
|
2022
|
+
{
|
|
2023
|
+
name: "autoPlay",
|
|
2024
|
+
type: "boolean",
|
|
2025
|
+
defaultValue: true
|
|
1987
2026
|
},
|
|
1988
|
-
[_IMMUTABLE]: {
|
|
1989
|
-
dangerouslySetInnerHTML: _wrapSignal(props, "code")
|
|
1990
|
-
}
|
|
1991
|
-
});
|
|
1992
|
-
}, "CustomCode_component_uYOSy7w7Zqw"));
|
|
1993
|
-
const componentInfo = {
|
|
1994
|
-
name: "Custom Code",
|
|
1995
|
-
static: true,
|
|
1996
|
-
builtIn: true,
|
|
1997
|
-
requiredPermissions: [
|
|
1998
|
-
"editCode"
|
|
1999
|
-
],
|
|
2000
|
-
inputs: [
|
|
2001
2027
|
{
|
|
2002
|
-
name: "
|
|
2003
|
-
type: "
|
|
2004
|
-
|
|
2005
|
-
defaultValue: "<p>Hello there, I am custom HTML code!</p>",
|
|
2006
|
-
code: true
|
|
2028
|
+
name: "controls",
|
|
2029
|
+
type: "boolean",
|
|
2030
|
+
defaultValue: false
|
|
2007
2031
|
},
|
|
2008
2032
|
{
|
|
2009
|
-
name: "
|
|
2033
|
+
name: "muted",
|
|
2010
2034
|
type: "boolean",
|
|
2011
|
-
|
|
2012
|
-
advanced: true
|
|
2035
|
+
defaultValue: true
|
|
2013
2036
|
},
|
|
2014
2037
|
{
|
|
2015
|
-
name: "
|
|
2038
|
+
name: "loop",
|
|
2016
2039
|
type: "boolean",
|
|
2017
|
-
defaultValue:
|
|
2018
|
-
|
|
2040
|
+
defaultValue: true
|
|
2041
|
+
},
|
|
2042
|
+
{
|
|
2043
|
+
name: "playsInline",
|
|
2044
|
+
type: "boolean",
|
|
2045
|
+
defaultValue: true
|
|
2046
|
+
},
|
|
2047
|
+
{
|
|
2048
|
+
name: "fit",
|
|
2049
|
+
type: "text",
|
|
2050
|
+
defaultValue: "cover",
|
|
2051
|
+
enum: [
|
|
2052
|
+
"contain",
|
|
2053
|
+
"cover",
|
|
2054
|
+
"fill",
|
|
2055
|
+
"auto"
|
|
2056
|
+
]
|
|
2057
|
+
},
|
|
2058
|
+
{
|
|
2059
|
+
name: "fitContent",
|
|
2060
|
+
type: "boolean",
|
|
2061
|
+
helperText: "When child blocks are provided, fit to them instead of using the aspect ratio",
|
|
2062
|
+
defaultValue: true,
|
|
2019
2063
|
advanced: true
|
|
2020
|
-
}
|
|
2021
|
-
|
|
2022
|
-
|
|
2023
|
-
|
|
2024
|
-
|
|
2025
|
-
|
|
2026
|
-
|
|
2027
|
-
|
|
2028
|
-
|
|
2029
|
-
|
|
2030
|
-
|
|
2031
|
-
|
|
2032
|
-
|
|
2033
|
-
|
|
2034
|
-
|
|
2035
|
-
|
|
2036
|
-
|
|
2037
|
-
|
|
2038
|
-
|
|
2039
|
-
|
|
2040
|
-
|
|
2041
|
-
|
|
2042
|
-
|
|
2043
|
-
|
|
2044
|
-
|
|
2045
|
-
|
|
2046
|
-
|
|
2047
|
-
|
|
2048
|
-
|
|
2049
|
-
|
|
2050
|
-
|
|
2051
|
-
|
|
2052
|
-
|
|
2053
|
-
|
|
2054
|
-
|
|
2055
|
-
|
|
2056
|
-
|
|
2057
|
-
|
|
2058
|
-
|
|
2059
|
-
|
|
2060
|
-
|
|
2061
|
-
component: Embed,
|
|
2062
|
-
...componentInfo$2
|
|
2063
|
-
},
|
|
2064
|
-
{
|
|
2065
|
-
component: CustomCode,
|
|
2066
|
-
...componentInfo
|
|
2067
|
-
}
|
|
2068
|
-
];
|
|
2069
|
-
function getGlobalThis() {
|
|
2070
|
-
if (typeof globalThis !== "undefined")
|
|
2071
|
-
return globalThis;
|
|
2072
|
-
if (typeof window !== "undefined")
|
|
2073
|
-
return window;
|
|
2074
|
-
if (typeof global !== "undefined")
|
|
2075
|
-
return global;
|
|
2076
|
-
if (typeof self !== "undefined")
|
|
2077
|
-
return self;
|
|
2078
|
-
return globalThis;
|
|
2079
|
-
}
|
|
2080
|
-
function getFetch() {
|
|
2081
|
-
const globalFetch = getGlobalThis().fetch;
|
|
2082
|
-
if (typeof globalFetch === "undefined") {
|
|
2083
|
-
console.warn(`Builder SDK could not find a global fetch function. Make sure you have a polyfill for fetch in your project.
|
|
2084
|
-
For more information, read https://github.com/BuilderIO/this-package-uses-fetch`);
|
|
2085
|
-
throw new Error("Builder SDK could not find a global `fetch` function");
|
|
2086
|
-
}
|
|
2087
|
-
return globalFetch;
|
|
2088
|
-
}
|
|
2089
|
-
const fetch$1 = getFetch();
|
|
2090
|
-
const getTopLevelDomain = (host) => {
|
|
2091
|
-
if (host === "localhost" || host === "127.0.0.1")
|
|
2092
|
-
return host;
|
|
2093
|
-
const parts = host.split(".");
|
|
2094
|
-
if (parts.length > 2)
|
|
2095
|
-
return parts.slice(1).join(".");
|
|
2096
|
-
return host;
|
|
2097
|
-
};
|
|
2098
|
-
const getCookie = async ({ name, canTrack }) => {
|
|
2099
|
-
try {
|
|
2100
|
-
if (!canTrack)
|
|
2101
|
-
return void 0;
|
|
2102
|
-
return document.cookie.split("; ").find((row) => row.startsWith(`${name}=`))?.split("=")[1];
|
|
2103
|
-
} catch (err) {
|
|
2104
|
-
console.debug("[COOKIE] GET error: ", err);
|
|
2105
|
-
return void 0;
|
|
2106
|
-
}
|
|
2107
|
-
};
|
|
2108
|
-
const stringifyCookie = (cookie) => cookie.map(([key, value]) => value ? `${key}=${value}` : key).filter(checkIsDefined).join("; ");
|
|
2109
|
-
const SECURE_CONFIG = [
|
|
2110
|
-
[
|
|
2111
|
-
"secure",
|
|
2112
|
-
""
|
|
2113
|
-
],
|
|
2114
|
-
[
|
|
2115
|
-
"SameSite",
|
|
2116
|
-
"None"
|
|
2117
|
-
]
|
|
2118
|
-
];
|
|
2119
|
-
const createCookieString = ({ name, value, expires }) => {
|
|
2120
|
-
const secure = isBrowser() ? location.protocol === "https:" : true;
|
|
2121
|
-
const secureObj = secure ? SECURE_CONFIG : [
|
|
2122
|
-
[]
|
|
2123
|
-
];
|
|
2124
|
-
const expiresObj = expires ? [
|
|
2125
|
-
[
|
|
2126
|
-
"expires",
|
|
2127
|
-
expires.toUTCString()
|
|
2128
|
-
]
|
|
2129
|
-
] : [
|
|
2130
|
-
[]
|
|
2131
|
-
];
|
|
2132
|
-
const cookieValue = [
|
|
2133
|
-
[
|
|
2134
|
-
name,
|
|
2135
|
-
value
|
|
2136
|
-
],
|
|
2137
|
-
...expiresObj,
|
|
2138
|
-
[
|
|
2139
|
-
"path",
|
|
2140
|
-
"/"
|
|
2141
|
-
],
|
|
2142
|
-
[
|
|
2143
|
-
"domain",
|
|
2144
|
-
getTopLevelDomain(window.location.hostname)
|
|
2145
|
-
],
|
|
2146
|
-
...secureObj
|
|
2147
|
-
];
|
|
2148
|
-
const cookie = stringifyCookie(cookieValue);
|
|
2149
|
-
return cookie;
|
|
2150
|
-
};
|
|
2151
|
-
const setCookie = async ({ name, value, expires, canTrack }) => {
|
|
2152
|
-
try {
|
|
2153
|
-
if (!canTrack)
|
|
2154
|
-
return;
|
|
2155
|
-
const cookie = createCookieString({
|
|
2156
|
-
name,
|
|
2157
|
-
value,
|
|
2158
|
-
expires
|
|
2159
|
-
});
|
|
2160
|
-
document.cookie = cookie;
|
|
2161
|
-
} catch (err) {
|
|
2162
|
-
console.warn("[COOKIE] SET error: ", err);
|
|
2163
|
-
}
|
|
2164
|
-
};
|
|
2165
|
-
const BUILDER_STORE_PREFIX = "builderio.variations";
|
|
2166
|
-
const getContentTestKey = (id) => `${BUILDER_STORE_PREFIX}.${id}`;
|
|
2167
|
-
const getContentVariationCookie = ({ contentId, canTrack }) => getCookie({
|
|
2168
|
-
name: getContentTestKey(contentId),
|
|
2169
|
-
canTrack
|
|
2170
|
-
});
|
|
2171
|
-
const setContentVariationCookie = ({ contentId, canTrack, value }) => setCookie({
|
|
2172
|
-
name: getContentTestKey(contentId),
|
|
2173
|
-
value,
|
|
2174
|
-
canTrack
|
|
2175
|
-
});
|
|
2176
|
-
const checkIsBuilderContentWithVariations = (item) => checkIsDefined(item.id) && checkIsDefined(item.variations) && Object.keys(item.variations).length > 0;
|
|
2177
|
-
const getRandomVariationId = ({ id, variations }) => {
|
|
2178
|
-
let n = 0;
|
|
2179
|
-
const random = Math.random();
|
|
2180
|
-
for (const id1 in variations) {
|
|
2181
|
-
const testRatio = variations[id1]?.testRatio;
|
|
2182
|
-
n += testRatio;
|
|
2183
|
-
if (random < n)
|
|
2184
|
-
return id1;
|
|
2185
|
-
}
|
|
2186
|
-
return id;
|
|
2064
|
+
},
|
|
2065
|
+
{
|
|
2066
|
+
name: "position",
|
|
2067
|
+
type: "text",
|
|
2068
|
+
defaultValue: "center",
|
|
2069
|
+
enum: [
|
|
2070
|
+
"center",
|
|
2071
|
+
"top",
|
|
2072
|
+
"left",
|
|
2073
|
+
"right",
|
|
2074
|
+
"bottom",
|
|
2075
|
+
"top left",
|
|
2076
|
+
"top right",
|
|
2077
|
+
"bottom left",
|
|
2078
|
+
"bottom right"
|
|
2079
|
+
]
|
|
2080
|
+
},
|
|
2081
|
+
{
|
|
2082
|
+
name: "height",
|
|
2083
|
+
type: "number",
|
|
2084
|
+
advanced: true
|
|
2085
|
+
},
|
|
2086
|
+
{
|
|
2087
|
+
name: "width",
|
|
2088
|
+
type: "number",
|
|
2089
|
+
advanced: true
|
|
2090
|
+
},
|
|
2091
|
+
{
|
|
2092
|
+
name: "aspectRatio",
|
|
2093
|
+
type: "number",
|
|
2094
|
+
advanced: true,
|
|
2095
|
+
defaultValue: 0.7004048582995948
|
|
2096
|
+
},
|
|
2097
|
+
{
|
|
2098
|
+
name: "lazyLoad",
|
|
2099
|
+
type: "boolean",
|
|
2100
|
+
helperText: 'Load this video "lazily" - as in only when a user scrolls near the video. Recommended for optmized performance and bandwidth consumption',
|
|
2101
|
+
defaultValue: true,
|
|
2102
|
+
advanced: true
|
|
2103
|
+
}
|
|
2104
|
+
]
|
|
2187
2105
|
};
|
|
2188
|
-
const
|
|
2189
|
-
|
|
2190
|
-
|
|
2191
|
-
|
|
2192
|
-
|
|
2193
|
-
|
|
2194
|
-
|
|
2195
|
-
|
|
2196
|
-
|
|
2197
|
-
|
|
2198
|
-
|
|
2199
|
-
|
|
2200
|
-
|
|
2106
|
+
const videoProps = function videoProps2(props, state) {
|
|
2107
|
+
return {
|
|
2108
|
+
...props.autoPlay === true ? {
|
|
2109
|
+
autoPlay: true
|
|
2110
|
+
} : {},
|
|
2111
|
+
...props.muted === true ? {
|
|
2112
|
+
muted: true
|
|
2113
|
+
} : {},
|
|
2114
|
+
...props.controls === true ? {
|
|
2115
|
+
controls: true
|
|
2116
|
+
} : {},
|
|
2117
|
+
...props.loop === true ? {
|
|
2118
|
+
loop: true
|
|
2119
|
+
} : {},
|
|
2120
|
+
...props.playsInline === true ? {
|
|
2121
|
+
playsInline: true
|
|
2122
|
+
} : {}
|
|
2123
|
+
};
|
|
2201
2124
|
};
|
|
2202
|
-
const
|
|
2203
|
-
|
|
2204
|
-
|
|
2205
|
-
|
|
2125
|
+
const spreadProps = function spreadProps2(props, state) {
|
|
2126
|
+
return {
|
|
2127
|
+
...props.attributes,
|
|
2128
|
+
...videoProps(props)
|
|
2129
|
+
};
|
|
2130
|
+
};
|
|
2131
|
+
const Video = /* @__PURE__ */ componentQrl(inlinedQrl((props) => {
|
|
2132
|
+
return /* @__PURE__ */ jsx("video", {
|
|
2133
|
+
...spreadProps(props),
|
|
2134
|
+
style: {
|
|
2135
|
+
width: "100%",
|
|
2136
|
+
height: "100%",
|
|
2137
|
+
...props.attributes?.style,
|
|
2138
|
+
objectFit: props.fit,
|
|
2139
|
+
objectPosition: props.position,
|
|
2140
|
+
borderRadius: 1
|
|
2141
|
+
},
|
|
2142
|
+
src: props.video || "no-src",
|
|
2143
|
+
get poster() {
|
|
2144
|
+
return props.posterImage;
|
|
2145
|
+
},
|
|
2146
|
+
[_IMMUTABLE]: {
|
|
2147
|
+
poster: _wrapSignal(props, "posterImage")
|
|
2148
|
+
}
|
|
2206
2149
|
});
|
|
2207
|
-
|
|
2208
|
-
|
|
2209
|
-
|
|
2210
|
-
|
|
2211
|
-
|
|
2212
|
-
|
|
2213
|
-
|
|
2214
|
-
|
|
2215
|
-
|
|
2216
|
-
|
|
2217
|
-
|
|
2218
|
-
|
|
2219
|
-
|
|
2220
|
-
|
|
2221
|
-
|
|
2222
|
-
|
|
2223
|
-
|
|
2224
|
-
|
|
2225
|
-
|
|
2226
|
-
|
|
2227
|
-
|
|
2228
|
-
|
|
2229
|
-
|
|
2150
|
+
}, "Video_component_qdcTZflYyoQ"));
|
|
2151
|
+
const componentInfo$2 = {
|
|
2152
|
+
name: "Embed",
|
|
2153
|
+
static: true,
|
|
2154
|
+
builtIn: true,
|
|
2155
|
+
inputs: [
|
|
2156
|
+
{
|
|
2157
|
+
name: "url",
|
|
2158
|
+
type: "url",
|
|
2159
|
+
required: true,
|
|
2160
|
+
defaultValue: "",
|
|
2161
|
+
helperText: "e.g. enter a youtube url, google map, etc",
|
|
2162
|
+
onChange: serializeFn((options) => {
|
|
2163
|
+
const url = options.get("url");
|
|
2164
|
+
if (url) {
|
|
2165
|
+
options.set("content", "Loading...");
|
|
2166
|
+
const apiKey = "ae0e60e78201a3f2b0de4b";
|
|
2167
|
+
return fetch(`https://iframe.ly/api/iframely?url=${url}&api_key=${apiKey}`).then((res) => res.json()).then((data) => {
|
|
2168
|
+
if (options.get("url") === url) {
|
|
2169
|
+
if (data.html)
|
|
2170
|
+
options.set("content", data.html);
|
|
2171
|
+
else
|
|
2172
|
+
options.set("content", "Invalid url, please try another");
|
|
2173
|
+
}
|
|
2174
|
+
}).catch((_err) => {
|
|
2175
|
+
options.set("content", "There was an error embedding this URL, please try again or another URL");
|
|
2176
|
+
});
|
|
2177
|
+
} else
|
|
2178
|
+
options.delete("content");
|
|
2179
|
+
})
|
|
2180
|
+
},
|
|
2181
|
+
{
|
|
2182
|
+
name: "content",
|
|
2183
|
+
type: "html",
|
|
2184
|
+
defaultValue: '<div style="padding: 20px; text-align: center">(Choose an embed URL)<div>',
|
|
2185
|
+
hideFromUI: true
|
|
2186
|
+
}
|
|
2187
|
+
]
|
|
2230
2188
|
};
|
|
2231
|
-
const
|
|
2232
|
-
|
|
2189
|
+
const SCRIPT_MIME_TYPES = [
|
|
2190
|
+
"text/javascript",
|
|
2191
|
+
"application/javascript",
|
|
2192
|
+
"application/ecmascript"
|
|
2193
|
+
];
|
|
2194
|
+
const isJsScript = (script) => SCRIPT_MIME_TYPES.includes(script.type);
|
|
2195
|
+
const findAndRunScripts$1 = function findAndRunScripts2(props, state, elem) {
|
|
2196
|
+
if (!elem || !elem.getElementsByTagName)
|
|
2233
2197
|
return;
|
|
2234
|
-
const
|
|
2235
|
-
|
|
2236
|
-
|
|
2237
|
-
|
|
2238
|
-
|
|
2198
|
+
const scripts = elem.getElementsByTagName("script");
|
|
2199
|
+
for (let i = 0; i < scripts.length; i++) {
|
|
2200
|
+
const script = scripts[i];
|
|
2201
|
+
if (script.src && !state.scriptsInserted.includes(script.src)) {
|
|
2202
|
+
state.scriptsInserted.push(script.src);
|
|
2203
|
+
const newScript = document.createElement("script");
|
|
2204
|
+
newScript.async = true;
|
|
2205
|
+
newScript.src = script.src;
|
|
2206
|
+
document.head.appendChild(newScript);
|
|
2207
|
+
} else if (isJsScript(script) && !state.scriptsRun.includes(script.innerText))
|
|
2208
|
+
try {
|
|
2209
|
+
state.scriptsRun.push(script.innerText);
|
|
2210
|
+
new Function(script.innerText)();
|
|
2211
|
+
} catch (error) {
|
|
2212
|
+
console.warn("`Embed`: Error running script:", error);
|
|
2213
|
+
}
|
|
2214
|
+
}
|
|
2239
2215
|
};
|
|
2240
|
-
|
|
2241
|
-
|
|
2242
|
-
|
|
2243
|
-
|
|
2244
|
-
|
|
2245
|
-
|
|
2246
|
-
].filter(Boolean).join(separator);
|
|
2247
|
-
const isObject = [
|
|
2248
|
-
typeof value === "object",
|
|
2249
|
-
value !== null,
|
|
2250
|
-
!(Array.isArray(value) && value.length === 0)
|
|
2251
|
-
].every(Boolean);
|
|
2252
|
-
return isObject ? {
|
|
2253
|
-
...acc,
|
|
2254
|
-
...flatten(value, newPath, separator)
|
|
2255
|
-
} : {
|
|
2256
|
-
...acc,
|
|
2257
|
-
[newPath]: value
|
|
2258
|
-
};
|
|
2259
|
-
}, {});
|
|
2260
|
-
}
|
|
2261
|
-
const BUILDER_SEARCHPARAMS_PREFIX = "builder.";
|
|
2262
|
-
const BUILDER_OPTIONS_PREFIX = "options.";
|
|
2263
|
-
const convertSearchParamsToQueryObject = (searchParams) => {
|
|
2264
|
-
const options = {};
|
|
2265
|
-
searchParams.forEach((value, key) => {
|
|
2266
|
-
options[key] = value;
|
|
2216
|
+
const Embed = /* @__PURE__ */ componentQrl(inlinedQrl((props) => {
|
|
2217
|
+
const elem = useRef();
|
|
2218
|
+
const state = useStore({
|
|
2219
|
+
ranInitFn: false,
|
|
2220
|
+
scriptsInserted: [],
|
|
2221
|
+
scriptsRun: []
|
|
2267
2222
|
});
|
|
2268
|
-
|
|
2223
|
+
useTaskQrl(inlinedQrl(({ track: track2 }) => {
|
|
2224
|
+
const [elem2, props2, state2] = useLexicalScope();
|
|
2225
|
+
track2(() => elem2);
|
|
2226
|
+
track2(() => state2.ranInitFn);
|
|
2227
|
+
if (elem2 && !state2.ranInitFn) {
|
|
2228
|
+
state2.ranInitFn = true;
|
|
2229
|
+
findAndRunScripts$1(props2, state2, elem2);
|
|
2230
|
+
}
|
|
2231
|
+
}, "Embed_component_useTask_bg7ez0XUtiM", [
|
|
2232
|
+
elem,
|
|
2233
|
+
props,
|
|
2234
|
+
state
|
|
2235
|
+
]));
|
|
2236
|
+
return /* @__PURE__ */ jsx("div", {
|
|
2237
|
+
class: "builder-embed",
|
|
2238
|
+
ref: elem,
|
|
2239
|
+
get dangerouslySetInnerHTML() {
|
|
2240
|
+
return props.content;
|
|
2241
|
+
},
|
|
2242
|
+
[_IMMUTABLE]: {
|
|
2243
|
+
dangerouslySetInnerHTML: _wrapSignal(props, "content")
|
|
2244
|
+
}
|
|
2245
|
+
});
|
|
2246
|
+
}, "Embed_component_Uji08ORjXbE"));
|
|
2247
|
+
const ImgComponent = /* @__PURE__ */ componentQrl(inlinedQrl((props) => {
|
|
2248
|
+
return /* @__PURE__ */ jsx("img", {
|
|
2249
|
+
style: {
|
|
2250
|
+
objectFit: props.backgroundSize || "cover",
|
|
2251
|
+
objectPosition: props.backgroundPosition || "center"
|
|
2252
|
+
},
|
|
2253
|
+
get alt() {
|
|
2254
|
+
return props.altText;
|
|
2255
|
+
},
|
|
2256
|
+
src: props.imgSrc || props.image,
|
|
2257
|
+
...props.attributes,
|
|
2258
|
+
[_IMMUTABLE]: {
|
|
2259
|
+
alt: _wrapSignal(props, "altText")
|
|
2260
|
+
}
|
|
2261
|
+
}, isEditing() && props.imgSrc || "default-key");
|
|
2262
|
+
}, "ImgComponent_component_FXvIDBSffO8"));
|
|
2263
|
+
const componentInfo$1 = {
|
|
2264
|
+
name: "Raw:Img",
|
|
2265
|
+
hideFromInsertMenu: true,
|
|
2266
|
+
builtIn: true,
|
|
2267
|
+
image: "https://firebasestorage.googleapis.com/v0/b/builder-3b0a2.appspot.com/o/images%2Fbaseline-insert_photo-24px.svg?alt=media&token=4e5d0ef4-f5e8-4e57-b3a9-38d63a9b9dc4",
|
|
2268
|
+
inputs: [
|
|
2269
|
+
{
|
|
2270
|
+
name: "image",
|
|
2271
|
+
bubble: true,
|
|
2272
|
+
type: "file",
|
|
2273
|
+
allowedFileTypes: [
|
|
2274
|
+
"jpeg",
|
|
2275
|
+
"jpg",
|
|
2276
|
+
"png",
|
|
2277
|
+
"svg"
|
|
2278
|
+
],
|
|
2279
|
+
required: true
|
|
2280
|
+
}
|
|
2281
|
+
],
|
|
2282
|
+
noWrap: true,
|
|
2283
|
+
static: true
|
|
2284
|
+
};
|
|
2285
|
+
const findAndRunScripts = function findAndRunScripts22(props, state, elem) {
|
|
2286
|
+
if (elem && elem.getElementsByTagName && typeof window !== "undefined") {
|
|
2287
|
+
const scripts = elem.getElementsByTagName("script");
|
|
2288
|
+
for (let i = 0; i < scripts.length; i++) {
|
|
2289
|
+
const script = scripts[i];
|
|
2290
|
+
if (script.src) {
|
|
2291
|
+
if (state.scriptsInserted.includes(script.src))
|
|
2292
|
+
continue;
|
|
2293
|
+
state.scriptsInserted.push(script.src);
|
|
2294
|
+
const newScript = document.createElement("script");
|
|
2295
|
+
newScript.async = true;
|
|
2296
|
+
newScript.src = script.src;
|
|
2297
|
+
document.head.appendChild(newScript);
|
|
2298
|
+
} else if (!script.type || [
|
|
2299
|
+
"text/javascript",
|
|
2300
|
+
"application/javascript",
|
|
2301
|
+
"application/ecmascript"
|
|
2302
|
+
].includes(script.type)) {
|
|
2303
|
+
if (state.scriptsRun.includes(script.innerText))
|
|
2304
|
+
continue;
|
|
2305
|
+
try {
|
|
2306
|
+
state.scriptsRun.push(script.innerText);
|
|
2307
|
+
new Function(script.innerText)();
|
|
2308
|
+
} catch (error) {
|
|
2309
|
+
console.warn("`CustomCode`: Error running script:", error);
|
|
2310
|
+
}
|
|
2311
|
+
}
|
|
2312
|
+
}
|
|
2313
|
+
}
|
|
2269
2314
|
};
|
|
2270
|
-
const
|
|
2271
|
-
|
|
2272
|
-
|
|
2273
|
-
|
|
2274
|
-
|
|
2275
|
-
|
|
2276
|
-
|
|
2277
|
-
|
|
2278
|
-
|
|
2315
|
+
const CustomCode = /* @__PURE__ */ componentQrl(inlinedQrl((props) => {
|
|
2316
|
+
const elem = useRef();
|
|
2317
|
+
const state = useStore({
|
|
2318
|
+
scriptsInserted: [],
|
|
2319
|
+
scriptsRun: []
|
|
2320
|
+
});
|
|
2321
|
+
useClientEffectQrl(inlinedQrl(() => {
|
|
2322
|
+
const [elem2, props2, state2] = useLexicalScope();
|
|
2323
|
+
findAndRunScripts(props2, state2, elem2);
|
|
2324
|
+
}, "CustomCode_component_useClientEffect_4w4c951ufB4", [
|
|
2325
|
+
elem,
|
|
2326
|
+
props,
|
|
2327
|
+
state
|
|
2328
|
+
]));
|
|
2329
|
+
return /* @__PURE__ */ jsx("div", {
|
|
2330
|
+
ref: elem,
|
|
2331
|
+
class: "builder-custom-code" + (props.replaceNodes ? " replace-nodes" : ""),
|
|
2332
|
+
get dangerouslySetInnerHTML() {
|
|
2333
|
+
return props.code;
|
|
2334
|
+
},
|
|
2335
|
+
[_IMMUTABLE]: {
|
|
2336
|
+
dangerouslySetInnerHTML: _wrapSignal(props, "code")
|
|
2279
2337
|
}
|
|
2280
2338
|
});
|
|
2281
|
-
|
|
2282
|
-
|
|
2283
|
-
|
|
2284
|
-
|
|
2285
|
-
|
|
2286
|
-
|
|
2287
|
-
|
|
2339
|
+
}, "CustomCode_component_uYOSy7w7Zqw"));
|
|
2340
|
+
const componentInfo = {
|
|
2341
|
+
name: "Custom Code",
|
|
2342
|
+
static: true,
|
|
2343
|
+
builtIn: true,
|
|
2344
|
+
requiredPermissions: [
|
|
2345
|
+
"editCode"
|
|
2346
|
+
],
|
|
2347
|
+
inputs: [
|
|
2348
|
+
{
|
|
2349
|
+
name: "code",
|
|
2350
|
+
type: "html",
|
|
2351
|
+
required: true,
|
|
2352
|
+
defaultValue: "<p>Hello there, I am custom HTML code!</p>",
|
|
2353
|
+
code: true
|
|
2354
|
+
},
|
|
2355
|
+
{
|
|
2356
|
+
name: "replaceNodes",
|
|
2357
|
+
type: "boolean",
|
|
2358
|
+
helperText: "Preserve server rendered dom nodes",
|
|
2359
|
+
advanced: true
|
|
2360
|
+
},
|
|
2361
|
+
{
|
|
2362
|
+
name: "scriptsClientOnly",
|
|
2363
|
+
type: "boolean",
|
|
2364
|
+
defaultValue: false,
|
|
2365
|
+
helperText: "Only print and run scripts on the client. Important when scripts influence DOM that could be replaced when client loads",
|
|
2366
|
+
advanced: true
|
|
2367
|
+
}
|
|
2368
|
+
]
|
|
2288
2369
|
};
|
|
2289
|
-
const
|
|
2290
|
-
|
|
2291
|
-
|
|
2292
|
-
|
|
2293
|
-
|
|
2294
|
-
|
|
2295
|
-
|
|
2296
|
-
...
|
|
2297
|
-
|
|
2298
|
-
|
|
2299
|
-
|
|
2300
|
-
|
|
2301
|
-
|
|
2302
|
-
|
|
2303
|
-
|
|
2304
|
-
|
|
2305
|
-
|
|
2306
|
-
|
|
2307
|
-
|
|
2308
|
-
|
|
2309
|
-
|
|
2370
|
+
const getDefaultRegisteredComponents = () => [
|
|
2371
|
+
{
|
|
2372
|
+
component: Button,
|
|
2373
|
+
...componentInfo$a
|
|
2374
|
+
},
|
|
2375
|
+
{
|
|
2376
|
+
component: Columns,
|
|
2377
|
+
...componentInfo$9
|
|
2378
|
+
},
|
|
2379
|
+
{
|
|
2380
|
+
component: CustomCode,
|
|
2381
|
+
...componentInfo
|
|
2382
|
+
},
|
|
2383
|
+
{
|
|
2384
|
+
component: Embed,
|
|
2385
|
+
...componentInfo$2
|
|
2386
|
+
},
|
|
2387
|
+
{
|
|
2388
|
+
component: FragmentComponent,
|
|
2389
|
+
...componentInfo$8
|
|
2390
|
+
},
|
|
2391
|
+
{
|
|
2392
|
+
component: Image,
|
|
2393
|
+
...componentInfo$7
|
|
2394
|
+
},
|
|
2395
|
+
{
|
|
2396
|
+
component: ImgComponent,
|
|
2397
|
+
...componentInfo$1
|
|
2398
|
+
},
|
|
2399
|
+
{
|
|
2400
|
+
component: SectionComponent,
|
|
2401
|
+
...componentInfo$6
|
|
2402
|
+
},
|
|
2403
|
+
{
|
|
2404
|
+
component: Symbol$1,
|
|
2405
|
+
...componentInfo$5
|
|
2406
|
+
},
|
|
2407
|
+
{
|
|
2408
|
+
component: Text,
|
|
2409
|
+
...componentInfo$4
|
|
2410
|
+
},
|
|
2411
|
+
{
|
|
2412
|
+
component: Video,
|
|
2413
|
+
...componentInfo$3
|
|
2310
2414
|
}
|
|
2311
|
-
|
|
2312
|
-
};
|
|
2313
|
-
async function getContent(options) {
|
|
2314
|
-
return (await getAllContent({
|
|
2315
|
-
...options,
|
|
2316
|
-
limit: 1
|
|
2317
|
-
})).results[0] || null;
|
|
2318
|
-
}
|
|
2319
|
-
async function getAllContent(options) {
|
|
2320
|
-
const url = generateContentUrl(options);
|
|
2321
|
-
const res = await fetch$1(url.href);
|
|
2322
|
-
const content = await res.json();
|
|
2323
|
-
const canTrack = options.canTrack !== false;
|
|
2324
|
-
if (canTrack && Array.isArray(content.results))
|
|
2325
|
-
for (const item of content.results)
|
|
2326
|
-
await handleABTesting({
|
|
2327
|
-
item,
|
|
2328
|
-
canTrack
|
|
2329
|
-
});
|
|
2330
|
-
return content;
|
|
2331
|
-
}
|
|
2415
|
+
];
|
|
2332
2416
|
function isPreviewing() {
|
|
2333
2417
|
if (!isBrowser())
|
|
2334
2418
|
return false;
|
|
@@ -2589,20 +2673,20 @@ const getInteractionPropertiesForEvent = (event) => {
|
|
|
2589
2673
|
}
|
|
2590
2674
|
};
|
|
2591
2675
|
};
|
|
2592
|
-
const getCssFromFont =
|
|
2676
|
+
const getCssFromFont = (font) => {
|
|
2593
2677
|
const family = font.family + (font.kind && !font.kind.includes("#") ? ", " + font.kind : "");
|
|
2594
2678
|
const name = family.split(",")[0];
|
|
2595
2679
|
const url = font.fileUrl ?? font?.files?.regular;
|
|
2596
2680
|
let str = "";
|
|
2597
2681
|
if (url && family && name)
|
|
2598
2682
|
str += `
|
|
2599
|
-
|
|
2600
|
-
|
|
2601
|
-
|
|
2602
|
-
|
|
2603
|
-
|
|
2604
|
-
|
|
2605
|
-
|
|
2683
|
+
@font-face {
|
|
2684
|
+
font-family: "${family}";
|
|
2685
|
+
src: local("${name}"), url('${url}') format('woff2');
|
|
2686
|
+
font-display: fallback;
|
|
2687
|
+
font-weight: 400;
|
|
2688
|
+
}
|
|
2689
|
+
`.trim();
|
|
2606
2690
|
if (font.files)
|
|
2607
2691
|
for (const weight in font.files) {
|
|
2608
2692
|
const isNumber = String(Number(weight)) === weight;
|
|
@@ -2611,60 +2695,102 @@ const getCssFromFont = function getCssFromFont2(props, state, font) {
|
|
|
2611
2695
|
const weightUrl = font.files[weight];
|
|
2612
2696
|
if (weightUrl && weightUrl !== url)
|
|
2613
2697
|
str += `
|
|
2614
|
-
|
|
2615
|
-
|
|
2616
|
-
|
|
2617
|
-
|
|
2618
|
-
|
|
2619
|
-
|
|
2620
|
-
|
|
2698
|
+
@font-face {
|
|
2699
|
+
font-family: "${family}";
|
|
2700
|
+
src: url('${weightUrl}') format('woff2');
|
|
2701
|
+
font-display: fallback;
|
|
2702
|
+
font-weight: ${weight};
|
|
2703
|
+
}
|
|
2704
|
+
`.trim();
|
|
2621
2705
|
}
|
|
2622
2706
|
return str;
|
|
2623
2707
|
};
|
|
2624
|
-
const getFontCss =
|
|
2625
|
-
return customFonts?.map((font) => getCssFromFont(
|
|
2708
|
+
const getFontCss = ({ customFonts }) => {
|
|
2709
|
+
return customFonts?.map((font) => getCssFromFont(font))?.join(" ") || "";
|
|
2626
2710
|
};
|
|
2627
|
-
const
|
|
2628
|
-
|
|
2629
|
-
|
|
2630
|
-
|
|
2631
|
-
|
|
2632
|
-
})
|
|
2711
|
+
const getCss = ({ cssCode, contentId }) => {
|
|
2712
|
+
if (!cssCode)
|
|
2713
|
+
return "";
|
|
2714
|
+
if (!contentId)
|
|
2715
|
+
return cssCode;
|
|
2716
|
+
return cssCode?.replace(/&/g, `div[builder-content-id="${contentId}"]`) || "";
|
|
2633
2717
|
};
|
|
2634
2718
|
const RenderContentStyles = /* @__PURE__ */ componentQrl(inlinedQrl((props) => {
|
|
2635
|
-
const state = {
|
|
2719
|
+
const state = useStore({
|
|
2720
|
+
injectedStyles: `
|
|
2721
|
+
${getCss({
|
|
2722
|
+
cssCode: props.cssCode,
|
|
2723
|
+
contentId: props.contentId
|
|
2724
|
+
})}
|
|
2725
|
+
${getFontCss({
|
|
2726
|
+
customFonts: props.customFonts
|
|
2727
|
+
})}
|
|
2728
|
+
`
|
|
2729
|
+
});
|
|
2636
2730
|
return /* @__PURE__ */ jsx(RenderInlinedStyles, {
|
|
2637
|
-
styles
|
|
2731
|
+
get styles() {
|
|
2732
|
+
return state.injectedStyles;
|
|
2733
|
+
},
|
|
2734
|
+
[_IMMUTABLE]: {
|
|
2735
|
+
styles: _wrapSignal(state, "injectedStyles")
|
|
2736
|
+
}
|
|
2638
2737
|
}, "V0_0");
|
|
2639
2738
|
}, "RenderContentStyles_component_Og0xL34Zbvc"));
|
|
2640
|
-
const
|
|
2641
|
-
|
|
2642
|
-
|
|
2739
|
+
const getContextStateInitialValue = ({ content, data, locale }) => {
|
|
2740
|
+
const defaultValues = {};
|
|
2741
|
+
content?.data?.inputs?.forEach((input) => {
|
|
2742
|
+
if (input.name && input.defaultValue !== void 0 && content?.data?.state && content.data.state[input.name] === void 0)
|
|
2743
|
+
defaultValues[input.name] = input.defaultValue;
|
|
2744
|
+
});
|
|
2745
|
+
const stateToUse = {
|
|
2746
|
+
...content?.data?.state,
|
|
2747
|
+
...data,
|
|
2748
|
+
...locale ? {
|
|
2749
|
+
locale
|
|
2750
|
+
} : {}
|
|
2751
|
+
};
|
|
2643
2752
|
return {
|
|
2644
|
-
...
|
|
2645
|
-
...
|
|
2753
|
+
...defaultValues,
|
|
2754
|
+
...stateToUse
|
|
2755
|
+
};
|
|
2756
|
+
};
|
|
2757
|
+
const getContentInitialValue = ({ content, data }) => {
|
|
2758
|
+
return !content ? void 0 : {
|
|
2759
|
+
...content,
|
|
2760
|
+
data: {
|
|
2761
|
+
...content?.data,
|
|
2762
|
+
...data
|
|
2763
|
+
},
|
|
2764
|
+
meta: content?.meta
|
|
2765
|
+
};
|
|
2766
|
+
};
|
|
2767
|
+
const mergeNewContent = function mergeNewContent2(props, state, elementRef, newContent) {
|
|
2768
|
+
state.useContent = {
|
|
2769
|
+
...state.useContent,
|
|
2770
|
+
...newContent,
|
|
2646
2771
|
data: {
|
|
2647
|
-
...
|
|
2648
|
-
...
|
|
2649
|
-
...state.overrideContent?.data
|
|
2772
|
+
...state.useContent?.data,
|
|
2773
|
+
...newContent?.data
|
|
2650
2774
|
},
|
|
2651
2775
|
meta: {
|
|
2652
|
-
...
|
|
2653
|
-
...
|
|
2654
|
-
breakpoints:
|
|
2776
|
+
...state.useContent?.meta,
|
|
2777
|
+
...newContent?.meta,
|
|
2778
|
+
breakpoints: newContent?.meta?.breakpoints || state.useContent?.meta?.breakpoints
|
|
2655
2779
|
}
|
|
2656
2780
|
};
|
|
2657
2781
|
};
|
|
2658
|
-
const
|
|
2659
|
-
|
|
2660
|
-
...
|
|
2661
|
-
|
|
2662
|
-
|
|
2663
|
-
|
|
2664
|
-
}
|
|
2665
|
-
...state.overrideState
|
|
2782
|
+
const setBreakpoints = function setBreakpoints2(props, state, elementRef, breakpoints) {
|
|
2783
|
+
state.useContent = {
|
|
2784
|
+
...state.useContent,
|
|
2785
|
+
meta: {
|
|
2786
|
+
...state.useContent?.meta,
|
|
2787
|
+
breakpoints
|
|
2788
|
+
}
|
|
2666
2789
|
};
|
|
2667
2790
|
};
|
|
2791
|
+
const setContextState = function setContextState2(props, state, elementRef, newState) {
|
|
2792
|
+
state.contentState = newState;
|
|
2793
|
+
};
|
|
2668
2794
|
const processMessage = function processMessage2(props, state, elementRef, event) {
|
|
2669
2795
|
const { data } = event;
|
|
2670
2796
|
if (data)
|
|
@@ -2672,9 +2798,10 @@ const processMessage = function processMessage2(props, state, elementRef, event)
|
|
|
2672
2798
|
case "builder.configureSdk": {
|
|
2673
2799
|
const messageContent = data.data;
|
|
2674
2800
|
const { breakpoints, contentId } = messageContent;
|
|
2675
|
-
if (!contentId || contentId !== useContent
|
|
2801
|
+
if (!contentId || contentId !== state.useContent?.id)
|
|
2676
2802
|
return;
|
|
2677
|
-
|
|
2803
|
+
if (breakpoints)
|
|
2804
|
+
setBreakpoints(props, state, elementRef, breakpoints);
|
|
2678
2805
|
state.forceReRenderCount = state.forceReRenderCount + 1;
|
|
2679
2806
|
break;
|
|
2680
2807
|
}
|
|
@@ -2683,7 +2810,7 @@ const processMessage = function processMessage2(props, state, elementRef, event)
|
|
|
2683
2810
|
const key = messageContent1.key || messageContent1.alias || messageContent1.entry || messageContent1.modelName;
|
|
2684
2811
|
const contentData = messageContent1.data;
|
|
2685
2812
|
if (key === props.model) {
|
|
2686
|
-
state
|
|
2813
|
+
mergeNewContent(props, state, elementRef, contentData);
|
|
2687
2814
|
state.forceReRenderCount = state.forceReRenderCount + 1;
|
|
2688
2815
|
}
|
|
2689
2816
|
break;
|
|
@@ -2691,18 +2818,18 @@ const processMessage = function processMessage2(props, state, elementRef, event)
|
|
|
2691
2818
|
}
|
|
2692
2819
|
};
|
|
2693
2820
|
const evaluateJsCode = function evaluateJsCode2(props, state, elementRef) {
|
|
2694
|
-
const jsCode = useContent
|
|
2821
|
+
const jsCode = state.useContent?.data?.jsCode;
|
|
2695
2822
|
if (jsCode)
|
|
2696
2823
|
evaluate({
|
|
2697
2824
|
code: jsCode,
|
|
2698
|
-
context:
|
|
2699
|
-
state: contentState
|
|
2825
|
+
context: props.context || {},
|
|
2826
|
+
state: state.contentState
|
|
2700
2827
|
});
|
|
2701
2828
|
};
|
|
2702
2829
|
const onClick = function onClick22(props, state, elementRef, event) {
|
|
2703
|
-
if (useContent
|
|
2704
|
-
const variationId = useContent
|
|
2705
|
-
const contentId = useContent
|
|
2830
|
+
if (state.useContent) {
|
|
2831
|
+
const variationId = state.useContent?.testVariationId;
|
|
2832
|
+
const contentId = state.useContent?.id;
|
|
2706
2833
|
_track({
|
|
2707
2834
|
type: "click",
|
|
2708
2835
|
canTrack: state.canTrackToUse,
|
|
@@ -2719,23 +2846,23 @@ const onClick = function onClick22(props, state, elementRef, event) {
|
|
|
2719
2846
|
const evalExpression = function evalExpression2(props, state, elementRef, expression) {
|
|
2720
2847
|
return expression.replace(/{{([^}]+)}}/g, (_match, group) => evaluate({
|
|
2721
2848
|
code: group,
|
|
2722
|
-
context:
|
|
2723
|
-
state: contentState
|
|
2849
|
+
context: props.context || {},
|
|
2850
|
+
state: state.contentState
|
|
2724
2851
|
}));
|
|
2725
2852
|
};
|
|
2726
2853
|
const handleRequest = function handleRequest2(props, state, elementRef, { url, key }) {
|
|
2727
2854
|
fetch$1(url).then((response) => response.json()).then((json) => {
|
|
2728
|
-
const
|
|
2729
|
-
...state.
|
|
2855
|
+
const newState = {
|
|
2856
|
+
...state.contentState,
|
|
2730
2857
|
[key]: json
|
|
2731
2858
|
};
|
|
2732
|
-
state
|
|
2859
|
+
setContextState(props, state, elementRef, newState);
|
|
2733
2860
|
}).catch((err) => {
|
|
2734
2861
|
console.log("error fetching dynamic data", url, err);
|
|
2735
2862
|
});
|
|
2736
2863
|
};
|
|
2737
2864
|
const runHttpRequests = function runHttpRequests2(props, state, elementRef) {
|
|
2738
|
-
const requests = useContent
|
|
2865
|
+
const requests = state.useContent?.data?.httpRequests ?? {};
|
|
2739
2866
|
Object.entries(requests).forEach(([key, url]) => {
|
|
2740
2867
|
if (url && (!state.httpReqsData[key] || isEditing())) {
|
|
2741
2868
|
const evaluatedUrl = evalExpression(props, state, elementRef, url);
|
|
@@ -2750,7 +2877,7 @@ const emitStateUpdate = function emitStateUpdate2(props, state, elementRef) {
|
|
|
2750
2877
|
if (isEditing())
|
|
2751
2878
|
window.dispatchEvent(new CustomEvent("builder:component:stateChange", {
|
|
2752
2879
|
detail: {
|
|
2753
|
-
state: contentState
|
|
2880
|
+
state: state.contentState,
|
|
2754
2881
|
ref: {
|
|
2755
2882
|
name: props.model
|
|
2756
2883
|
}
|
|
@@ -2758,7 +2885,7 @@ const emitStateUpdate = function emitStateUpdate2(props, state, elementRef) {
|
|
|
2758
2885
|
}));
|
|
2759
2886
|
};
|
|
2760
2887
|
const shouldRenderContentStyles = function shouldRenderContentStyles2(props, state, elementRef) {
|
|
2761
|
-
return Boolean((useContent
|
|
2888
|
+
return Boolean((state.useContent?.data?.cssCode || state.useContent?.data?.customFonts?.length) && TARGET !== "reactNative");
|
|
2762
2889
|
};
|
|
2763
2890
|
const RenderContent = /* @__PURE__ */ componentQrl(inlinedQrl((props) => {
|
|
2764
2891
|
const elementRef = useRef();
|
|
@@ -2773,18 +2900,24 @@ const RenderContent = /* @__PURE__ */ componentQrl(inlinedQrl((props) => {
|
|
|
2773
2900
|
}), {}),
|
|
2774
2901
|
canTrackToUse: checkIsDefined(props.canTrack) ? props.canTrack : true,
|
|
2775
2902
|
clicked: false,
|
|
2776
|
-
|
|
2903
|
+
contentState: getContextStateInitialValue({
|
|
2904
|
+
content: props.content,
|
|
2905
|
+
data: props.data,
|
|
2906
|
+
locale: props.locale
|
|
2907
|
+
}),
|
|
2777
2908
|
forceReRenderCount: 0,
|
|
2778
2909
|
httpReqsData: {},
|
|
2779
2910
|
overrideContent: null,
|
|
2780
|
-
overrideState: {},
|
|
2781
2911
|
update: 0,
|
|
2782
|
-
|
|
2912
|
+
useContent: getContentInitialValue({
|
|
2913
|
+
content: props.content,
|
|
2914
|
+
data: props.data
|
|
2915
|
+
})
|
|
2783
2916
|
});
|
|
2784
|
-
useContextProvider(
|
|
2785
|
-
content: useContent
|
|
2786
|
-
state: contentState
|
|
2787
|
-
context:
|
|
2917
|
+
useContextProvider(builderContext, useStore({
|
|
2918
|
+
content: state.useContent,
|
|
2919
|
+
state: state.contentState,
|
|
2920
|
+
context: props.context || {},
|
|
2788
2921
|
apiKey: props.apiKey,
|
|
2789
2922
|
registeredComponents: state.allRegisteredComponents
|
|
2790
2923
|
}));
|
|
@@ -2811,9 +2944,9 @@ const RenderContent = /* @__PURE__ */ componentQrl(inlinedQrl((props) => {
|
|
|
2811
2944
|
window.addEventListener("message", processMessage.bind(null, props2, state2, elementRef2));
|
|
2812
2945
|
window.addEventListener("builder:component:stateChangeListenerActivated", emitStateUpdate.bind(null, props2, state2, elementRef2));
|
|
2813
2946
|
}
|
|
2814
|
-
if (useContent
|
|
2815
|
-
const variationId = useContent
|
|
2816
|
-
const contentId = useContent
|
|
2947
|
+
if (state2.useContent) {
|
|
2948
|
+
const variationId = state2.useContent?.testVariationId;
|
|
2949
|
+
const contentId = state2.useContent?.id;
|
|
2817
2950
|
_track({
|
|
2818
2951
|
type: "impression",
|
|
2819
2952
|
canTrack: state2.canTrackToUse,
|
|
@@ -2832,7 +2965,7 @@ const RenderContent = /* @__PURE__ */ componentQrl(inlinedQrl((props) => {
|
|
|
2832
2965
|
apiKey: props2.apiKey
|
|
2833
2966
|
}).then((content) => {
|
|
2834
2967
|
if (content)
|
|
2835
|
-
state2
|
|
2968
|
+
mergeNewContent(props2, state2, elementRef2, content);
|
|
2836
2969
|
});
|
|
2837
2970
|
}
|
|
2838
2971
|
evaluateJsCode(props2, state2);
|
|
@@ -2844,30 +2977,30 @@ const RenderContent = /* @__PURE__ */ componentQrl(inlinedQrl((props) => {
|
|
|
2844
2977
|
props,
|
|
2845
2978
|
state
|
|
2846
2979
|
]));
|
|
2847
|
-
|
|
2980
|
+
useTaskQrl(inlinedQrl(({ track: track2 }) => {
|
|
2848
2981
|
const [elementRef2, props2, state2] = useLexicalScope();
|
|
2849
|
-
|
|
2850
|
-
|
|
2982
|
+
track2(() => state2.useContent?.data?.jsCode);
|
|
2983
|
+
track2(() => state2.contentState);
|
|
2851
2984
|
evaluateJsCode(props2, state2);
|
|
2852
|
-
}, "
|
|
2985
|
+
}, "RenderContent_component_useTask_Kulmlf9pM08", [
|
|
2853
2986
|
elementRef,
|
|
2854
2987
|
props,
|
|
2855
2988
|
state
|
|
2856
2989
|
]));
|
|
2857
|
-
|
|
2990
|
+
useTaskQrl(inlinedQrl(({ track: track2 }) => {
|
|
2858
2991
|
const [elementRef2, props2, state2] = useLexicalScope();
|
|
2859
|
-
|
|
2992
|
+
track2(() => state2.useContent?.data?.httpRequests);
|
|
2860
2993
|
runHttpRequests(props2, state2, elementRef2);
|
|
2861
|
-
}, "
|
|
2994
|
+
}, "RenderContent_component_useTask_1_X59YMGOetns", [
|
|
2862
2995
|
elementRef,
|
|
2863
2996
|
props,
|
|
2864
2997
|
state
|
|
2865
2998
|
]));
|
|
2866
|
-
|
|
2999
|
+
useTaskQrl(inlinedQrl(({ track: track2 }) => {
|
|
2867
3000
|
const [elementRef2, props2, state2] = useLexicalScope();
|
|
2868
|
-
|
|
3001
|
+
track2(() => state2.contentState);
|
|
2869
3002
|
emitStateUpdate(props2, state2);
|
|
2870
|
-
}, "
|
|
3003
|
+
}, "RenderContent_component_useTask_2_u3gn3Pj2b2s", [
|
|
2871
3004
|
elementRef,
|
|
2872
3005
|
props,
|
|
2873
3006
|
state
|
|
@@ -2884,7 +3017,7 @@ const RenderContent = /* @__PURE__ */ componentQrl(inlinedQrl((props) => {
|
|
|
2884
3017
|
state
|
|
2885
3018
|
]));
|
|
2886
3019
|
return /* @__PURE__ */ jsx(Fragment, {
|
|
2887
|
-
children: useContent
|
|
3020
|
+
children: state.useContent ? /* @__PURE__ */ jsxs("div", {
|
|
2888
3021
|
ref: elementRef,
|
|
2889
3022
|
onClick$: inlinedQrl((event) => {
|
|
2890
3023
|
const [elementRef2, props2, state2] = useLexicalScope();
|
|
@@ -2894,17 +3027,18 @@ const RenderContent = /* @__PURE__ */ componentQrl(inlinedQrl((props) => {
|
|
|
2894
3027
|
props,
|
|
2895
3028
|
state
|
|
2896
3029
|
]),
|
|
2897
|
-
"builder-content-id": useContent
|
|
3030
|
+
"builder-content-id": state.useContent?.id,
|
|
2898
3031
|
get "builder-model"() {
|
|
2899
3032
|
return props.model;
|
|
2900
3033
|
},
|
|
2901
3034
|
children: [
|
|
2902
3035
|
shouldRenderContentStyles(props, state) ? /* @__PURE__ */ jsx(RenderContentStyles, {
|
|
2903
|
-
|
|
2904
|
-
|
|
3036
|
+
contentId: state.useContent?.id,
|
|
3037
|
+
cssCode: state.useContent?.data?.cssCode,
|
|
3038
|
+
customFonts: state.useContent?.data?.customFonts
|
|
2905
3039
|
}, "03_0") : null,
|
|
2906
3040
|
/* @__PURE__ */ jsx(RenderBlocks, {
|
|
2907
|
-
blocks: useContent
|
|
3041
|
+
blocks: state.useContent?.data?.blocks
|
|
2908
3042
|
}, state.forceReRenderCount)
|
|
2909
3043
|
],
|
|
2910
3044
|
[_IMMUTABLE]: {
|
|
@@ -2917,69 +3051,7 @@ const RenderContent = /* @__PURE__ */ componentQrl(inlinedQrl((props) => {
|
|
|
2917
3051
|
}
|
|
2918
3052
|
}, "03_1");
|
|
2919
3053
|
}, "RenderContent_component_hEAI0ahViXM"));
|
|
2920
|
-
const
|
|
2921
|
-
return [
|
|
2922
|
-
...[
|
|
2923
|
-
props.attributes.class
|
|
2924
|
-
],
|
|
2925
|
-
"builder-symbol",
|
|
2926
|
-
props.symbol?.inline ? "builder-inline-symbol" : void 0,
|
|
2927
|
-
props.symbol?.dynamic || props.dynamic ? "builder-dynamic-symbol" : void 0
|
|
2928
|
-
].filter(Boolean).join(" ");
|
|
2929
|
-
};
|
|
2930
|
-
const contentToUse = function contentToUse2(props, state, builderContext) {
|
|
2931
|
-
return props.symbol?.content || state.fetchedContent;
|
|
2932
|
-
};
|
|
2933
|
-
const Symbol$1 = /* @__PURE__ */ componentQrl(inlinedQrl((props) => {
|
|
2934
|
-
const builderContext = useContext(BuilderContext);
|
|
2935
|
-
const state = useStore({
|
|
2936
|
-
fetchedContent: null
|
|
2937
|
-
});
|
|
2938
|
-
useWatchQrl(inlinedQrl(({ track: track2 }) => {
|
|
2939
|
-
const [builderContext2, props2, state2] = useLexicalScope();
|
|
2940
|
-
props2 && track2(props2, "symbol");
|
|
2941
|
-
state2 && track2(state2, "fetchedContent");
|
|
2942
|
-
const symbolToUse = props2.symbol;
|
|
2943
|
-
if (symbolToUse && !symbolToUse.content && !state2.fetchedContent && symbolToUse.model && builderContext2?.apiKey)
|
|
2944
|
-
getContent({
|
|
2945
|
-
model: symbolToUse.model,
|
|
2946
|
-
apiKey: builderContext2.apiKey,
|
|
2947
|
-
query: {
|
|
2948
|
-
id: symbolToUse.entry
|
|
2949
|
-
}
|
|
2950
|
-
}).then((response) => {
|
|
2951
|
-
state2.fetchedContent = response;
|
|
2952
|
-
});
|
|
2953
|
-
}, "Symbol_component_useWatch_9HNT04zd0Dk", [
|
|
2954
|
-
builderContext,
|
|
2955
|
-
props,
|
|
2956
|
-
state
|
|
2957
|
-
]));
|
|
2958
|
-
return /* @__PURE__ */ jsx("div", {
|
|
2959
|
-
...props.attributes,
|
|
2960
|
-
class: className(props),
|
|
2961
|
-
children: /* @__PURE__ */ jsx(RenderContent, {
|
|
2962
|
-
get apiKey() {
|
|
2963
|
-
return builderContext.apiKey;
|
|
2964
|
-
},
|
|
2965
|
-
get context() {
|
|
2966
|
-
return builderContext.context;
|
|
2967
|
-
},
|
|
2968
|
-
customComponents: Object.values(builderContext.registeredComponents),
|
|
2969
|
-
data: {
|
|
2970
|
-
...props.symbol?.data,
|
|
2971
|
-
...builderContext.state,
|
|
2972
|
-
...props.symbol?.content?.data?.state
|
|
2973
|
-
},
|
|
2974
|
-
model: props.symbol?.model,
|
|
2975
|
-
content: contentToUse(props, state),
|
|
2976
|
-
[_IMMUTABLE]: {
|
|
2977
|
-
apiKey: _wrapSignal(builderContext, "apiKey"),
|
|
2978
|
-
context: _wrapSignal(builderContext, "context")
|
|
2979
|
-
}
|
|
2980
|
-
}, "Wt_0")
|
|
2981
|
-
});
|
|
2982
|
-
}, "Symbol_component_WVvggdkUPdk"));
|
|
3054
|
+
const RenderContent$1 = RenderContent;
|
|
2983
3055
|
const settings = {};
|
|
2984
3056
|
function setEditorSettings(newSettings) {
|
|
2985
3057
|
if (isBrowser()) {
|
|
@@ -2997,7 +3069,7 @@ export {
|
|
|
2997
3069
|
FragmentComponent as Fragment,
|
|
2998
3070
|
Image,
|
|
2999
3071
|
RenderBlocks,
|
|
3000
|
-
RenderContent,
|
|
3072
|
+
RenderContent$1 as RenderContent,
|
|
3001
3073
|
SectionComponent as Section,
|
|
3002
3074
|
Symbol$1 as Symbol,
|
|
3003
3075
|
Text,
|