@builder.io/sdk-qwik 0.7.2 → 0.7.4

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.
@@ -2674,6 +2674,8 @@ const componentInfo = {
2674
2674
  ]
2675
2675
  };
2676
2676
  const Video = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((props) => {
2677
+ var _a, _b, _c, _d, _e, _f, _g;
2678
+ _jsxBranch();
2677
2679
  const videoProps = useComputedQrl(/* @__PURE__ */ inlinedQrl(() => {
2678
2680
  const [props2] = useLexicalScope();
2679
2681
  return {
@@ -2697,43 +2699,83 @@ const Video = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((props) =>
2697
2699
  props
2698
2700
  ]));
2699
2701
  const spreadProps = useComputedQrl(/* @__PURE__ */ inlinedQrl(() => {
2700
- const [props2, videoProps2] = useLexicalScope();
2702
+ const [videoProps2] = useLexicalScope();
2701
2703
  return {
2702
- ...props2.attributes,
2703
2704
  ...videoProps2.value
2704
2705
  };
2705
2706
  }, "Video_component_spreadProps_useComputed_ZdLsx18NYH4", [
2706
- props,
2707
2707
  videoProps
2708
2708
  ]));
2709
- return /* @__PURE__ */ _jsxS("video", {
2710
- ...spreadProps.value
2711
- }, {
2712
- poster: _fnSignal((p0) => p0.posterImage, [
2713
- props
2714
- ], "p0.posterImage"),
2715
- preload: _fnSignal((p0) => p0.preload || "metadata", [
2716
- props
2717
- ], 'p0.preload||"metadata"'),
2718
- src: _fnSignal((p0) => p0.video || "no-src", [
2719
- props
2720
- ], 'p0.video||"no-src"'),
2721
- style: _fnSignal((p0) => {
2722
- var _a;
2723
- return {
2709
+ return /* @__PURE__ */ _jsxQ("div", null, {
2710
+ style: {
2711
+ position: "relative"
2712
+ }
2713
+ }, [
2714
+ /* @__PURE__ */ _jsxS("video", {
2715
+ ...spreadProps.value,
2716
+ children: !props.lazyLoad ? /* @__PURE__ */ _jsxQ("source", null, {
2717
+ src: _fnSignal((p0) => p0.video, [
2718
+ props
2719
+ ], "p0.video"),
2720
+ type: "video/mp4"
2721
+ }, null, 3, "j7_0") : null,
2722
+ style: {
2724
2723
  width: "100%",
2725
2724
  height: "100%",
2726
- ...(_a = p0.attributes) == null ? void 0 : _a.style,
2727
- objectFit: p0.fit,
2728
- objectPosition: p0.position,
2725
+ ...(_a = props.attributes) == null ? void 0 : _a.style,
2726
+ objectFit: props.fit,
2727
+ objectPosition: props.position,
2729
2728
  // Hack to get object fit to work as expected and
2730
2729
  // not have the video overflow
2731
- borderRadius: 1
2732
- };
2733
- }, [
2734
- props
2735
- ], '{width:"100%",height:"100%",...p0.attributes?.style,objectFit:p0.fit,objectPosition:p0.position,borderRadius:1}')
2736
- }, 0, "j7_0");
2730
+ zIndex: 2,
2731
+ borderRadius: "1px",
2732
+ ...props.aspectRatio ? {
2733
+ position: "absolute"
2734
+ } : null
2735
+ }
2736
+ }, {
2737
+ class: "builder-video",
2738
+ poster: _fnSignal((p0) => p0.posterImage, [
2739
+ props
2740
+ ], "p0.posterImage"),
2741
+ preload: _fnSignal((p0) => p0.preload || "metadata", [
2742
+ props
2743
+ ], 'p0.preload||"metadata"'),
2744
+ src: _fnSignal((p0) => p0.video || "no-src", [
2745
+ props
2746
+ ], 'p0.video||"no-src"')
2747
+ }, 0, null),
2748
+ props.aspectRatio && !(props.fitContent && ((_c = (_b = props.builderBlock) == null ? void 0 : _b.children) == null ? void 0 : _c.length)) ? /* @__PURE__ */ _jsxQ("div", null, {
2749
+ style: _fnSignal((p0) => ({
2750
+ width: "100%",
2751
+ paddingTop: p0.aspectRatio * 100 + "%",
2752
+ pointerEvents: "none",
2753
+ fontSize: "0px"
2754
+ }), [
2755
+ props
2756
+ ], '{width:"100%",paddingTop:p0.aspectRatio*100+"%",pointerEvents:"none",fontSize:"0px"}')
2757
+ }, null, 3, "j7_1") : null,
2758
+ ((_e = (_d = props.builderBlock) == null ? void 0 : _d.children) == null ? void 0 : _e.length) && props.fitContent ? /* @__PURE__ */ _jsxQ("div", null, {
2759
+ style: {
2760
+ display: "flex",
2761
+ flexDirection: "column",
2762
+ alignItems: "stretch"
2763
+ }
2764
+ }, /* @__PURE__ */ _jsxC(Slot, null, 3, "j7_2"), 1, "j7_3") : null,
2765
+ ((_g = (_f = props.builderBlock) == null ? void 0 : _f.children) == null ? void 0 : _g.length) && !props.fitContent ? /* @__PURE__ */ _jsxQ("div", null, {
2766
+ style: {
2767
+ pointerEvents: "none",
2768
+ display: "flex",
2769
+ flexDirection: "column",
2770
+ alignItems: "stretch",
2771
+ position: "absolute",
2772
+ top: "0",
2773
+ left: "0",
2774
+ width: "100%",
2775
+ height: "100%"
2776
+ }
2777
+ }, /* @__PURE__ */ _jsxC(Slot, null, 3, "j7_4"), 1, "j7_5") : null
2778
+ ], 1, "j7_6");
2737
2779
  }, "Video_component_qdcTZflYyoQ"));
2738
2780
  const getDefaultRegisteredComponents = () => [
2739
2781
  {
@@ -2799,12 +2841,16 @@ const serializeComponentInfo = ({ inputs, ...info }) => ({
2799
2841
  [key]: serializeValue(value)
2800
2842
  }), {}))
2801
2843
  });
