@builder.io/sdk-qwik 0.7.3 → 0.7.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/browser/index.qwik.cjs +115 -191
- package/lib/browser/index.qwik.mjs +115 -191
- package/lib/edge/index.qwik.cjs +115 -191
- package/lib/edge/index.qwik.mjs +115 -191
- package/lib/node/index.qwik.cjs +115 -191
- package/lib/node/index.qwik.mjs +115 -191
- package/package.json +8 -1
- package/types/src/blocks/video/video.d.ts +4 -0
- package/types/src/components/content/content.helpers.d.ts +1 -1
- package/types/src/components/content/content.types.d.ts +0 -4
- package/types/src/components/content-variants/helpers.d.ts +3 -3
- package/types/src/components/content-variants/inlined-fns.d.ts +14 -0
- package/types/src/constants/sdk-version.d.ts +1 -1
package/lib/node/index.qwik.mjs
CHANGED
|
@@ -818,8 +818,9 @@ const Block = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((props) =>
|
|
|
818
818
|
props
|
|
819
819
|
]));
|
|
820
820
|
const processedBlock = useComputedQrl(/* @__PURE__ */ inlinedQrl(() => {
|
|
821
|
-
|
|
822
|
-
|
|
821
|
+
var _a2;
|
|
822
|
+
const [props2] = useLexicalScope();
|
|
823
|
+
return ((_a2 = props2.block.repeat) == null ? void 0 : _a2.collection) ? props2.block : getProcessedBlock({
|
|
823
824
|
block: props2.block,
|
|
824
825
|
localState: props2.context.localState,
|
|
825
826
|
rootState: props2.context.rootState,
|
|
@@ -828,8 +829,7 @@ const Block = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((props) =>
|
|
|
828
829
|
shouldEvaluateBindings: true
|
|
829
830
|
});
|
|
830
831
|
}, "Block_component_processedBlock_useComputed_ESKw0l5FcBc", [
|
|
831
|
-
props
|
|
832
|
-
repeatItem
|
|
832
|
+
props
|
|
833
833
|
]));
|
|
834
834
|
const Tag = useComputedQrl(/* @__PURE__ */ inlinedQrl(() => {
|
|
835
835
|
const [props2] = useLexicalScope();
|
|
@@ -838,14 +838,19 @@ const Block = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((props) =>
|
|
|
838
838
|
props
|
|
839
839
|
]));
|
|
840
840
|
const canShowBlock = useComputedQrl(/* @__PURE__ */ inlinedQrl(() => {
|
|
841
|
-
|
|
841
|
+
var _a2, _b;
|
|
842
|
+
const [processedBlock2, props2, repeatItem2] = useLexicalScope();
|
|
842
843
|
if ("hide" in processedBlock2.value)
|
|
843
844
|
return !processedBlock2.value.hide;
|
|
844
845
|
if ("show" in processedBlock2.value)
|
|
845
846
|
return processedBlock2.value.show;
|
|
847
|
+
if (((_a2 = props2.block.repeat) == null ? void 0 : _a2.collection) && !((_b = repeatItem2.value) == null ? void 0 : _b.length))
|
|
848
|
+
return false;
|
|
846
849
|
return true;
|
|
847
850
|
}, "Block_component_canShowBlock_useComputed_NJEFz8ICF08", [
|
|
848
|
-
processedBlock
|
|
851
|
+
processedBlock,
|
|
852
|
+
props,
|
|
853
|
+
repeatItem
|
|
849
854
|
]));
|
|
850
855
|
const childrenWithoutParentComponent = useComputedQrl(/* @__PURE__ */ inlinedQrl(() => {
|
|
851
856
|
var _a2;
|
|
@@ -2674,6 +2679,8 @@ const componentInfo = {
|
|
|
2674
2679
|
]
|
|
2675
2680
|
};
|
|
2676
2681
|
const Video = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((props) => {
|
|
2682
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
2683
|
+
_jsxBranch();
|
|
2677
2684
|
const videoProps = useComputedQrl(/* @__PURE__ */ inlinedQrl(() => {
|
|
2678
2685
|
const [props2] = useLexicalScope();
|
|
2679
2686
|
return {
|
|
@@ -2697,43 +2704,83 @@ const Video = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((props) =>
|
|
|
2697
2704
|
props
|
|
2698
2705
|
]));
|
|
2699
2706
|
const spreadProps = useComputedQrl(/* @__PURE__ */ inlinedQrl(() => {
|
|
2700
|
-
const [
|
|
2707
|
+
const [videoProps2] = useLexicalScope();
|
|
2701
2708
|
return {
|
|
2702
|
-
...props2.attributes,
|
|
2703
2709
|
...videoProps2.value
|
|
2704
2710
|
};
|
|
2705
2711
|
}, "Video_component_spreadProps_useComputed_ZdLsx18NYH4", [
|
|
2706
|
-
props,
|
|
2707
2712
|
videoProps
|
|
2708
2713
|
]));
|
|
2709
|
-
return /* @__PURE__ */
|
|
2710
|
-
|
|
2711
|
-
|
|
2712
|
-
|
|
2713
|
-
|
|
2714
|
-
|
|
2715
|
-
|
|
2716
|
-
props
|
|
2717
|
-
|
|
2718
|
-
|
|
2719
|
-
|
|
2720
|
-
|
|
2721
|
-
|
|
2722
|
-
|
|
2723
|
-
return {
|
|
2714
|
+
return /* @__PURE__ */ _jsxQ("div", null, {
|
|
2715
|
+
style: {
|
|
2716
|
+
position: "relative"
|
|
2717
|
+
}
|
|
2718
|
+
}, [
|
|
2719
|
+
/* @__PURE__ */ _jsxS("video", {
|
|
2720
|
+
...spreadProps.value,
|
|
2721
|
+
children: !props.lazyLoad ? /* @__PURE__ */ _jsxQ("source", null, {
|
|
2722
|
+
src: _fnSignal((p0) => p0.video, [
|
|
2723
|
+
props
|
|
2724
|
+
], "p0.video"),
|
|
2725
|
+
type: "video/mp4"
|
|
2726
|
+
}, null, 3, "j7_0") : null,
|
|
2727
|
+
style: {
|
|
2724
2728
|
width: "100%",
|
|
2725
2729
|
height: "100%",
|
|
2726
|
-
...(_a =
|
|
2727
|
-
objectFit:
|
|
2728
|
-
objectPosition:
|
|
2730
|
+
...(_a = props.attributes) == null ? void 0 : _a.style,
|
|
2731
|
+
objectFit: props.fit,
|
|
2732
|
+
objectPosition: props.position,
|
|
2729
2733
|
// Hack to get object fit to work as expected and
|
|
2730
2734
|
// not have the video overflow
|
|
2731
|
-
|
|
2732
|
-
|
|
2733
|
-
|
|
2734
|
-
|
|
2735
|
-
|
|
2736
|
-
|
|
2735
|
+
zIndex: 2,
|
|
2736
|
+
borderRadius: "1px",
|
|
2737
|
+
...props.aspectRatio ? {
|
|
2738
|
+
position: "absolute"
|
|
2739
|
+
} : null
|
|
2740
|
+
}
|
|
2741
|
+
}, {
|
|
2742
|
+
class: "builder-video",
|
|
2743
|
+
poster: _fnSignal((p0) => p0.posterImage, [
|
|
2744
|
+
props
|
|
2745
|
+
], "p0.posterImage"),
|
|
2746
|
+
preload: _fnSignal((p0) => p0.preload || "metadata", [
|
|
2747
|
+
props
|
|
2748
|
+
], 'p0.preload||"metadata"'),
|
|
2749
|
+
src: _fnSignal((p0) => p0.video || "no-src", [
|
|
2750
|
+
props
|
|
2751
|
+
], 'p0.video||"no-src"')
|
|
2752
|
+
}, 0, null),
|
|
2753
|
+
props.aspectRatio && !(props.fitContent && ((_c = (_b = props.builderBlock) == null ? void 0 : _b.children) == null ? void 0 : _c.length)) ? /* @__PURE__ */ _jsxQ("div", null, {
|
|
2754
|
+
style: _fnSignal((p0) => ({
|
|
2755
|
+
width: "100%",
|
|
2756
|
+
paddingTop: p0.aspectRatio * 100 + "%",
|
|
2757
|
+
pointerEvents: "none",
|
|
2758
|
+
fontSize: "0px"
|
|
2759
|
+
}), [
|
|
2760
|
+
props
|
|
2761
|
+
], '{width:"100%",paddingTop:p0.aspectRatio*100+"%",pointerEvents:"none",fontSize:"0px"}')
|
|
2762
|
+
}, null, 3, "j7_1") : null,
|
|
2763
|
+
((_e = (_d = props.builderBlock) == null ? void 0 : _d.children) == null ? void 0 : _e.length) && props.fitContent ? /* @__PURE__ */ _jsxQ("div", null, {
|
|
2764
|
+
style: {
|
|
2765
|
+
display: "flex",
|
|
2766
|
+
flexDirection: "column",
|
|
2767
|
+
alignItems: "stretch"
|
|
2768
|
+
}
|
|
2769
|
+
}, /* @__PURE__ */ _jsxC(Slot, null, 3, "j7_2"), 1, "j7_3") : null,
|
|
2770
|
+
((_g = (_f = props.builderBlock) == null ? void 0 : _f.children) == null ? void 0 : _g.length) && !props.fitContent ? /* @__PURE__ */ _jsxQ("div", null, {
|
|
2771
|
+
style: {
|
|
2772
|
+
pointerEvents: "none",
|
|
2773
|
+
display: "flex",
|
|
2774
|
+
flexDirection: "column",
|
|
2775
|
+
alignItems: "stretch",
|
|
2776
|
+
position: "absolute",
|
|
2777
|
+
top: "0",
|
|
2778
|
+
left: "0",
|
|
2779
|
+
width: "100%",
|
|
2780
|
+
height: "100%"
|
|
2781
|
+
}
|
|
2782
|
+
}, /* @__PURE__ */ _jsxC(Slot, null, 3, "j7_4"), 1, "j7_5") : null
|
|
2783
|
+
], 1, "j7_6");
|
|
2737
2784
|
}, "Video_component_qdcTZflYyoQ"));
|
|
2738
2785
|
const getDefaultRegisteredComponents = () => [
|
|
2739
2786
|
{
|
|
@@ -2799,12 +2846,16 @@ const serializeComponentInfo = ({ inputs, ...info }) => ({
|
|
|
2799
2846
|
[key]: serializeValue(value)
|
|
2800
2847
|
}), {}))
|
|
2801
2848
|
});
|
|
2849
|
+
const UPDATE_COOKIES_AND_STYLES_SCRIPT = "function updateCookiesAndStyles(contentId, variants, isHydrationTarget) {\n function getAndSetVariantId() {\n function setCookie(name, value, days) {\n let expires = '';\n if (days) {\n const date = new Date();\n date.setTime(date.getTime() + days * 24 * 60 * 60 * 1000);\n expires = '; expires=' + date.toUTCString();\n }\n document.cookie = name + '=' + (value || '') + expires + '; path=/' + '; Secure; SameSite=None';\n }\n function getCookie(name) {\n const nameEQ = name + '=';\n const ca = document.cookie.split(';');\n for (let i = 0; i < ca.length; i++) {\n let c = ca[i];\n while (c.charAt(0) === ' ') c = c.substring(1, c.length);\n if (c.indexOf(nameEQ) === 0) return c.substring(nameEQ.length, c.length);\n }\n return null;\n }\n const cookieName = `builder.tests.${contentId}`;\n const variantInCookie = getCookie(cookieName);\n const availableIDs = variants.map(vr => vr.id).concat(contentId);\n if (variantInCookie && availableIDs.includes(variantInCookie)) {\n return variantInCookie;\n }\n let n = 0;\n const random = Math.random();\n for (let i = 0; i < variants.length; i++) {\n const variant = variants[i];\n const testRatio = variant.testRatio;\n n += testRatio;\n if (random < n) {\n setCookie(cookieName, variant.id);\n return variant.id;\n }\n }\n setCookie(cookieName, contentId);\n return contentId;\n }\n const winningVariantId = getAndSetVariantId();\n const styleEl = document.currentScript?.previousElementSibling;\n if (isHydrationTarget) {\n styleEl.remove();\n const thisScriptEl = document.currentScript;\n thisScriptEl?.remove();\n } else {\n const newStyleStr = variants.concat({\n id: contentId\n }).filter(variant => variant.id !== winningVariantId).map(value => {\n return `.variant-${value.id} { display: none; }\n `;\n }).join('');\n styleEl.innerHTML = newStyleStr;\n }\n}";
|
|
2850
|
+
const UPDATE_VARIANT_VISIBILITY_SCRIPT = "function updateVariantVisibility(variantContentId, defaultContentId, isHydrationTarget) {\n if (!navigator.cookieEnabled) {\n return;\n }\n function getCookie(name) {\n const nameEQ = name + '=';\n const ca = document.cookie.split(';');\n for (let i = 0; i < ca.length; i++) {\n let c = ca[i];\n while (c.charAt(0) === ' ') c = c.substring(1, c.length);\n if (c.indexOf(nameEQ) === 0) return c.substring(nameEQ.length, c.length);\n }\n return null;\n }\n const cookieName = `builder.tests.${defaultContentId}`;\n const winningVariant = getCookie(cookieName);\n const parentDiv = document.currentScript?.parentElement;\n const isDefaultContent = variantContentId === defaultContentId;\n const isWinningVariant = winningVariant === variantContentId;\n if (isWinningVariant && !isDefaultContent) {\n parentDiv?.removeAttribute('hidden');\n parentDiv?.removeAttribute('aria-hidden');\n } else if (!isWinningVariant && isDefaultContent) {\n parentDiv?.setAttribute('hidden', 'true');\n parentDiv?.setAttribute('aria-hidden', 'true');\n }\n if (isHydrationTarget) {\n if (!isWinningVariant) {\n parentDiv?.remove();\n }\n const thisScriptEl = document.currentScript;\n thisScriptEl?.remove();\n }\n return;\n}";
|
|
2851
|
+
const UPDATE_COOKIES_AND_STYLES_SCRIPT_NAME = "builderIoAbTest";
|
|
2852
|
+
const UPDATE_VARIANT_VISIBILITY_SCRIPT_FN_NAME = "builderIoRenderContent";
|
|
2802
2853
|
const getVariants = (content) => Object.values((content == null ? void 0 : content.variations) || {}).map((variant) => ({
|
|
2803
2854
|
...variant,
|
|
2804
2855
|
testVariationId: variant.id,
|
|
2805
2856
|
id: content == null ? void 0 : content.id
|
|
2806
2857
|
}));
|
|
2807
|
-
const
|
|
2858
|
+
const checkShouldRenderVariants = ({ canTrack, content }) => {
|
|
2808
2859
|
const hasVariants = getVariants(content).length > 0;
|
|
2809
2860
|
if (!hasVariants)
|
|
2810
2861
|
return false;
|
|
@@ -2814,131 +2865,27 @@ const checkShouldRunVariants = ({ canTrack, content }) => {
|
|
|
2814
2865
|
return false;
|
|
2815
2866
|
return true;
|
|
2816
2867
|
};
|
|
2817
|
-
function bldrAbTest(contentId, variants, isHydrationTarget2) {
|
|
2818
|
-
var _a;
|
|
2819
|
-
function getAndSetVariantId2() {
|
|
2820
|
-
function setCookie2(name, value, days) {
|
|
2821
|
-
let expires = "";
|
|
2822
|
-
if (days) {
|
|
2823
|
-
const date = /* @__PURE__ */ new Date();
|
|
2824
|
-
date.setTime(date.getTime() + days * 864e5);
|
|
2825
|
-
expires = "; expires=" + date.toUTCString();
|
|
2826
|
-
}
|
|
2827
|
-
document.cookie = name + "=" + (value || "") + expires + "; path=/; Secure; SameSite=None";
|
|
2828
|
-
}
|
|
2829
|
-
function getCookie2(name) {
|
|
2830
|
-
const nameEQ = name + "=";
|
|
2831
|
-
const ca = document.cookie.split(";");
|
|
2832
|
-
for (let i = 0; i < ca.length; i++) {
|
|
2833
|
-
let c = ca[i];
|
|
2834
|
-
while (c.charAt(0) === " ")
|
|
2835
|
-
c = c.substring(1, c.length);
|
|
2836
|
-
if (c.indexOf(nameEQ) === 0)
|
|
2837
|
-
return c.substring(nameEQ.length, c.length);
|
|
2838
|
-
}
|
|
2839
|
-
return null;
|
|
2840
|
-
}
|
|
2841
|
-
const cookieName = `builder.tests.${contentId}`;
|
|
2842
|
-
const variantInCookie = getCookie2(cookieName);
|
|
2843
|
-
const availableIDs = variants.map((vr) => vr.id).concat(contentId);
|
|
2844
|
-
if (variantInCookie && availableIDs.includes(variantInCookie))
|
|
2845
|
-
return variantInCookie;
|
|
2846
|
-
let n = 0;
|
|
2847
|
-
const random = Math.random();
|
|
2848
|
-
for (let i = 0; i < variants.length; i++) {
|
|
2849
|
-
const variant = variants[i];
|
|
2850
|
-
const testRatio = variant.testRatio;
|
|
2851
|
-
n += testRatio;
|
|
2852
|
-
if (random < n) {
|
|
2853
|
-
setCookie2(cookieName, variant.id);
|
|
2854
|
-
return variant.id;
|
|
2855
|
-
}
|
|
2856
|
-
}
|
|
2857
|
-
setCookie2(cookieName, contentId);
|
|
2858
|
-
return contentId;
|
|
2859
|
-
}
|
|
2860
|
-
const winningVariantId = getAndSetVariantId2();
|
|
2861
|
-
const styleEl = (_a = document.currentScript) == null ? void 0 : _a.previousElementSibling;
|
|
2862
|
-
if (isHydrationTarget2) {
|
|
2863
|
-
styleEl.remove();
|
|
2864
|
-
const thisScriptEl = document.currentScript;
|
|
2865
|
-
thisScriptEl == null ? void 0 : thisScriptEl.remove();
|
|
2866
|
-
} else {
|
|
2867
|
-
const newStyleStr = variants.concat({
|
|
2868
|
-
id: contentId
|
|
2869
|
-
}).filter((variant) => variant.id !== winningVariantId).map((value) => {
|
|
2870
|
-
return `.variant-${value.id} { display: none; }
|
|
2871
|
-
`;
|
|
2872
|
-
}).join("");
|
|
2873
|
-
styleEl.innerHTML = newStyleStr;
|
|
2874
|
-
}
|
|
2875
|
-
}
|
|
2876
|
-
function bldrCntntScrpt(variantContentId, defaultContentId, isHydrationTarget2) {
|
|
2877
|
-
var _a;
|
|
2878
|
-
if (!navigator.cookieEnabled)
|
|
2879
|
-
return;
|
|
2880
|
-
function getCookie2(name) {
|
|
2881
|
-
const nameEQ = name + "=";
|
|
2882
|
-
const ca = document.cookie.split(";");
|
|
2883
|
-
for (let i = 0; i < ca.length; i++) {
|
|
2884
|
-
let c = ca[i];
|
|
2885
|
-
while (c.charAt(0) === " ")
|
|
2886
|
-
c = c.substring(1, c.length);
|
|
2887
|
-
if (c.indexOf(nameEQ) === 0)
|
|
2888
|
-
return c.substring(nameEQ.length, c.length);
|
|
2889
|
-
}
|
|
2890
|
-
return null;
|
|
2891
|
-
}
|
|
2892
|
-
const cookieName = `builder.tests.${defaultContentId}`;
|
|
2893
|
-
const variantId = getCookie2(cookieName);
|
|
2894
|
-
const parentDiv = (_a = document.currentScript) == null ? void 0 : _a.parentElement;
|
|
2895
|
-
const variantIsDefaultContent = variantContentId === defaultContentId;
|
|
2896
|
-
if (variantId === variantContentId) {
|
|
2897
|
-
if (variantIsDefaultContent)
|
|
2898
|
-
return;
|
|
2899
|
-
parentDiv == null ? void 0 : parentDiv.removeAttribute("hidden");
|
|
2900
|
-
parentDiv == null ? void 0 : parentDiv.removeAttribute("aria-hidden");
|
|
2901
|
-
} else {
|
|
2902
|
-
if (variantIsDefaultContent) {
|
|
2903
|
-
if (isHydrationTarget2)
|
|
2904
|
-
parentDiv == null ? void 0 : parentDiv.remove();
|
|
2905
|
-
else {
|
|
2906
|
-
parentDiv == null ? void 0 : parentDiv.setAttribute("hidden", "true");
|
|
2907
|
-
parentDiv == null ? void 0 : parentDiv.setAttribute("aria-hidden", "true");
|
|
2908
|
-
}
|
|
2909
|
-
}
|
|
2910
|
-
return;
|
|
2911
|
-
}
|
|
2912
|
-
return;
|
|
2913
|
-
}
|
|
2914
2868
|
const getIsHydrationTarget = (target) => target === "react" || target === "reactNative";
|
|
2915
2869
|
const isHydrationTarget = getIsHydrationTarget(TARGET);
|
|
2916
|
-
const
|
|
2917
|
-
|
|
2918
|
-
|
|
2919
|
-
const fnStr = bldrAbTest.toString().replace(/\s+/g, " ");
|
|
2920
|
-
const fnStr2 = bldrCntntScrpt.toString().replace(/\s+/g, " ");
|
|
2921
|
-
return `
|
|
2922
|
-
window.${AB_TEST_FN_NAME} = ${fnStr}
|
|
2923
|
-
window.${CONTENT_FN_NAME} = ${fnStr2}
|
|
2870
|
+
const getScriptString = () => `
|
|
2871
|
+
window.${UPDATE_COOKIES_AND_STYLES_SCRIPT_NAME} = ${UPDATE_COOKIES_AND_STYLES_SCRIPT}
|
|
2872
|
+
window.${UPDATE_VARIANT_VISIBILITY_SCRIPT_FN_NAME} = ${UPDATE_VARIANT_VISIBILITY_SCRIPT}
|
|
2924
2873
|
`;
|
|
2925
|
-
|
|
2926
|
-
|
|
2927
|
-
|
|
2928
|
-
|
|
2929
|
-
}
|
|
2930
|
-
|
|
2931
|
-
|
|
2932
|
-
window.${CONTENT_FN_NAME}("${variationId}", "${contentId}", ${isHydrationTarget})`;
|
|
2933
|
-
};
|
|
2874
|
+
const getUpdateCookieAndStylesScript = (variants, contentId) => `
|
|
2875
|
+
window.${UPDATE_COOKIES_AND_STYLES_SCRIPT_NAME}(
|
|
2876
|
+
"${contentId}",${JSON.stringify(variants)}, ${isHydrationTarget}
|
|
2877
|
+
)`;
|
|
2878
|
+
const getUpdateVariantVisibilityScript = ({ contentId, variationId }) => `window.${UPDATE_VARIANT_VISIBILITY_SCRIPT_FN_NAME}(
|
|
2879
|
+
"${variationId}", "${contentId}", ${isHydrationTarget}
|
|
2880
|
+
)`;
|
|
2934
2881
|
const InlinedScript = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((props) => {
|
|
2935
2882
|
return /* @__PURE__ */ _jsxQ("script", null, {
|
|
2936
2883
|
dangerouslySetInnerHTML: _fnSignal((p0) => p0.scriptStr, [
|
|
2937
2884
|
props
|
|
2938
2885
|
], "p0.scriptStr"),
|
|
2939
|
-
id: _fnSignal((p0) => p0.id, [
|
|
2886
|
+
id: _fnSignal((p0) => p0.id || "", [
|
|
2940
2887
|
props
|
|
2941
|
-
],
|
|
2888
|
+
], 'p0.id||""')
|
|
2942
2889
|
}, null, 3, "WO_0");
|
|
2943
2890
|
}, "InlinedScript_component_hwThBdhA8rw"));
|
|
2944
2891
|
function getGlobalThis() {
|
|
@@ -3318,7 +3265,7 @@ const getInteractionPropertiesForEvent = (event) => {
|
|
|
3318
3265
|
}
|
|
3319
3266
|
};
|
|
3320
3267
|
};
|
|
3321
|
-
const SDK_VERSION = "0.7.
|
|
3268
|
+
const SDK_VERSION = "0.7.5";
|
|
3322
3269
|
const registry = {};
|
|
3323
3270
|
function register(type, info) {
|
|
3324
3271
|
let typeList = registry[type];
|
|
@@ -3576,7 +3523,7 @@ const emitStateUpdate = function emitStateUpdate2(props, state, elementRef) {
|
|
|
3576
3523
|
}));
|
|
3577
3524
|
};
|
|
3578
3525
|
const EnableEditor = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((props) => {
|
|
3579
|
-
var _a, _b, _c;
|
|
3526
|
+
var _a, _b, _c, _d, _e;
|
|
3580
3527
|
_jsxBranch();
|
|
3581
3528
|
const elementRef = useSignal();
|
|
3582
3529
|
const state = useStore({
|
|
@@ -3636,7 +3583,7 @@ const EnableEditor = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((pr
|
|
|
3636
3583
|
state
|
|
3637
3584
|
]));
|
|
3638
3585
|
useOn("qvisible", /* @__PURE__ */ inlinedQrl((event, element) => {
|
|
3639
|
-
var _a2, _b2, _c2,
|
|
3586
|
+
var _a2, _b2, _c2, _d2;
|
|
3640
3587
|
if (isBrowser()) {
|
|
3641
3588
|
if (isEditing() && element)
|
|
3642
3589
|
element.dispatchEvent(new CustomEvent("initeditingbldr"));
|
|
@@ -3644,7 +3591,7 @@ const EnableEditor = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((pr
|
|
|
3644
3591
|
if (shouldTrackImpression) {
|
|
3645
3592
|
const variationId = (_b2 = element.attributes.getNamedItem("variationId")) == null ? void 0 : _b2.value;
|
|
3646
3593
|
const contentId = (_c2 = element.attributes.getNamedItem("contentId")) == null ? void 0 : _c2.value;
|
|
3647
|
-
const apiKeyProp = (
|
|
3594
|
+
const apiKeyProp = (_d2 = element.attributes.getNamedItem("apiKey")) == null ? void 0 : _d2.value;
|
|
3648
3595
|
_track({
|
|
3649
3596
|
type: "impression",
|
|
3650
3597
|
canTrack: true,
|
|
@@ -3742,7 +3689,7 @@ const EnableEditor = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((pr
|
|
|
3742
3689
|
hidden: true,
|
|
3743
3690
|
"aria-hidden": true
|
|
3744
3691
|
},
|
|
3745
|
-
class: props.
|
|
3692
|
+
class: `variant-${((_d = props.content) == null ? void 0 : _d.testVariationId) || ((_e = props.content) == null ? void 0 : _e.id)}`
|
|
3746
3693
|
}, /* @__PURE__ */ _jsxC(Slot, null, 3, "06_0")) : null
|
|
3747
3694
|
}, 1, "06_1");
|
|
3748
3695
|
}, "EnableEditor_component_ko1mO8oaj8k"));
|
|
@@ -3829,22 +3776,19 @@ ${getFontCss({
|
|
|
3829
3776
|
const getContextStateInitialValue = ({ content, data, locale }) => {
|
|
3830
3777
|
var _a, _b, _c;
|
|
3831
3778
|
const defaultValues = {};
|
|
3832
|
-
|
|
3833
|
-
|
|
3834
|
-
if (input.name && input.defaultValue !== void 0
|
|
3779
|
+
const initialState = ((_a = content == null ? void 0 : content.data) == null ? void 0 : _a.state) || {};
|
|
3780
|
+
(_c = (_b = content == null ? void 0 : content.data) == null ? void 0 : _b.inputs) == null ? void 0 : _c.forEach((input) => {
|
|
3781
|
+
if (input.name && input.defaultValue !== void 0)
|
|
3835
3782
|
defaultValues[input.name] = input.defaultValue;
|
|
3836
3783
|
});
|
|
3837
|
-
|
|
3838
|
-
...
|
|
3784
|
+
return {
|
|
3785
|
+
...defaultValues,
|
|
3786
|
+
...initialState,
|
|
3839
3787
|
...data,
|
|
3840
3788
|
...locale ? {
|
|
3841
3789
|
locale
|
|
3842
3790
|
} : {}
|
|
3843
3791
|
};
|
|
3844
|
-
return {
|
|
3845
|
-
...defaultValues,
|
|
3846
|
-
...stateToUse
|
|
3847
|
-
};
|
|
3848
3792
|
};
|
|
3849
3793
|
const getContentInitialValue = ({ content, data }) => {
|
|
3850
3794
|
return !content ? void 0 : {
|
|
@@ -3906,7 +3850,7 @@ const ContentComponent = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl
|
|
|
3906
3850
|
...serializeComponentInfo(info)
|
|
3907
3851
|
}
|
|
3908
3852
|
}), {}),
|
|
3909
|
-
scriptStr:
|
|
3853
|
+
scriptStr: getUpdateVariantVisibilityScript({
|
|
3910
3854
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion, @typescript-eslint/no-non-null-asserted-optional-chain
|
|
3911
3855
|
variationId: (_a = props.content) == null ? void 0 : _a.testVariationId,
|
|
3912
3856
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion, @typescript-eslint/no-non-null-asserted-optional-chain
|
|
@@ -3943,9 +3887,6 @@ const ContentComponent = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl
|
|
|
3943
3887
|
get enrich() {
|
|
3944
3888
|
return props.enrich;
|
|
3945
3889
|
},
|
|
3946
|
-
get classNameProp() {
|
|
3947
|
-
return props.classNameProp;
|
|
3948
|
-
},
|
|
3949
3890
|
get showContent() {
|
|
3950
3891
|
return props.showContent;
|
|
3951
3892
|
},
|
|
@@ -4034,9 +3975,6 @@ const ContentComponent = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl
|
|
|
4034
3975
|
canTrack: _fnSignal((p0) => p0.canTrack, [
|
|
4035
3976
|
props
|
|
4036
3977
|
], "p0.canTrack"),
|
|
4037
|
-
classNameProp: _fnSignal((p0) => p0.classNameProp, [
|
|
4038
|
-
props
|
|
4039
|
-
], "p0.classNameProp"),
|
|
4040
3978
|
content: _fnSignal((p0) => p0.content, [
|
|
4041
3979
|
props
|
|
4042
3980
|
], "p0.content"),
|
|
@@ -4064,19 +4002,19 @@ const ContentComponent = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl
|
|
|
4064
4002
|
const ContentVariants = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((props) => {
|
|
4065
4003
|
_jsxBranch();
|
|
4066
4004
|
const state = useStore({
|
|
4067
|
-
shouldRenderVariants:
|
|
4005
|
+
shouldRenderVariants: checkShouldRenderVariants({
|
|
4068
4006
|
canTrack: getDefaultCanTrack(props.canTrack),
|
|
4069
4007
|
content: props.content
|
|
4070
4008
|
})
|
|
4071
4009
|
});
|
|
4072
|
-
const
|
|
4010
|
+
const updateCookieAndStylesScriptStr = useComputedQrl(/* @__PURE__ */ inlinedQrl(() => {
|
|
4073
4011
|
var _a;
|
|
4074
4012
|
const [props2] = useLexicalScope();
|
|
4075
|
-
return
|
|
4013
|
+
return getUpdateCookieAndStylesScript(getVariants(props2.content).map((value) => ({
|
|
4076
4014
|
id: value.testVariationId,
|
|
4077
4015
|
testRatio: value.testRatio
|
|
4078
4016
|
})), ((_a = props2.content) == null ? void 0 : _a.id) || "");
|
|
4079
|
-
}, "
|
|
4017
|
+
}, "ContentVariants_component_updateCookieAndStylesScriptStr_useComputed_FtJXWpnoDYg", [
|
|
4080
4018
|
props
|
|
4081
4019
|
]));
|
|
4082
4020
|
const hideVariantsStyleString = useComputedQrl(/* @__PURE__ */ inlinedQrl(() => {
|
|
@@ -4133,11 +4071,11 @@ const ContentVariants = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl(
|
|
|
4133
4071
|
}, 3, "XM_1"),
|
|
4134
4072
|
/* @__PURE__ */ _jsxC(InlinedScript, {
|
|
4135
4073
|
get scriptStr() {
|
|
4136
|
-
return
|
|
4074
|
+
return updateCookieAndStylesScriptStr.value;
|
|
4137
4075
|
},
|
|
4138
4076
|
[_IMMUTABLE]: {
|
|
4139
4077
|
scriptStr: _fnSignal((p0) => p0.value, [
|
|
4140
|
-
|
|
4078
|
+
updateCookieAndStylesScriptStr
|
|
4141
4079
|
], "p0.value")
|
|
4142
4080
|
}
|
|
4143
4081
|
}, 3, "XM_2"),
|
|
@@ -4145,9 +4083,6 @@ const ContentVariants = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl(
|
|
|
4145
4083
|
return /* @__PURE__ */ _jsxC(ContentComponent, {
|
|
4146
4084
|
content: variant,
|
|
4147
4085
|
showContent: false,
|
|
4148
|
-
get classNameProp() {
|
|
4149
|
-
return void 0;
|
|
4150
|
-
},
|
|
4151
4086
|
get model() {
|
|
4152
4087
|
return props.model;
|
|
4153
4088
|
},
|
|
@@ -4191,7 +4126,6 @@ const ContentVariants = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl(
|
|
|
4191
4126
|
canTrack: _fnSignal((p0) => p0.canTrack, [
|
|
4192
4127
|
props
|
|
4193
4128
|
], "p0.canTrack"),
|
|
4194
|
-
classNameProp: _IMMUTABLE,
|
|
4195
4129
|
context: _fnSignal((p0) => p0.context, [
|
|
4196
4130
|
props
|
|
4197
4131
|
], "p0.context"),
|
|
@@ -4226,10 +4160,6 @@ const ContentVariants = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl(
|
|
|
4226
4160
|
get content() {
|
|
4227
4161
|
return defaultContent.value;
|
|
4228
4162
|
},
|
|
4229
|
-
get classNameProp() {
|
|
4230
|
-
var _a;
|
|
4231
|
-
return `variant-${(_a = props.content) == null ? void 0 : _a.id}`;
|
|
4232
|
-
},
|
|
4233
4163
|
showContent: true,
|
|
4234
4164
|
get model() {
|
|
4235
4165
|
return props.model;
|
|
@@ -4274,12 +4204,6 @@ const ContentVariants = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl(
|
|
|
4274
4204
|
canTrack: _fnSignal((p0) => p0.canTrack, [
|
|
4275
4205
|
props
|
|
4276
4206
|
], "p0.canTrack"),
|
|
4277
|
-
classNameProp: _fnSignal((p0) => {
|
|
4278
|
-
var _a;
|
|
4279
|
-
return `variant-${(_a = p0.content) == null ? void 0 : _a.id}`;
|
|
4280
|
-
}, [
|
|
4281
|
-
props
|
|
4282
|
-
], "`variant-${p0.content?.id}`"),
|
|
4283
4207
|
content: _fnSignal((p0) => p0.value, [
|
|
4284
4208
|
defaultContent
|
|
4285
4209
|
], "p0.value"),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@builder.io/sdk-qwik",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.5",
|
|
4
4
|
"description": "Builder.io Qwik SDK",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./lib/edge/index.qwik.cjs",
|
|
@@ -90,6 +90,7 @@
|
|
|
90
90
|
},
|
|
91
91
|
"scripts": {
|
|
92
92
|
"release": "npm publish",
|
|
93
|
+
"build-inline-fns": "yarn g:build-inline-fns",
|
|
93
94
|
"typecheck": "tsc --noEmit",
|
|
94
95
|
"tsc": "tsc",
|
|
95
96
|
"build": "nx run-many -p @builder.io/sdk-qwik -t tsc build:node build:edge build:browser",
|
|
@@ -115,8 +116,14 @@
|
|
|
115
116
|
},
|
|
116
117
|
"nx": {
|
|
117
118
|
"targets": {
|
|
119
|
+
"build-inline-fns": {
|
|
120
|
+
"dependsOn": [
|
|
121
|
+
"^build:qwik"
|
|
122
|
+
]
|
|
123
|
+
},
|
|
118
124
|
"build": {
|
|
119
125
|
"dependsOn": [
|
|
126
|
+
"build-inline-fns",
|
|
120
127
|
"^build:qwik",
|
|
121
128
|
"^build"
|
|
122
129
|
],
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { BuilderBlock } from "../../types/builder-block.js";
|
|
1
2
|
export interface VideoProps {
|
|
2
3
|
attributes?: any;
|
|
3
4
|
video?: string;
|
|
@@ -14,6 +15,9 @@ export interface VideoProps {
|
|
|
14
15
|
position?: "center" | "top" | "left" | "right" | "bottom" | "top left" | "top right" | "bottom left" | "bottom right";
|
|
15
16
|
posterImage?: string;
|
|
16
17
|
lazyLoad?: boolean;
|
|
18
|
+
children?: any;
|
|
19
|
+
fitContent?: boolean;
|
|
20
|
+
builderBlock?: BuilderBlock;
|
|
17
21
|
}
|
|
18
22
|
export declare const Video: import("@builder.io/qwik").Component<VideoProps>;
|
|
19
23
|
export default Video;
|
|
@@ -2,6 +2,6 @@ import type { BuilderContent } from '../../types/builder-content.js';
|
|
|
2
2
|
import type { Nullable } from '../../types/typescript.js';
|
|
3
3
|
import type { ContentProps } from './content.types.js';
|
|
4
4
|
export declare const getContextStateInitialValue: ({ content, data, locale }: Pick<ContentProps, 'content' | 'data' | 'locale'>) => {
|
|
5
|
-
|
|
5
|
+
locale?: string | undefined;
|
|
6
6
|
};
|
|
7
7
|
export declare const getContentInitialValue: ({ content, data }: Pick<ContentProps, 'content' | 'data'>) => Nullable<BuilderContent>;
|
|
@@ -2,10 +2,6 @@ import type { BuilderRenderState } from '../../context/types.js';
|
|
|
2
2
|
import type { EnforcePartials } from '../../types/enforced-partials.js';
|
|
3
3
|
import type { ContentVariantsPrps } from '../content-variants/content-variants.types.js';
|
|
4
4
|
interface InternalRenderProps {
|
|
5
|
-
/**
|
|
6
|
-
* TO-DO: improve qwik generator to not remap this name for non-HTML tags, then name it `className`
|
|
7
|
-
*/
|
|
8
|
-
classNameProp: string | undefined;
|
|
9
5
|
showContent: boolean;
|
|
10
6
|
isSsrAbTest: boolean;
|
|
11
7
|
}
|
|
@@ -24,7 +24,7 @@ export declare const getVariants: (content: Nullable<BuilderContent>) => {
|
|
|
24
24
|
breakpoints?: import("../../types/typescript.js").Nullable<import("../../types/builder-content.js").Breakpoints>;
|
|
25
25
|
} | undefined;
|
|
26
26
|
}[];
|
|
27
|
-
export declare const
|
|
27
|
+
export declare const checkShouldRenderVariants: ({ canTrack, content }: {
|
|
28
28
|
canTrack: Nullable<boolean>;
|
|
29
29
|
content: Nullable<BuilderContent>;
|
|
30
30
|
}) => boolean;
|
|
@@ -33,8 +33,8 @@ type VariantData = {
|
|
|
33
33
|
testRatio?: number;
|
|
34
34
|
};
|
|
35
35
|
export declare const getScriptString: () => string;
|
|
36
|
-
export declare const
|
|
37
|
-
export declare const
|
|
36
|
+
export declare const getUpdateCookieAndStylesScript: (variants: VariantData[], contentId: string) => string;
|
|
37
|
+
export declare const getUpdateVariantVisibilityScript: ({ contentId, variationId }: {
|
|
38
38
|
variationId: string;
|
|
39
39
|
contentId: string;
|
|
40
40
|
}) => string;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WARNING: This file contains functions that get stringified and inlined into the HTML at build-time.
|
|
3
|
+
* They cannot import anything.
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* For more information on how this works,
|
|
7
|
+
* see our [SSR A/B Test Docs](https://github.com/BuilderIO/builder/tree/main/packages/sdks/src/SSR_AB_TEST.md)
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* For more information on how this works,
|
|
11
|
+
* see our [SSR A/B Test Docs](https://github.com/BuilderIO/builder/tree/main/packages/sdks/src/SSR_AB_TEST.md)
|
|
12
|
+
*/
|
|
13
|
+
export declare const UPDATE_COOKIES_AND_STYLES_SCRIPT = "function updateCookiesAndStyles(contentId, variants, isHydrationTarget) {\n function getAndSetVariantId() {\n function setCookie(name, value, days) {\n let expires = '';\n if (days) {\n const date = new Date();\n date.setTime(date.getTime() + days * 24 * 60 * 60 * 1000);\n expires = '; expires=' + date.toUTCString();\n }\n document.cookie = name + '=' + (value || '') + expires + '; path=/' + '; Secure; SameSite=None';\n }\n function getCookie(name) {\n const nameEQ = name + '=';\n const ca = document.cookie.split(';');\n for (let i = 0; i < ca.length; i++) {\n let c = ca[i];\n while (c.charAt(0) === ' ') c = c.substring(1, c.length);\n if (c.indexOf(nameEQ) === 0) return c.substring(nameEQ.length, c.length);\n }\n return null;\n }\n const cookieName = `builder.tests.${contentId}`;\n const variantInCookie = getCookie(cookieName);\n const availableIDs = variants.map(vr => vr.id).concat(contentId);\n if (variantInCookie && availableIDs.includes(variantInCookie)) {\n return variantInCookie;\n }\n let n = 0;\n const random = Math.random();\n for (let i = 0; i < variants.length; i++) {\n const variant = variants[i];\n const testRatio = variant.testRatio;\n n += testRatio;\n if (random < n) {\n setCookie(cookieName, variant.id);\n return variant.id;\n }\n }\n setCookie(cookieName, contentId);\n return contentId;\n }\n const winningVariantId = getAndSetVariantId();\n const styleEl = document.currentScript?.previousElementSibling;\n if (isHydrationTarget) {\n styleEl.remove();\n const thisScriptEl = document.currentScript;\n thisScriptEl?.remove();\n } else {\n const newStyleStr = variants.concat({\n id: contentId\n }).filter(variant => variant.id !== winningVariantId).map(value => {\n return `.variant-${value.id} { display: none; }\n `;\n }).join('');\n styleEl.innerHTML = newStyleStr;\n }\n}";
|
|
14
|
+
export declare const UPDATE_VARIANT_VISIBILITY_SCRIPT = "function updateVariantVisibility(variantContentId, defaultContentId, isHydrationTarget) {\n if (!navigator.cookieEnabled) {\n return;\n }\n function getCookie(name) {\n const nameEQ = name + '=';\n const ca = document.cookie.split(';');\n for (let i = 0; i < ca.length; i++) {\n let c = ca[i];\n while (c.charAt(0) === ' ') c = c.substring(1, c.length);\n if (c.indexOf(nameEQ) === 0) return c.substring(nameEQ.length, c.length);\n }\n return null;\n }\n const cookieName = `builder.tests.${defaultContentId}`;\n const winningVariant = getCookie(cookieName);\n const parentDiv = document.currentScript?.parentElement;\n const isDefaultContent = variantContentId === defaultContentId;\n const isWinningVariant = winningVariant === variantContentId;\n if (isWinningVariant && !isDefaultContent) {\n parentDiv?.removeAttribute('hidden');\n parentDiv?.removeAttribute('aria-hidden');\n } else if (!isWinningVariant && isDefaultContent) {\n parentDiv?.setAttribute('hidden', 'true');\n parentDiv?.setAttribute('aria-hidden', 'true');\n }\n if (isHydrationTarget) {\n if (!isWinningVariant) {\n parentDiv?.remove();\n }\n const thisScriptEl = document.currentScript;\n thisScriptEl?.remove();\n }\n return;\n}";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const SDK_VERSION = "0.7.
|
|
1
|
+
export declare const SDK_VERSION = "0.7.5";
|