@builder.io/sdk-qwik 0.4.4 → 0.4.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.
Files changed (36) hide show
  1. package/lib/index.qwik.cjs +474 -392
  2. package/lib/index.qwik.mjs +475 -393
  3. package/package.json +1 -1
  4. package/types/blocks/text/text.d.ts +1 -1
  5. package/types/components/block/block.d.ts +10 -0
  6. package/types/components/block/block.helpers.d.ts +12 -0
  7. package/types/components/block/components/block-styles.d.ts +8 -0
  8. package/types/components/block/components/component-ref.d.ts +21 -0
  9. package/types/components/block/components/component.d.ts +21 -0
  10. package/types/components/block/components/repeated-block.d.ts +10 -0
  11. package/types/components/block/types.d.ts +6 -0
  12. package/types/components/blocks/blocks-wrapper.d.ts +15 -0
  13. package/types/components/blocks/blocks.d.ts +9 -0
  14. package/types/components/content/builder-editing.d.ts +23 -0
  15. package/types/components/content/components/content-styles.d.ts +8 -0
  16. package/types/components/content/components/content-styles.helpers.d.ts +15 -0
  17. package/types/components/content/components/enable-editor.d.ts +23 -0
  18. package/types/components/content/components/render-styles.d.ts +8 -0
  19. package/types/components/content/components/render-styles.helpers.d.ts +15 -0
  20. package/types/components/content/content.d.ts +7 -0
  21. package/types/components/content/content.helpers.d.ts +7 -0
  22. package/types/components/content/content.types.d.ts +38 -0
  23. package/types/components/content/index.d.ts +1 -0
  24. package/types/components/content/wrap-component-ref.d.ts +6 -0
  25. package/types/components/content-variants/content-variants.d.ts +3 -0
  26. package/types/components/content-variants/helpers.d.ts +17 -0
  27. package/types/components/inlined-script.d.ts +6 -0
  28. package/types/components/inlined-styles.d.ts +6 -0
  29. package/types/components/render-content/render-content.types.d.ts +9 -23
  30. package/types/components/render-content-variants/helpers.d.ts +27 -3
  31. package/types/components/render-content-variants/render-content-variants.d.ts +8 -2
  32. package/types/components/render-content-variants/render-content-variants.types.d.ts +20 -0
  33. package/types/constants/sdk-version.d.ts +1 -1
  34. package/types/types/builder-props.d.ts +10 -0
  35. package/types/types/enforced-partials.d.ts +21 -0
  36. package/types/types/typescript.d.ts +3 -0
@@ -34,6 +34,16 @@ const STYLES$3 = `
34
34
  all: unset;
35
35
  }
36
36
  `;
37
+ const InlinedStyles = /* @__PURE__ */ qwik.componentQrl(/* @__PURE__ */ qwik.inlinedQrl((props) => {
38
+ return /* @__PURE__ */ qwik._jsxQ("style", null, {
39
+ dangerouslySetInnerHTML: qwik._fnSignal((p0) => p0.styles, [
40
+ props
41
+ ], "p0.styles"),
42
+ id: qwik._fnSignal((p0) => p0.id, [
43
+ props
44
+ ], "p0.id")
45
+ }, null, 3, "NG_0");
46
+ }, "InlinedStyles_component_IOsg46hMexk"));
37
47
  const BuilderContext = qwik.createContextId("Builder");
38
48
  const TARGET = "qwik";