2844
+ 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}";
2845
+ 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}";
2846
+ const UPDATE_COOKIES_AND_STYLES_SCRIPT_NAME = "builderIoAbTest";
2847
+ const UPDATE_VARIANT_VISIBILITY_SCRIPT_FN_NAME = "builderIoRenderContent";
2802
2848
  const getVariants = (content) => Object.values((content == null ? void 0 : content.variations) || {}).map((variant) => ({
2803
2849
  ...variant,
2804
2850
  testVariationId: variant.id,
2805
2851
  id: content == null ? void 0 : content.id
2806
2852
  }));
2807
- const checkShouldRunVariants = ({ canTrack, content }) => {
2853
+ const checkShouldRenderVariants = ({ canTrack, content }) => {
2808
2854
  const hasVariants = getVariants(content).length > 0;
2809
2855
  if (!hasVariants)
2810
2856
  return false;
@@ -2814,131 +2860,27 @@ const checkShouldRunVariants = ({ canTrack, content }) => {
2814
2860
  return false;
2815
2861
  return true;
2816
2862
  };
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
2863
  const getIsHydrationTarget = (target) => target === "react" || target === "reactNative";
2915
2864
  const isHydrationTarget = getIsHydrationTarget(TARGET);
2916
- const AB_TEST_FN_NAME = "builderIoAbTest";
2917
- const CONTENT_FN_NAME = "builderIoRenderContent";
2918
- const getScriptString = () => {
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}
2865
+ const getScriptString = () => `
2866
+ window.${UPDATE_COOKIES_AND_STYLES_SCRIPT_NAME} = ${UPDATE_COOKIES_AND_STYLES_SCRIPT}
2867
+ window.${UPDATE_VARIANT_VISIBILITY_SCRIPT_FN_NAME} = ${UPDATE_VARIANT_VISIBILITY_SCRIPT}
2924
2868
  `;
2925
- };
2926
- const getVariantsScriptString = (variants, contentId) => {
2927
- return `
2928
- window.${AB_TEST_FN_NAME}("${contentId}",${JSON.stringify(variants)}, ${isHydrationTarget})`;
2929
- };
2930
- const getRenderContentScriptString = ({ contentId, variationId }) => {
2931
- return `
2932
- window.${CONTENT_FN_NAME}("${variationId}", "${contentId}", ${isHydrationTarget})`;
2933
- };
2869
+ const getUpdateCookieAndStylesScript = (variants, contentId) => `
2870
+ window.${UPDATE_COOKIES_AND_STYLES_SCRIPT_NAME}(
2871
+ "${contentId}",${JSON.stringify(variants)}, ${isHydrationTarget}
2872
+ )`;
2873
+ const getUpdateVariantVisibilityScript = ({ contentId, variationId }) => `window.${UPDATE_VARIANT_VISIBILITY_SCRIPT_FN_NAME}(
2874
+ "${variationId}", "${contentId}", ${isHydrationTarget}
2875
+ )`;
2934
2876
  const InlinedScript = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((props) => {
2935
2877
  return /* @__PURE__ */ _jsxQ("script", null, {
2936
2878
  dangerouslySetInnerHTML: _fnSignal((p0) => p0.scriptStr, [
2937
2879
  props
2938
2880
  ], "p0.scriptStr"),
2939
- id: _fnSignal((p0) => p0.id, [
2881
+ id: _fnSignal((p0) => p0.id || "", [
2940
2882
  props
2941
- ], "p0.id")
2883
+ ], 'p0.id||""')
2942
2884
  }, null, 3, "WO_0");
2943
2885
  }, "InlinedScript_component_hwThBdhA8rw"));