39
49
  function isBrowser() {
@@ -196,16 +206,6 @@ const createCssClass = ({ mediaQuery, className, styles }) => {
196
206
  else
197
207
  return cssClass;
198
208
  };
199
- const RenderInlinedStyles = /* @__PURE__ */ qwik.componentQrl(/* @__PURE__ */ qwik.inlinedQrl((props) => {
200
- return /* @__PURE__ */ qwik._jsxQ("style", null, {
201
- dangerouslySetInnerHTML: qwik._fnSignal((p0) => p0.styles, [
202
- props
203
- ], "p0.styles"),
204
- id: qwik._fnSignal((p0) => p0.id, [
205
- props
206
- ], "p0.id")
207
- }, null, 3, "zz_0");
208
- }, "RenderInlinedStyles_component_ejNQtXd1ahM"));
209
209
  const BlockStyles = /* @__PURE__ */ qwik.componentQrl(/* @__PURE__ */ qwik.inlinedQrl((props) => {
210
210
  qwik._jsxBranch();
211
211
  const useBlock = qwik.useComputedQrl(/* @__PURE__ */ qwik.inlinedQrl(() => {
@@ -266,7 +266,7 @@ const BlockStyles = /* @__PURE__ */ qwik.componentQrl(/* @__PURE__ */ qwik.inlin
266
266
  useBlock
267
267
  ]));
268
268
  return /* @__PURE__ */ qwik._jsxC(jsxRuntime.Fragment, {
269
- children: css.value && canShowBlock.value ? /* @__PURE__ */ qwik._jsxC(RenderInlinedStyles, {
269
+ children: css.value && canShowBlock.value ? /* @__PURE__ */ qwik._jsxC(InlinedStyles, {
270
270
  get styles() {
271
271
  return css.value;
272
272
  },
@@ -847,7 +847,7 @@ const Columns = /* @__PURE__ */ qwik.componentQrl(/* @__PURE__ */ qwik.inlinedQr
847
847
  columnsCssVars
848
848
  ], "p0.value")
849
849
  }, [
850
- /* @__PURE__ */ qwik._jsxC(RenderInlinedStyles, {
850
+ /* @__PURE__ */ qwik._jsxC(InlinedStyles, {
851
851
  get styles() {
852
852
  return columnsStyles.value;
853
853
  },
@@ -1088,6 +1088,194 @@ const SectionComponent = /* @__PURE__ */ qwik.componentQrl(/* @__PURE__ */ qwik.
1088
1088
  children: /* @__PURE__ */ qwik._jsxC(qwik.Slot, null, 3, "2Y_0")
1089
1089
  }, null, 0, "2Y_1");
1090
1090
  }, "SectionComponent_component_ZWF9iD5WeLg"));
1091
+ const MSG_PREFIX = "[Builder.io]: ";
1092
+ const logger = {
1093
+ log: (...message) => console.log(MSG_PREFIX, ...message),
1094
+ error: (...message) => console.error(MSG_PREFIX, ...message),
1095
+ warn: (...message) => console.warn(MSG_PREFIX, ...message),
1096
+ debug: (...message) => console.debug(MSG_PREFIX, ...message)
1097
+ };
1098
+ const getTopLevelDomain = (host) => {
1099
+ if (host === "localhost" || host === "127.0.0.1")
1100
+ return host;
1101
+ const parts = host.split(".");
1102
+ if (parts.length > 2)
1103
+ return parts.slice(1).join(".");
1104
+ return host;
1105
+ };
1106
+ const getCookieSync = ({ name, canTrack }) => {
1107
+ try {
1108
+ if (!canTrack)
1109
+ return void 0;
1110
+ return document.cookie.split("; ").find((row) => row.startsWith(`${name}=`))?.split("=")[1];
1111
+ } catch (err) {
1112
+ logger.warn("[COOKIE] GET error: ", err?.message || err);
1113
+ return void 0;
1114
+ }
1115
+ };
1116
+ const getCookie = async (args) => getCookieSync(args);
1117
+ const stringifyCookie = (cookie) => cookie.map(([key, value]) => value ? `${key}=${value}` : key).filter(checkIsDefined).join("; ");
1118
+ const SECURE_CONFIG = [
1119
+ [
1120
+ "secure",
1121
+ ""
1122
+ ],
1123
+ [
1124
+ "SameSite",
1125
+ "None"
1126
+ ]
1127
+ ];
1128
+ const createCookieString = ({ name, value, expires }) => {
1129
+ const secure = isBrowser() ? location.protocol === "https:" : true;
1130
+ const secureObj = secure ? SECURE_CONFIG : [
1131
+ []
1132
+ ];
1133
+ const expiresObj = expires ? [
1134
+ [
1135
+ "expires",
1136
+ expires.toUTCString()
1137
+ ]
1138
+ ] : [
1139
+ []
1140
+ ];
1141
+ const cookieValue = [
1142
+ [
1143
+ name,
1144
+ value
1145
+ ],
1146
+ ...expiresObj,
1147
+ [
1148
+ "path",
1149
+ "/"
1150
+ ],
1151
+ [
1152
+ "domain",
1153
+ getTopLevelDomain(window.location.hostname)
1154
+ ],
1155
+ ...secureObj
1156
+ ];
1157
+ const cookie = stringifyCookie(cookieValue);
1158
+ return cookie;
1159
+ };
1160
+ const setCookie = async ({ name, value, expires, canTrack }) => {
1161
+ try {
1162
+ if (!canTrack)
1163
+ return;
1164
+ const cookie = createCookieString({
1165
+ name,
1166
+ value,
1167
+ expires
1168
+ });
1169
+ document.cookie = cookie;
1170
+ } catch (err) {
1171
+ logger.warn("[COOKIE] SET error: ", err?.message || err);
1172
+ }
1173
+ };
1174
+ const BUILDER_STORE_PREFIX = "builder.tests";
1175
+ const getContentTestKey = (id) => `${BUILDER_STORE_PREFIX}.${id}`;
1176
+ const getContentVariationCookie = ({ contentId }) => getCookie({
1177
+ name: getContentTestKey(contentId),
1178
+ canTrack: true
1179
+ });
1180
+ const getContentVariationCookieSync = ({ contentId }) => getCookieSync({
1181
+ name: getContentTestKey(contentId),
1182
+ canTrack: true
1183
+ });
1184
+ const setContentVariationCookie = ({ contentId, value }) => setCookie({
1185
+ name: getContentTestKey(contentId),
1186
+ value,
1187
+ canTrack: true
1188
+ });
1189
+ const checkIsBuilderContentWithVariations = (item) => checkIsDefined(item.id) && checkIsDefined(item.variations) && Object.keys(item.variations).length > 0;
1190
+ const getRandomVariationId = ({ id, variations }) => {
1191
+ let n = 0;
1192
+ const random = Math.random();
1193
+ for (const id2 in variations) {
1194
+ const testRatio = variations[id2]?.testRatio;
1195
+ n += testRatio;
1196
+ if (random < n)
1197
+ return id2;
1198
+ }
1199
+ return id;
1200
+ };
1201
+ const getAndSetVariantId = (args) => {
1202
+ const randomVariationId = getRandomVariationId(args);
1203
+ setContentVariationCookie({
1204
+ contentId: args.id,
1205
+ value: randomVariationId
1206
+ }).catch((err) => {
1207
+ logger.error("could not store A/B test variation: ", err);
1208
+ });
1209
+ return randomVariationId;
1210
+ };
1211
+ const getTestFields = ({ item, testGroupId }) => {
1212
+ const variationValue = item.variations[testGroupId];
1213
+ if (testGroupId === item.id || !variationValue)
1214
+ return {
1215
+ testVariationId: item.id,
1216
+ testVariationName: "Default"
1217
+ };
1218
+ else
1219
+ return {
1220
+ data: variationValue.data,
1221
+ testVariationId: variationValue.id,
1222
+ testVariationName: variationValue.name || (variationValue.id === item.id ? "Default" : "")
1223
+ };
1224
+ };
1225
+ const handleABTestingSync = ({ item, canTrack }) => {
1226
+ if (!canTrack)
1227
+ return item;
1228
+ if (!item)
1229
+ return void 0;
1230
+ if (!checkIsBuilderContentWithVariations(item))
1231
+ return item;
1232
+ const testGroupId = getContentVariationCookieSync({
1233
+ contentId: item.id
1234
+ }) || getAndSetVariantId({
1235
+ variations: item.variations,
1236
+ id: item.id
1237
+ });
1238
+ const variationValue = getTestFields({
1239
+ item,
1240
+ testGroupId
1241
+ });
1242
+ return {
1243
+ ...item,
1244
+ ...variationValue
1245
+ };
1246
+ };
1247
+ const handleABTesting = async ({ item, canTrack }) => {
1248
+ if (!canTrack)
1249
+ return item;
1250
+ if (!checkIsBuilderContentWithVariations(item))
1251
+ return item;
1252
+ const cookieValue = await getContentVariationCookie({
1253
+ contentId: item.id
1254
+ });
1255
+ const testGroupId = cookieValue || getAndSetVariantId({
1256
+ variations: item.variations,
1257
+ id: item.id
1258
+ });
1259
+ const variationValue = getTestFields({
1260
+ item,
1261
+ testGroupId
1262
+ });
1263
+ return {
1264
+ ...item,
1265
+ ...variationValue
1266
+ };
1267
+ };
1268
+ const getDefaultCanTrack = (canTrack) => checkIsDefined(canTrack) ? canTrack : true;
1269
+ const InlinedScript = /* @__PURE__ */ qwik.componentQrl(/* @__PURE__ */ qwik.inlinedQrl((props) => {
1270
+ return /* @__PURE__ */ qwik._jsxQ("script", null, {
1271
+ dangerouslySetInnerHTML: qwik._fnSignal((p0) => p0.scriptStr, [
1272
+ props
1273
+ ], "p0.scriptStr"),
1274
+ id: qwik._fnSignal((p0) => p0.id, [
1275
+ props
1276
+ ], "p0.id")
1277
+ }, null, 3, "WO_0");
1278
+ }, "InlinedScript_component_hwThBdhA8rw"));
1091
1279
  const componentInfo$a = {
1092
1280
  name: "Core:Button",
1093
1281
  image: "https://cdn.builder.io/api/v1/image/assets%2FIsxPKMo2gPRRKeakUztj1D6uqed2%2F81a15681c3e74df09677dfc57a615b13",
@@ -1636,9 +1824,9 @@ const Text = /* @__PURE__ */ qwik.componentQrl(/* @__PURE__ */ qwik.inlinedQrl((
1636
1824
  }
1637
1825
  }, {
1638
1826
  class: "builder-text",
1639
- dangerouslySetInnerHTML: qwik._fnSignal((p0) => p0.text, [
1827
+ dangerouslySetInnerHTML: qwik._fnSignal((p0) => p0.text?.toString(), [
1640
1828
  props
1641
- ], "p0.text")
1829
+ ], "p0.text?.toString()")
1642
1830
  }, null, 3, "yO_0");
1643
1831
  }, "Text_component_15p0cKUxgIE"));
1644
1832
  const componentInfo$3 = {
@@ -2071,201 +2259,23 @@ const getDefaultRegisteredComponents = () => [
2071
2259
  ...componentInfo$3
2072
2260
  }
2073
2261
  ];
2074
- const MSG_PREFIX = "[Builder.io]: ";
2075
- const logger = {
2076
- log: (...message) => console.log(MSG_PREFIX, ...message),
2077
- error: (...message) => console.error(MSG_PREFIX, ...message),
2078
- warn: (...message) => console.warn(MSG_PREFIX, ...message),
2079
- debug: (...message) => console.debug(MSG_PREFIX, ...message)
2080
- };
2081
- const getTopLevelDomain = (host) => {
2082
- if (host === "localhost" || host === "127.0.0.1")
2083
- return host;
2084
- const parts = host.split(".");
2085
- if (parts.length > 2)
2086
- return parts.slice(1).join(".");
2087
- return host;
2088
- };
2089
- const getCookieSync = ({ name, canTrack }) => {
2090
- try {
2091
- if (!canTrack)
2092
- return void 0;
2093
- return document.cookie.split("; ").find((row) => row.startsWith(`${name}=`))?.split("=")[1];
2094
- } catch (err) {
2095
- logger.warn("[COOKIE] GET error: ", err?.message || err);
2096
- return void 0;
2097
- }
2098
- };
2099
- const getCookie = async (args) => getCookieSync(args);
2100
- const stringifyCookie = (cookie) => cookie.map(([key, value]) => value ? `${key}=${value}` : key).filter(checkIsDefined).join("; ");
2101
- const SECURE_CONFIG = [
2102
- [
2103
- "secure",
2104
- ""
2105
- ],
2106
- [
2107
- "SameSite",
2108
- "None"
2109
- ]
2110
- ];
2111
- const createCookieString = ({ name, value, expires }) => {
2112
- const secure = isBrowser() ? location.protocol === "https:" : true;
2113
- const secureObj = secure ? SECURE_CONFIG : [
2114
- []
2115
- ];
2116
- const expiresObj = expires ? [
2117
- [
2118
- "expires",
2119
- expires.toUTCString()
2120
- ]
2121
- ] : [
2122
- []
2123
- ];
2124
- const cookieValue = [
2125
- [
2126
- name,
2127
- value
2128
- ],
2129
- ...expiresObj,
2130
- [
2131
- "path",
2132
- "/"
2133
- ],
2134
- [
2135
- "domain",
2136
- getTopLevelDomain(window.location.hostname)
2137
- ],
2138
- ...secureObj
2139
- ];
2140
- const cookie = stringifyCookie(cookieValue);
2141
- return cookie;
2142
- };
2143
- const setCookie = async ({ name, value, expires, canTrack }) => {
2144
- try {
2145
- if (!canTrack)
2146
- return;
2147
- const cookie = createCookieString({
2148
- name,
2149
- value,
2150
- expires
2151
- });
2152
- document.cookie = cookie;
2153
- } catch (err) {
2154
- logger.warn("[COOKIE] SET error: ", err?.message || err);
2155
- }
2156
- };
2157
- const BUILDER_STORE_PREFIX = "builder.tests";
2158
- const getContentTestKey = (id) => `${BUILDER_STORE_PREFIX}.${id}`;
2159
- const getContentVariationCookie = ({ contentId }) => getCookie({
2160
- name: getContentTestKey(contentId),
2161
- canTrack: true
2162
- });
2163
- const getContentVariationCookieSync = ({ contentId }) => getCookieSync({
2164
- name: getContentTestKey(contentId),
2165
- canTrack: true
2166
- });
2167
- const setContentVariationCookie = ({ contentId, value }) => setCookie({
2168
- name: getContentTestKey(contentId),
2169
- value,
2170
- canTrack: true
2171
- });
2172
- const checkIsBuilderContentWithVariations = (item) => checkIsDefined(item.id) && checkIsDefined(item.variations) && Object.keys(item.variations).length > 0;
2173
- const getRandomVariationId = ({ id, variations }) => {
2174
- let n = 0;
2175
- const random = Math.random();
2176
- for (const id2 in variations) {
2177
- const testRatio = variations[id2]?.testRatio;
2178
- n += testRatio;
2179
- if (random < n)
2180
- return id2;
2181
- }
2182
- return id;
2183
- };
2184
- const getAndSetVariantId = (args) => {
2185
- const randomVariationId = getRandomVariationId(args);
2186
- setContentVariationCookie({
2187
- contentId: args.id,
2188
- value: randomVariationId
2189
- }).catch((err) => {
2190
- logger.error("could not store A/B test variation: ", err);
2191
- });
2192
- return randomVariationId;
2193
- };
2194
- const getTestFields = ({ item, testGroupId }) => {
2195
- const variationValue = item.variations[testGroupId];
2196
- if (testGroupId === item.id || !variationValue)
2197
- return {
2198
- testVariationId: item.id,
2199
- testVariationName: "Default"
2200
- };
2201
- else
2202
- return {
2203
- data: variationValue.data,
2204
- testVariationId: variationValue.id,
2205
- testVariationName: variationValue.name || (variationValue.id === item.id ? "Default" : "")
2206
- };
2207
- };
2208
- const handleABTestingSync = ({ item, canTrack }) => {
2209
- if (!canTrack)
2210
- return item;
2211
- if (!item)
2212
- return void 0;
2213
- if (!checkIsBuilderContentWithVariations(item))
2214
- return item;
2215
- const testGroupId = getContentVariationCookieSync({
2216
- contentId: item.id
2217
- }) || getAndSetVariantId({
2218
- variations: item.variations,
2219
- id: item.id
2220
- });
2221
- const variationValue = getTestFields({
2222
- item,
2223
- testGroupId
2224
- });
2225
- return {
2226
- ...item,
2227
- ...variationValue
2228
- };
2229
- };
2230
- const handleABTesting = async ({ item, canTrack }) => {
2231
- if (!canTrack)
2232
- return item;
2233
- if (!checkIsBuilderContentWithVariations(item))
2234
- return item;
2235
- const cookieValue = await getContentVariationCookie({
2236
- contentId: item.id
2237
- });
2238
- const testGroupId = cookieValue || getAndSetVariantId({
2239
- variations: item.variations,
2240
- id: item.id
2241
- });
2242
- const variationValue = getTestFields({
2243
- item,
2244
- testGroupId
2245
- });
2246
- return {
2247
- ...item,
2248
- ...variationValue
2249
- };
2250
- };
2251
- const getDefaultCanTrack = (canTrack) => checkIsDefined(canTrack) ? canTrack : true;
2252
- function getGlobalThis() {
2253
- if (typeof globalThis !== "undefined")
2254
- return globalThis;
2255
- if (typeof window !== "undefined")
2256
- return window;
2257
- if (typeof global !== "undefined")
2258
- return global;
2259
- if (typeof self !== "undefined")
2260
- return self;
2261
- return globalThis;
2262
- }
2263
- function getFetch() {
2264
- const globalFetch = getGlobalThis().fetch;
2265
- if (typeof globalFetch === "undefined") {
2266
- console.warn(`Builder SDK could not find a global fetch function. Make sure you have a polyfill for fetch in your project.
2267
- For more information, read https://github.com/BuilderIO/this-package-uses-fetch`);
2268
- throw new Error("Builder SDK could not find a global `fetch` function");
2262
+ function getGlobalThis() {
2263
+ if (typeof globalThis !== "undefined")
2264
+ return globalThis;
2265
+ if (typeof window !== "undefined")
2266
+ return window;
2267
+ if (typeof global !== "undefined")
2268
+ return global;
2269
+ if (typeof self !== "undefined")
2270
+ return self;
2271
+ return globalThis;
2272
+ }
2273
+ function getFetch() {
2274
+ const globalFetch = getGlobalThis().fetch;
2275
+ if (typeof globalFetch === "undefined") {
2276
+ console.warn(`Builder SDK could not find a global fetch function. Make sure you have a polyfill for fetch in your project.
2277
+ For more information, read https://github.com/BuilderIO/this-package-uses-fetch`);
2278
+ throw new Error("Builder SDK could not find a global `fetch` function");
2269
2279
  }
2270
2280
  return globalFetch;
2271
2281
  }
@@ -2654,7 +2664,7 @@ const getInteractionPropertiesForEvent = (event) => {
2654
2664
  }
2655
2665
  };
2656
2666
  };
2657
- const SDK_VERSION = "0.4.4";
2667
+ const SDK_VERSION = "0.4.5";
2658
2668
  const registry = {};
2659
2669
  function register(type, info) {
2660
2670
  let typeList = registry[type];
@@ -2782,7 +2792,11 @@ const setupBrowserForEditing = (options = {}) => {
2782
2792
  });
2783
2793
  }
2784
2794
  };
2785
- const getVariants = (content) => Object.values(content?.variations || {});
2795
+ const getVariants = (content) => Object.values(content?.variations || {}).map((variant) => ({
2796
+ ...variant,
2797
+ testVariationId: variant.id,
2798
+ id: content?.id
2799
+ }));
2786
2800
  const checkShouldRunVariants = ({ canTrack, content }) => {
2787
2801
  const hasVariants = getVariants(content).length > 0;
2788
2802
  if (!hasVariants)
@@ -2836,10 +2850,10 @@ function bldrAbTest(contentId, variants, isHydrationTarget2) {
2836
2850
  return contentId;
2837
2851
  }
2838
2852
  const winningVariantId = getAndSetVariantId2();
2839
- const styleEl = document.getElementById(`variants-styles-${contentId}`);
2853
+ const styleEl = document.currentScript?.previousElementSibling;
2840
2854
  if (isHydrationTarget2) {
2841
2855
  styleEl.remove();
2842
- const thisScriptEl = document.getElementById(`variants-script-${contentId}`);
2856
+ const thisScriptEl = document.currentScript;
2843
2857
  thisScriptEl?.remove();
2844
2858
  } else {
2845
2859
  const newStyleStr = variants.concat({
@@ -2868,7 +2882,7 @@ function bldrCntntScrpt(variantContentId, defaultContentId, isHydrationTarget2)
2868
2882
  }
2869
2883
  const cookieName = `builder.tests.${defaultContentId}`;
2870
2884
  const variantId = getCookie2(cookieName);
2871
- const parentDiv = document.querySelector(`[builder-content-id="${variantContentId}"]`);
2885
+ const parentDiv = document.currentScript?.parentElement;
2872
2886
  const variantIsDefaultContent = variantContentId === defaultContentId;
2873
2887
  if (variantId === variantContentId) {
2874
2888
  if (variantIsDefaultContent)
@@ -2888,22 +2902,25 @@ function bldrCntntScrpt(variantContentId, defaultContentId, isHydrationTarget2)
2888
2902
  }
2889
2903
  return;
2890
2904
  }
2891
- const getIsHydrationTarget = (target) => target === "react" || target === "reactNative" || target === "vue3" || target === "vue2";
2905
+ const getIsHydrationTarget = (target) => target === "react" || target === "reactNative";
2892
2906
  const isHydrationTarget = getIsHydrationTarget(TARGET);
2893
- const AB_TEST_FN_NAME = "bldrAbTest";
2894
- const CONTENT_FN_NAME = "bldrCntntScrpt";
2895
- const getVariantsScriptString = (variants, contentId) => {
2907
+ const AB_TEST_FN_NAME = "builderIoAbTest";
2908
+ const CONTENT_FN_NAME = "builderIoRenderContent";
2909
+ const getScriptString = () => {
2896
2910
  const fnStr = bldrAbTest.toString().replace(/\s+/g, " ");
2897
2911
  const fnStr2 = bldrCntntScrpt.toString().replace(/\s+/g, " ");
2898
2912
  return `
2899
- const ${AB_TEST_FN_NAME} = ${fnStr}
2900
- const ${CONTENT_FN_NAME} = ${fnStr2}
2901
- ${AB_TEST_FN_NAME}("${contentId}", ${JSON.stringify(variants)}, ${isHydrationTarget})
2913
+ window.${AB_TEST_FN_NAME} = ${fnStr}
2914
+ window.${CONTENT_FN_NAME} = ${fnStr2}
2902
2915
  `;
2903
2916
  };
2904
- const getRenderContentScriptString = ({ parentContentId, contentId }) => {
2917
+ const getVariantsScriptString = (variants, contentId) => {
2918
+ return `
2919
+ window.${AB_TEST_FN_NAME}("${contentId}",${JSON.stringify(variants)}, ${isHydrationTarget})`;
2920
+ };
2921
+ const getRenderContentScriptString = ({ contentId, variationId }) => {
2905
2922
  return `
2906
- ${CONTENT_FN_NAME}("${contentId}", "${parentContentId}", ${isHydrationTarget})`;
2923
+ window.${CONTENT_FN_NAME}("${variationId}", "${contentId}", ${isHydrationTarget})`;
2907
2924
  };
2908
2925
  const getCssFromFont = (font) => {
2909
2926
  const family = font.family + (font.kind && !font.kind.includes("#") ? ", " + font.kind : "");
@@ -2972,7 +2989,7 @@ ${getFontCss({
2972
2989
  }
2973
2990
  `.trim()
2974
2991
  });
2975
- return /* @__PURE__ */ qwik._jsxC(RenderInlinedStyles, {
2992
+ return /* @__PURE__ */ qwik._jsxC(InlinedStyles, {
2976
2993
  get styles() {
2977
2994
  return state.injectedStyles;
2978
2995
  },
@@ -3173,8 +3190,8 @@ const RenderContent = /* @__PURE__ */ qwik.componentQrl(/* @__PURE__ */ qwik.inl
3173
3190
  httpReqsData: {},
3174
3191
  overrideContent: null,
3175
3192
  scriptStr: getRenderContentScriptString({
3176
- contentId: props.content?.id,
3177
- parentContentId: props.parentContentId
3193
+ variationId: props.content?.testVariationId,
3194
+ contentId: props.content?.id
3178
3195
  }),
3179
3196
  update: 0
3180
3197
  }, {
@@ -3284,16 +3301,21 @@ const RenderContent = /* @__PURE__ */ qwik.componentQrl(/* @__PURE__ */ qwik.inl
3284
3301
  children: state.builderContextSignal.content ? /* @__PURE__ */ qwik._jsxS("div", {
3285
3302
  ref: elementRef,
3286
3303
  ...{},
3287
- ...props.hideContent ? {
3304
+ ...props.showContent ? {} : {
3288
3305
  hidden: true,
3289
3306
  "aria-hidden": true
3290
- } : {},
3307
+ },
3291
3308
  children: [
3292
- props.isSsrAbTest ? /* @__PURE__ */ qwik._jsxQ("script", null, {
3293
- dangerouslySetInnerHTML: qwik._fnSignal((p0) => p0.scriptStr, [
3294
- state
3295
- ], "p0.scriptStr")
3296
- }, null, 3, "03_0") : null,
3309
+ props.isSsrAbTest ? /* @__PURE__ */ qwik._jsxC(InlinedScript, {
3310
+ get scriptStr() {
3311
+ return state.scriptStr;
3312
+ },
3313
+ [qwik._IMMUTABLE]: {
3314
+ scriptStr: qwik._fnSignal((p0) => p0.scriptStr, [
3315
+ state
3316
+ ], "p0.scriptStr")
3317
+ }
3318
+ }, 3, "03_0") : null,
3297
3319
  /* @__PURE__ */ qwik._jsxC(RenderContentStyles, {
3298
3320
  get contentId() {
3299
3321
  return state.builderContextSignal.content?.id;
@@ -3348,14 +3370,230 @@ const RenderContent = /* @__PURE__ */ qwik.componentQrl(/* @__PURE__ */ qwik.inl
3348
3370
  }, 0, "03_2") : null
3349
3371
  }, 1, "03_3");
3350
3372
  }, "RenderContent_component_hEAI0ahViXM"));
3373
+ const RenderContentVariants = /* @__PURE__ */ qwik.componentQrl(/* @__PURE__ */ qwik.inlinedQrl((props) => {
3374
+ qwik._jsxBranch();
3375
+ const state = qwik.useStore({
3376
+ hideVariantsStyleString: getVariants(props.content).map((value) => `.variant-${value.testVariationId} { display: none; } `).join(""),
3377
+ shouldRenderVariants: checkShouldRunVariants({
3378
+ canTrack: getDefaultCanTrack(props.canTrack),
3379
+ content: props.content
3380
+ }),
3381
+ variantScriptStr: getVariantsScriptString(getVariants(props.content).map((value) => ({
3382
+ id: value.testVariationId,
3383
+ testRatio: value.testRatio
3384
+ })), props.content?.id || "")
3385
+ });
3386
+ qwik.useVisibleTaskQrl(/* @__PURE__ */ qwik.inlinedQrl(() => {
3387
+ qwik.useLexicalScope();
3388
+ }, "RenderContentVariants_component_useVisibleTask_zc1gmoEX01g", [
3389
+ state
3390
+ ]));
3391
+ return /* @__PURE__ */ qwik._jsxC(qwik.Fragment, {
3392
+ children: [
3393
+ !props.__isNestedRender && TARGET !== "reactNative" ? /* @__PURE__ */ qwik._jsxC(InlinedScript, {
3394
+ scriptStr: getScriptString()
3395
+ }, 3, "Bz_0") : null,
3396
+ state.shouldRenderVariants ? /* @__PURE__ */ qwik._jsxC(jsxRuntime.Fragment, {
3397
+ children: [
3398
+ /* @__PURE__ */ qwik._jsxC(InlinedStyles, {
3399
+ get id() {
3400
+ return `variants-styles-${props.content?.id}`;
3401
+ },
3402
+ get styles() {
3403
+ return state.hideVariantsStyleString;
3404
+ },
3405
+ [qwik._IMMUTABLE]: {
3406
+ id: qwik._fnSignal((p0) => `variants-styles-${p0.content?.id}`, [
3407
+ props
3408
+ ], "`variants-styles-${p0.content?.id}`"),
3409
+ styles: qwik._fnSignal((p0) => p0.hideVariantsStyleString, [
3410
+ state
3411
+ ], "p0.hideVariantsStyleString")
3412
+ }
3413
+ }, 3, "Bz_1"),
3414
+ /* @__PURE__ */ qwik._jsxC(InlinedScript, {
3415
+ get scriptStr() {
3416
+ return state.variantScriptStr;
3417
+ },
3418
+ [qwik._IMMUTABLE]: {
3419
+ scriptStr: qwik._fnSignal((p0) => p0.variantScriptStr, [
3420
+ state
3421
+ ], "p0.variantScriptStr")
3422
+ }
3423
+ }, 3, "Bz_2"),
3424
+ (getVariants(props.content) || []).map(function(variant) {
3425
+ return /* @__PURE__ */ qwik._jsxC(RenderContent, {
3426
+ content: variant,
3427
+ showContent: false,
3428
+ classNameProp: void 0,
3429
+ get model() {
3430
+ return props.model;
3431
+ },
3432
+ get data() {
3433
+ return props.data;
3434
+ },
3435
+ get context() {
3436
+ return props.context;
3437
+ },
3438
+ get apiKey() {
3439
+ return props.apiKey;
3440
+ },
3441
+ get apiVersion() {
3442
+ return props.apiVersion;
3443
+ },
3444
+ get customComponents() {
3445
+ return props.customComponents;
3446
+ },
3447
+ get canTrack() {
3448
+ return props.canTrack;
3449
+ },
3450
+ get locale() {
3451
+ return props.locale;
3452
+ },
3453
+ get includeRefs() {
3454
+ return props.includeRefs;
3455
+ },
3456
+ get enrich() {
3457
+ return props.enrich;
3458
+ },
3459
+ get isSsrAbTest() {
3460
+ return state.shouldRenderVariants;
3461
+ },
3462
+ [qwik._IMMUTABLE]: {
3463
+ showContent: qwik._IMMUTABLE,
3464
+ model: qwik._fnSignal((p0) => p0.model, [
3465
+ props
3466
+ ], "p0.model"),
3467
+ data: qwik._fnSignal((p0) => p0.data, [
3468
+ props
3469
+ ], "p0.data"),
3470
+ context: qwik._fnSignal((p0) => p0.context, [
3471
+ props
3472
+ ], "p0.context"),
3473
+ apiKey: qwik._fnSignal((p0) => p0.apiKey, [
3474
+ props
3475
+ ], "p0.apiKey"),
3476
+ apiVersion: qwik._fnSignal((p0) => p0.apiVersion, [
3477
+ props
3478
+ ], "p0.apiVersion"),
3479
+ customComponents: qwik._fnSignal((p0) => p0.customComponents, [
3480
+ props
3481
+ ], "p0.customComponents"),
3482
+ canTrack: qwik._fnSignal((p0) => p0.canTrack, [
3483
+ props
3484
+ ], "p0.canTrack"),
3485
+ locale: qwik._fnSignal((p0) => p0.locale, [
3486
+ props
3487
+ ], "p0.locale"),
3488
+ includeRefs: qwik._fnSignal((p0) => p0.includeRefs, [
3489
+ props
3490
+ ], "p0.includeRefs"),
3491
+ enrich: qwik._fnSignal((p0) => p0.enrich, [
3492
+ props
3493
+ ], "p0.enrich"),
3494
+ isSsrAbTest: qwik._fnSignal((p0) => p0.shouldRenderVariants, [
3495
+ state
3496
+ ], "p0.shouldRenderVariants")
3497
+ }
3498
+ }, 3, variant.testVariationId);
3499
+ })
3500
+ ]
3501
+ }, 1, "Bz_3") : null,
3502
+ /* @__PURE__ */ qwik._jsxC(RenderContent, {
3503
+ content: state.shouldRenderVariants ? props.content : handleABTestingSync({
3504
+ item: props.content,
3505
+ canTrack: getDefaultCanTrack(props.canTrack)
3506
+ }),
3507
+ get classNameProp() {
3508
+ return `variant-${props.content?.id}`;
3509
+ },
3510
+ showContent: true,
3511
+ get model() {
3512
+ return props.model;
3513
+ },
3514
+ get data() {
3515
+ return props.data;
3516
+ },
3517
+ get context() {
3518
+ return props.context;
3519
+ },
3520
+ get apiKey() {
3521
+ return props.apiKey;
3522
+ },
3523
+ get apiVersion() {
3524
+ return props.apiVersion;
3525
+ },
3526
+ get customComponents() {
3527
+ return props.customComponents;
3528
+ },
3529
+ get canTrack() {
3530
+ return props.canTrack;
3531
+ },
3532
+ get locale() {
3533
+ return props.locale;
3534
+ },
3535
+ get includeRefs() {
3536
+ return props.includeRefs;
3537
+ },
3538
+ get enrich() {
3539
+ return props.enrich;
3540
+ },
3541
+ get isSsrAbTest() {
3542
+ return state.shouldRenderVariants;
3543
+ },
3544
+ [qwik._IMMUTABLE]: {
3545
+ classNameProp: qwik._fnSignal((p0) => `variant-${p0.content?.id}`, [
3546
+ props
3547
+ ], "`variant-${p0.content?.id}`"),
3548
+ showContent: qwik._IMMUTABLE,
3549
+ model: qwik._fnSignal((p0) => p0.model, [
3550
+ props
3551
+ ], "p0.model"),
3552
+ data: qwik._fnSignal((p0) => p0.data, [
3553
+ props
3554
+ ], "p0.data"),
3555
+ context: qwik._fnSignal((p0) => p0.context, [
3556
+ props
3557
+ ], "p0.context"),
3558
+ apiKey: qwik._fnSignal((p0) => p0.apiKey, [
3559
+ props
3560
+ ], "p0.apiKey"),
3561
+ apiVersion: qwik._fnSignal((p0) => p0.apiVersion, [
3562
+ props
3563
+ ], "p0.apiVersion"),
3564
+ customComponents: qwik._fnSignal((p0) => p0.customComponents, [
3565
+ props
3566
+ ], "p0.customComponents"),
3567
+ canTrack: qwik._fnSignal((p0) => p0.canTrack, [
3568
+ props
3569
+ ], "p0.canTrack"),
3570
+ locale: qwik._fnSignal((p0) => p0.locale, [
3571
+ props
3572
+ ], "p0.locale"),
3573
+ includeRefs: qwik._fnSignal((p0) => p0.includeRefs, [
3574
+ props
3575
+ ], "p0.includeRefs"),
3576
+ enrich: qwik._fnSignal((p0) => p0.enrich, [
3577
+ props
3578
+ ], "p0.enrich"),
3579
+ isSsrAbTest: qwik._fnSignal((p0) => p0.shouldRenderVariants, [
3580
+ state
3581
+ ], "p0.shouldRenderVariants")
3582
+ }
3583
+ }, 3, "Bz_4")
3584
+ ]
3585
+ }, 1, "Bz_5");
3586
+ }, "RenderContentVariants_component_OMvvre8Ofjw"));
3351
3587
  const fetchContent = function fetchContent2(props, state, builderContext) {
3352
3588
  if (!state.contentToUse && props.symbol?.model && builderContext?.apiKey)
3353
3589
  getContent({
3354
3590
  model: props.symbol.model,
3355
3591
  apiKey: builderContext.apiKey,
3356
3592
  apiVersion: builderContext.apiVersion,
3357
- query: {
3358
- id: props.symbol.entry
3593
+ ...props.symbol?.entry && {
3594
+ query: {
3595
+ id: props.symbol.entry
3596
+ }
3359
3597
  }
3360
3598
  }).then((response) => {
3361
3599
  if (response)
@@ -3396,7 +3634,7 @@ const Symbol$1 = /* @__PURE__ */ qwik.componentQrl(/* @__PURE__ */ qwik.inlinedQ
3396
3634
  ]));
3397
3635
  return /* @__PURE__ */ qwik._jsxS("div", {
3398
3636
  ...props.attributes,
3399
- children: /* @__PURE__ */ qwik._jsxC(RenderContent, {
3637
+ children: /* @__PURE__ */ qwik._jsxC(RenderContentVariants, {
3400
3638
  get apiVersion() {
3401
3639
  return builderContext.apiVersion;
3402
3640
  },
@@ -3458,162 +3696,6 @@ const Symbol$1 = /* @__PURE__ */ qwik.componentQrl(/* @__PURE__ */ qwik.inlinedQ
3458
3696
  ], "p0.className")
3459
3697
  }, 0, "Wt_1");
3460
3698
  }, "Symbol_component_WVvggdkUPdk"));
3461
- const RenderContentVariants = /* @__PURE__ */ qwik.componentQrl(/* @__PURE__ */ qwik.inlinedQrl((props) => {
3462
- qwik._jsxBranch();
3463
- const state = qwik.useStore({
3464
- contentToRender: checkShouldRunVariants({
3465
- canTrack: getDefaultCanTrack(props.canTrack),
3466
- content: props.content
3467
- }) ? props.content : handleABTestingSync({
3468
- item: props.content,
3469
- canTrack: getDefaultCanTrack(props.canTrack)
3470
- }),
3471
- hideVariantsStyleString: getVariants(props.content).map((value) => `.variant-${value.id} { display: none; } `).join(""),
3472
- shouldRenderVariants: checkShouldRunVariants({
3473
- canTrack: getDefaultCanTrack(props.canTrack),
3474
- content: props.content
3475
- }),
3476
- variantScriptStr: getVariantsScriptString(getVariants(props.content).map((value) => ({
3477
- id: value.id,
3478
- testRatio: value.testRatio
3479
- })), props.content?.id || "")
3480
- });
3481
- return /* @__PURE__ */ qwik._jsxC(qwik.Fragment, {
3482
- children: [
3483
- state.shouldRenderVariants ? /* @__PURE__ */ qwik._jsxC(jsxRuntime.Fragment, {
3484
- children: [
3485
- /* @__PURE__ */ qwik._jsxC(RenderInlinedStyles, {
3486
- get id() {
3487
- return `variants-styles-${props.content?.id}`;
3488
- },
3489
- get styles() {
3490
- return state.hideVariantsStyleString;
3491
- },
3492
- [qwik._IMMUTABLE]: {
3493
- id: qwik._fnSignal((p0) => `variants-styles-${p0.content?.id}`, [
3494
- props
3495
- ], "`variants-styles-${p0.content?.id}`"),
3496
- styles: qwik._fnSignal((p0) => p0.hideVariantsStyleString, [
3497
- state
3498
- ], "p0.hideVariantsStyleString")
3499
- }
3500
- }, 3, "Bz_0"),
3501
- /* @__PURE__ */ qwik._jsxQ("script", null, {
3502
- id: qwik._fnSignal((p0) => `variants-script-${p0.content?.id}`, [
3503
- props
3504
- ], "`variants-script-${p0.content?.id}`"),
3505
- dangerouslySetInnerHTML: qwik._fnSignal((p0) => p0.variantScriptStr, [
3506
- state
3507
- ], "p0.variantScriptStr")
3508
- }, null, 3, null),
3509
- (getVariants(props.content) || []).map(function(variant) {
3510
- return /* @__PURE__ */ qwik._jsxC(RenderContent, {
3511
- content: variant,
3512
- get apiKey() {
3513
- return props.apiKey;
3514
- },
3515
- get apiVersion() {
3516
- return props.apiVersion;
3517
- },
3518
- get canTrack() {
3519
- return props.canTrack;
3520
- },
3521
- get customComponents() {
3522
- return props.customComponents;
3523
- },
3524
- hideContent: true,
3525
- get parentContentId() {
3526
- return props.content?.id;
3527
- },
3528
- get isSsrAbTest() {
3529
- return state.shouldRenderVariants;
3530
- },
3531
- [qwik._IMMUTABLE]: {
3532
- apiKey: qwik._fnSignal((p0) => p0.apiKey, [
3533
- props
3534
- ], "p0.apiKey"),
3535
- apiVersion: qwik._fnSignal((p0) => p0.apiVersion, [
3536
- props
3537
- ], "p0.apiVersion"),
3538
- canTrack: qwik._fnSignal((p0) => p0.canTrack, [
3539
- props
3540
- ], "p0.canTrack"),
3541
- customComponents: qwik._fnSignal((p0) => p0.customComponents, [
3542
- props
3543
- ], "p0.customComponents"),
3544
- hideContent: qwik._IMMUTABLE,
3545
- parentContentId: qwik._fnSignal((p0) => p0.content?.id, [
3546
- props
3547
- ], "p0.content?.id"),
3548
- isSsrAbTest: qwik._fnSignal((p0) => p0.shouldRenderVariants, [
3549
- state
3550
- ], "p0.shouldRenderVariants")
3551
- }
3552
- }, 3, variant.id);
3553
- })
3554
- ]
3555
- }, 1, "Bz_1") : null,
3556
- /* @__PURE__ */ qwik._jsxC(RenderContent, {
3557
- get model() {
3558
- return props.model;
3559
- },
3560
- get content() {
3561
- return state.contentToRender;
3562
- },
3563
- get apiKey() {
3564
- return props.apiKey;
3565
- },
3566
- get apiVersion() {
3567
- return props.apiVersion;
3568
- },
3569
- get canTrack() {
3570
- return props.canTrack;
3571
- },
3572
- get customComponents() {
3573
- return props.customComponents;
3574
- },
3575
- get classNameProp() {
3576
- return `variant-${props.content?.id}`;
3577
- },
3578
- get parentContentId() {
3579
- return props.content?.id;
3580
- },
3581
- get isSsrAbTest() {
3582
- return state.shouldRenderVariants;
3583
- },
3584
- [qwik._IMMUTABLE]: {
3585
- model: qwik._fnSignal((p0) => p0.model, [
3586
- props
3587
- ], "p0.model"),
3588
- content: qwik._fnSignal((p0) => p0.contentToRender, [
3589
- state
3590
- ], "p0.contentToRender"),
3591
- apiKey: qwik._fnSignal((p0) => p0.apiKey, [
3592
- props
3593
- ], "p0.apiKey"),
3594
- apiVersion: qwik._fnSignal((p0) => p0.apiVersion, [
3595
- props
3596
- ], "p0.apiVersion"),
3597
- canTrack: qwik._fnSignal((p0) => p0.canTrack, [
3598
- props
3599
- ], "p0.canTrack"),
3600
- customComponents: qwik._fnSignal((p0) => p0.customComponents, [
3601
- props
3602
- ], "p0.customComponents"),
3603
- classNameProp: qwik._fnSignal((p0) => `variant-${p0.content?.id}`, [
3604
- props
3605
- ], "`variant-${p0.content?.id}`"),
3606
- parentContentId: qwik._fnSignal((p0) => p0.content?.id, [
3607
- props
3608
- ], "p0.content?.id"),
3609
- isSsrAbTest: qwik._fnSignal((p0) => p0.shouldRenderVariants, [
3610
- state
3611
- ], "p0.shouldRenderVariants")
3612
- }
3613
- }, 3, "Bz_2")
3614
- ]
3615
- }, 1, "Bz_3");
3616
- }, "RenderContentVariants_component_OMvvre8Ofjw"));
3617
3699
  const settings = {};
3618
3700
  function setEditorSettings(newSettings) {
3619
3701
  if (isBrowser()) {