2944
2886
  function getGlobalThis() {
@@ -3318,7 +3260,7 @@ const getInteractionPropertiesForEvent = (event) => {
3318
3260
  }
3319
3261
  };
3320
3262
  };
3321
- const SDK_VERSION = "0.7.2";
3263
+ const SDK_VERSION = "0.7.4";
3322
3264
  const registry = {};
3323
3265
  function register(type, info) {
3324
3266
  let typeList = registry[type];
@@ -3576,7 +3518,7 @@ const emitStateUpdate = function emitStateUpdate2(props, state, elementRef) {
3576
3518
  }));
3577
3519
  };
3578
3520
  const EnableEditor = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((props) => {
3579
- var _a, _b, _c;
3521
+ var _a, _b, _c, _d, _e;
3580
3522
  _jsxBranch();
3581
3523
  const elementRef = useSignal();
3582
3524
  const state = useStore({
@@ -3636,7 +3578,7 @@ const EnableEditor = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((pr
3636
3578
  state
3637
3579
  ]));
3638
3580
  useOn("qvisible", /* @__PURE__ */ inlinedQrl((event, element) => {
3639
- var _a2, _b2, _c2, _d;
3581
+ var _a2, _b2, _c2, _d2;
3640
3582
  if (isBrowser()) {
3641
3583
  if (isEditing() && element)
3642
3584
  element.dispatchEvent(new CustomEvent("initeditingbldr"));
@@ -3644,7 +3586,7 @@ const EnableEditor = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((pr
3644
3586
  if (shouldTrackImpression) {
3645
3587
  const variationId = (_b2 = element.attributes.getNamedItem("variationId")) == null ? void 0 : _b2.value;
3646
3588
  const contentId = (_c2 = element.attributes.getNamedItem("contentId")) == null ? void 0 : _c2.value;
3647
- const apiKeyProp = (_d = element.attributes.getNamedItem("apiKey")) == null ? void 0 : _d.value;
3589
+ const apiKeyProp = (_d2 = element.attributes.getNamedItem("apiKey")) == null ? void 0 : _d2.value;
3648
3590
  _track({
3649
3591
  type: "impression",
3650
3592
  canTrack: true,
@@ -3742,7 +3684,7 @@ const EnableEditor = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((pr
3742
3684
  hidden: true,
3743
3685
  "aria-hidden": true
3744
3686
  },
3745
- class: props.classNameProp
3687
+ class: `variant-${((_d = props.content) == null ? void 0 : _d.testVariationId) || ((_e = props.content) == null ? void 0 : _e.id)}`
3746
3688
  }, /* @__PURE__ */ _jsxC(Slot, null, 3, "06_0")) : null
3747
3689
  }, 1, "06_1");
3748
3690
  }, "EnableEditor_component_ko1mO8oaj8k"));
@@ -3906,7 +3848,7 @@ const ContentComponent = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl
3906
3848
  ...serializeComponentInfo(info)
3907
3849
  }
3908
3850
  }), {}),
3909
- scriptStr: getRenderContentScriptString({
3851
+ scriptStr: getUpdateVariantVisibilityScript({
3910
3852
  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion, @typescript-eslint/no-non-null-asserted-optional-chain
3911
3853
  variationId: (_a = props.content) == null ? void 0 : _a.testVariationId,
3912
3854
  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion, @typescript-eslint/no-non-null-asserted-optional-chain
@@ -3943,9 +3885,6 @@ const ContentComponent = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl
3943
3885
  get enrich() {
3944
3886
  return props.enrich;
3945
3887
  },
3946
- get classNameProp() {
3947
- return props.classNameProp;
3948
- },
3949
3888
  get showContent() {
3950
3889
  return props.showContent;
3951
3890
  },
@@ -4034,9 +3973,6 @@ const ContentComponent = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl
4034
3973
  canTrack: _fnSignal((p0) => p0.canTrack, [
4035
3974
  props
4036
3975
  ], "p0.canTrack"),
4037
- classNameProp: _fnSignal((p0) => p0.classNameProp, [
4038
- props
4039
- ], "p0.classNameProp"),
4040
3976
  content: _fnSignal((p0) => p0.content, [
4041
3977
  props
4042
3978
  ], "p0.content"),
@@ -4064,19 +4000,19 @@ const ContentComponent = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl
4064
4000
  const ContentVariants = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((props) => {
4065
4001
  _jsxBranch();
4066
4002
  const state = useStore({
4067
- shouldRenderVariants: checkShouldRunVariants({
4003
+ shouldRenderVariants: checkShouldRenderVariants({
4068
4004
  canTrack: getDefaultCanTrack(props.canTrack),
4069
4005
  content: props.content
4070
4006
  })
4071
4007
  });
4072
- const variantScriptStr = useComputedQrl(/* @__PURE__ */ inlinedQrl(() => {
4008
+ const updateCookieAndStylesScriptStr = useComputedQrl(/* @__PURE__ */ inlinedQrl(() => {
4073
4009
  var _a;
4074
4010
  const [props2] = useLexicalScope();
4075
- return getVariantsScriptString(getVariants(props2.content).map((value) => ({
4011
+ return getUpdateCookieAndStylesScript(getVariants(props2.content).map((value) => ({
4076
4012
  id: value.testVariationId,
4077
4013
  testRatio: value.testRatio
4078
4014
  })), ((_a = props2.content) == null ? void 0 : _a.id) || "");
4079
- }, "ContentVariants_component_variantScriptStr_useComputed_ldWqWafT8Ww", [
4015
+ }, "ContentVariants_component_updateCookieAndStylesScriptStr_useComputed_FtJXWpnoDYg", [
4080
4016
  props
4081
4017
  ]));
4082
4018
  const hideVariantsStyleString = useComputedQrl(/* @__PURE__ */ inlinedQrl(() => {
@@ -4133,11 +4069,11 @@ const ContentVariants = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl(
4133
4069
  }, 3, "XM_1"),
4134
4070
  /* @__PURE__ */ _jsxC(InlinedScript, {
4135
4071
  get scriptStr() {
4136
- return variantScriptStr.value;
4072
+ return updateCookieAndStylesScriptStr.value;
4137
4073
  },
4138
4074
  [_IMMUTABLE]: {
4139
4075
  scriptStr: _fnSignal((p0) => p0.value, [
4140
- variantScriptStr
4076
+ updateCookieAndStylesScriptStr
4141
4077
  ], "p0.value")
4142
4078
  }
4143
4079
  }, 3, "XM_2"),
@@ -4145,9 +4081,6 @@ const ContentVariants = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl(
4145
4081
  return /* @__PURE__ */ _jsxC(ContentComponent, {
4146
4082
  content: variant,
4147
4083
  showContent: false,
4148
- get classNameProp() {
4149
- return void 0;
4150
- },
4151
4084
  get model() {
4152
4085
  return props.model;
4153
4086
  },
@@ -4191,7 +4124,6 @@ const ContentVariants = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl(
4191
4124
  canTrack: _fnSignal((p0) => p0.canTrack, [
4192
4125
  props
4193
4126
  ], "p0.canTrack"),
4194
- classNameProp: _IMMUTABLE,
4195
4127
  context: _fnSignal((p0) => p0.context, [
4196
4128
  props
4197
4129
  ], "p0.context"),
@@ -4226,10 +4158,6 @@ const ContentVariants = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl(
4226
4158
  get content() {
4227
4159
  return defaultContent.value;
4228
4160
  },
4229
- get classNameProp() {
4230
- var _a;
4231
- return `variant-${(_a = props.content) == null ? void 0 : _a.id}`;
4232
- },
4233
4161
  showContent: true,
4234
4162
  get model() {
4235
4163
  return props.model;
@@ -4274,12 +4202,6 @@ const ContentVariants = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl(
4274
4202
  canTrack: _fnSignal((p0) => p0.canTrack, [
4275
4203
  props
4276
4204
  ], "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
4205
  content: _fnSignal((p0) => p0.value, [
4284
4206
  defaultContent
4285
4207
  ], "p0.value"),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@builder.io/sdk-qwik",
3
- "version": "0.7.2",
3
+ "version": "0.7.4",
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,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 checkShouldRunVariants: ({ canTrack, content }: {
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 getVariantsScriptString: (variants: VariantData[], contentId: string) => string;
37
- export declare const getRenderContentScriptString: ({ contentId, variationId }: {
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.2";
1
+ export declare const SDK_VERSION = "0.7.4";