@builder.io/sdk-solid 4.0.1 → 4.0.3

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/edge/dev.js CHANGED
@@ -7182,9 +7182,8 @@ var _tmpl$13 = /* @__PURE__ */ template(`<div>`);
7182
7182
  function CustomCode(props) {
7183
7183
  const [scriptsInserted, setScriptsInserted] = createSignal([]);
7184
7184
  const [scriptsRun, setScriptsRun] = createSignal([]);
7185
- let elementRef;
7186
- onMount(() => {
7187
- if (!elementRef?.getElementsByTagName || typeof window === "undefined") {
7185
+ function runScripts() {
7186
+ if (!elementRef || !elementRef?.getElementsByTagName || typeof window === "undefined") {
7188
7187
  return;
7189
7188
  }
7190
7189
  const scripts = elementRef.getElementsByTagName("script");
@@ -7207,11 +7206,22 @@ function CustomCode(props) {
7207
7206
  scriptsRun().push(script.innerText);
7208
7207
  new Function(script.innerText)();
7209
7208
  } catch (error) {
7210
- console.warn("`CustomCode`: Error running script:", error);
7209
+ logger.warn("[BUILDER.IO] `CustomCode`: Error running script:", error);
7211
7210
  }
7212
7211
  }
7213
7212
  }
7213
+ }
7214
+ let elementRef;
7215
+ onMount(() => {
7216
+ runScripts();
7214
7217
  });
7218
+ const onUpdateFn_0_props_code = createMemo(() => props.code);
7219
+ function onUpdateFn_0() {
7220
+ if (isEditing()) {
7221
+ runScripts();
7222
+ }
7223
+ }
7224
+ createEffect(on(() => [onUpdateFn_0_props_code()], onUpdateFn_0));
7215
7225
  return (() => {
7216
7226
  const _el$ = _tmpl$13();
7217
7227
  const _ref$ = elementRef;
@@ -7275,7 +7285,7 @@ function Embed(props) {
7275
7285
  scriptsRun().push(script.innerText);
7276
7286
  new Function(script.innerText)();
7277
7287
  } catch (error) {
7278
- console.warn("`Embed`: Error running script:", error);
7288
+ logger.warn("[BUILDER.IO] `Embed`: Error running script:", error);
7279
7289
  }
7280
7290
  }
7281
7291
  }
@@ -8460,7 +8470,7 @@ function serializeIncludingFunctions(info) {
8460
8470
  }
8461
8471
 
8462
8472
  // src/components/content-variants/inlined-fns.ts
8463
- var 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}";
8473
+ var UPDATE_COOKIES_AND_STYLES_SCRIPT = "function updateCookiesAndStyles(contentId, variants, isHydrationTarget, isAngularSDK) {\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 let styleEl = document.currentScript?.previousElementSibling;\n if (isAngularSDK) {\n styleEl = document.currentScript?.parentElement?.previousElementSibling?.querySelector('style');\n }\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}";
8464
8474
  var 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}";
8465
8475
 
8466
8476
  // src/components/content-variants/helpers.ts
@@ -8489,6 +8499,7 @@ var checkShouldRenderVariants2 = ({
8489
8499
  return true;
8490
8500
  };
8491
8501
  var getIsHydrationTarget = (target) => target === "react" || target === "reactNative";
8502
+ var isAngularSDK = TARGET === "angular";
8492
8503
  var isHydrationTarget = getIsHydrationTarget(TARGET);
8493
8504
  var getInitVariantsFnsScriptString = () => `
8494
8505
  window.${UPDATE_COOKIES_AND_STYLES_SCRIPT_NAME} = ${UPDATE_COOKIES_AND_STYLES_SCRIPT}
@@ -8496,7 +8507,7 @@ var getInitVariantsFnsScriptString = () => `
8496
8507
  `;
8497
8508
  var getUpdateCookieAndStylesScript = (variants, contentId) => `
8498
8509
  window.${UPDATE_COOKIES_AND_STYLES_SCRIPT_NAME}(
8499
- "${contentId}",${JSON.stringify(variants)}, ${isHydrationTarget}
8510
+ "${contentId}",${JSON.stringify(variants)}, ${isHydrationTarget}, ${isAngularSDK}
8500
8511
  )`;
8501
8512
  var getUpdateVariantVisibilityScript = ({
8502
8513
  contentId,
@@ -8511,7 +8522,7 @@ function getPreviewContent(_searchParams) {
8511
8522
  }
8512
8523
 
8513
8524
  // src/constants/sdk-version.ts
8514
- var SDK_VERSION = "4.0.1";
8525
+ var SDK_VERSION = "4.0.3";
8515
8526
 
8516
8527
  // src/helpers/sdk-headers.ts
8517
8528
  var getSdkHeaders = () => ({
@@ -9372,6 +9383,7 @@ var getWrapperClassName = (variationId) => {
9372
9383
 
9373
9384
  // src/components/content/components/enable-editor.tsx
9374
9385
  function EnableEditor(props) {
9386
+ createSignal(false);
9375
9387
  const [ContentWrapper, setContentWrapper] = createSignal(props.contentWrapper || "div");
9376
9388
  const [httpReqsData, setHttpReqsData] = createSignal({});
9377
9389
  const [httpReqsPending, setHttpReqsPending] = createSignal({});
@@ -9539,8 +9551,12 @@ function EnableEditor(props) {
9539
9551
  window.addEventListener("builder:component:stateChangeListenerActivated", emitStateUpdate);
9540
9552
  }
9541
9553
  const shouldTrackImpression = props.builderContextSignal.content && getDefaultCanTrack(props.canTrack);
9542
- if (shouldTrackImpression) {
9543
- const variationId = props.builderContextSignal.content?.testVariationId;
9554
+ const winningVariantId = getCookieSync({
9555
+ name: `builder.tests.${props.builderContextSignal.content?.id}`,
9556
+ canTrack: true
9557
+ });
9558
+ const variationId = props.builderContextSignal.content?.testVariationId;
9559
+ if (shouldTrackImpression && variationId === winningVariantId) {
9544
9560
  const contentId = props.builderContextSignal.content?.id;
9545
9561
  const apiKeyProp = props.apiKey;
9546
9562
  _track({
@@ -9549,7 +9565,7 @@ function EnableEditor(props) {
9549
9565
  canTrack: true,
9550
9566
  contentId,
9551
9567
  apiKey: apiKeyProp,
9552
- variationId: variationId !== contentId ? variationId : void 0
9568
+ variationId: winningVariantId !== contentId ? winningVariantId : void 0
9553
9569
  });
9554
9570
  }
9555
9571
  if (isPreviewing() && !isEditing()) {
package/lib/edge/dev.jsx CHANGED
@@ -5099,7 +5099,7 @@ function SectionComponent(props) {
5099
5099
  var section_default = SectionComponent;
5100
5100
 
5101
5101
  // src/blocks/symbol/symbol.tsx
5102
- import { onMount as onMount9, on as on4, createEffect as createEffect4, createMemo as createMemo20, createSignal as createSignal20 } from "solid-js";
5102
+ import { onMount as onMount9, on as on5, createEffect as createEffect5, createMemo as createMemo20, createSignal as createSignal20 } from "solid-js";
5103
5103
 
5104
5104
  // src/components/content-variants/content-variants.tsx
5105
5105
  import { Show as Show16, For as For9, onMount as onMount8, createSignal as createSignal19, createMemo as createMemo19 } from "solid-js";
@@ -6808,13 +6808,12 @@ var componentInfo12 = {
6808
6808
  };
6809
6809
 
6810
6810
  // src/blocks/custom-code/custom-code.tsx
6811
- import { onMount as onMount5, createSignal as createSignal12 } from "solid-js";
6811
+ import { onMount as onMount5, on as on2, createEffect as createEffect2, createMemo as createMemo12, createSignal as createSignal12 } from "solid-js";
6812
6812
  function CustomCode(props) {
6813
6813
  const [scriptsInserted, setScriptsInserted] = createSignal12([]);
6814
6814
  const [scriptsRun, setScriptsRun] = createSignal12([]);
6815
- let elementRef;
6816
- onMount5(() => {
6817
- if (!elementRef?.getElementsByTagName || typeof window === "undefined") {
6815
+ function runScripts() {
6816
+ if (!elementRef || !elementRef?.getElementsByTagName || typeof window === "undefined") {
6818
6817
  return;
6819
6818
  }
6820
6819
  const scripts = elementRef.getElementsByTagName("script");
@@ -6841,11 +6840,25 @@ function CustomCode(props) {
6841
6840
  scriptsRun().push(script.innerText);
6842
6841
  new Function(script.innerText)();
6843
6842
  } catch (error) {
6844
- console.warn("`CustomCode`: Error running script:", error);
6843
+ logger.warn(
6844
+ "[BUILDER.IO] `CustomCode`: Error running script:",
6845
+ error
6846
+ );
6845
6847
  }
6846
6848
  }
6847
6849
  }
6850
+ }
6851
+ let elementRef;
6852
+ onMount5(() => {
6853
+ runScripts();
6848
6854
  });
6855
+ const onUpdateFn_0_props_code = createMemo12(() => props.code);
6856
+ function onUpdateFn_0() {
6857
+ if (isEditing()) {
6858
+ runScripts();
6859
+ }
6860
+ }
6861
+ createEffect2(on2(() => [onUpdateFn_0_props_code()], onUpdateFn_0));
6849
6862
  return <><div
6850
6863
  class={"builder-custom-code" + (props.replaceNodes ? " replace-nodes" : "")}
6851
6864
  ref={elementRef}
@@ -6873,7 +6886,7 @@ var componentInfo13 = {
6873
6886
  };
6874
6887
 
6875
6888
  // src/blocks/embed/embed.tsx
6876
- import { on as on2, createEffect as createEffect2, createMemo as createMemo13, createSignal as createSignal13 } from "solid-js";
6889
+ import { on as on3, createEffect as createEffect3, createMemo as createMemo13, createSignal as createSignal13 } from "solid-js";
6877
6890
 
6878
6891
  // src/blocks/embed/helpers.ts
6879
6892
  var SCRIPT_MIME_TYPES = ["text/javascript", "application/javascript", "application/ecmascript"];
@@ -6901,7 +6914,7 @@ function Embed(props) {
6901
6914
  scriptsRun().push(script.innerText);
6902
6915
  new Function(script.innerText)();
6903
6916
  } catch (error) {
6904
- console.warn("`Embed`: Error running script:", error);
6917
+ logger.warn("[BUILDER.IO] `Embed`: Error running script:", error);
6905
6918
  }
6906
6919
  }
6907
6920
  }
@@ -6915,8 +6928,8 @@ function Embed(props) {
6915
6928
  findAndRunScripts();
6916
6929
  }
6917
6930
  }
6918
- createEffect2(
6919
- on2(() => [onUpdateFn_0_elem(), onUpdateFn_0_ranInitFn__()], onUpdateFn_0)
6931
+ createEffect3(
6932
+ on3(() => [onUpdateFn_0_elem(), onUpdateFn_0_ranInitFn__()], onUpdateFn_0)
6920
6933
  );
6921
6934
  return <><div class="builder-embed" ref={elem} innerHTML={props.content} /></>;
6922
6935
  }
@@ -7958,7 +7971,7 @@ function serializeIncludingFunctions(info) {
7958
7971
  }
7959
7972
 
7960
7973
  // src/components/content-variants/inlined-fns.ts
7961
- var 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}";
7974
+ var UPDATE_COOKIES_AND_STYLES_SCRIPT = "function updateCookiesAndStyles(contentId, variants, isHydrationTarget, isAngularSDK) {\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 let styleEl = document.currentScript?.previousElementSibling;\n if (isAngularSDK) {\n styleEl = document.currentScript?.parentElement?.previousElementSibling?.querySelector('style');\n }\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}";
7962
7975
  var 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}";
7963
7976
 
7964
7977
  // src/components/content-variants/helpers.ts
@@ -7987,6 +8000,7 @@ var checkShouldRenderVariants2 = ({
7987
8000
  return true;
7988
8001
  };
7989
8002
  var getIsHydrationTarget = (target) => target === "react" || target === "reactNative";
8003
+ var isAngularSDK = TARGET === "angular";
7990
8004
  var isHydrationTarget = getIsHydrationTarget(TARGET);
7991
8005
  var getInitVariantsFnsScriptString = () => `
7992
8006
  window.${UPDATE_COOKIES_AND_STYLES_SCRIPT_NAME} = ${UPDATE_COOKIES_AND_STYLES_SCRIPT}
@@ -7994,7 +8008,7 @@ var getInitVariantsFnsScriptString = () => `
7994
8008
  `;
7995
8009
  var getUpdateCookieAndStylesScript = (variants, contentId) => `
7996
8010
  window.${UPDATE_COOKIES_AND_STYLES_SCRIPT_NAME}(
7997
- "${contentId}",${JSON.stringify(variants)}, ${isHydrationTarget}
8011
+ "${contentId}",${JSON.stringify(variants)}, ${isHydrationTarget}, ${isAngularSDK}
7998
8012
  )`;
7999
8013
  var getUpdateVariantVisibilityScript = ({
8000
8014
  contentId,
@@ -8007,8 +8021,8 @@ var getUpdateVariantVisibilityScript = ({
8007
8021
  import {
8008
8022
  Show as Show14,
8009
8023
  onMount as onMount7,
8010
- on as on3,
8011
- createEffect as createEffect3,
8024
+ on as on4,
8025
+ createEffect as createEffect4,
8012
8026
  createMemo as createMemo16,
8013
8027
  createSignal as createSignal16
8014
8028
  } from "solid-js";
@@ -8020,7 +8034,7 @@ function getPreviewContent(_searchParams) {
8020
8034
  }
8021
8035
 
8022
8036
  // src/constants/sdk-version.ts
8023
- var SDK_VERSION = "4.0.1";
8037
+ var SDK_VERSION = "4.0.3";
8024
8038
 
8025
8039
  // src/helpers/sdk-headers.ts
8026
8040
  var getSdkHeaders = () => ({
@@ -8881,6 +8895,7 @@ var getWrapperClassName = (variationId) => {
8881
8895
 
8882
8896
  // src/components/content/components/enable-editor.tsx
8883
8897
  function EnableEditor(props) {
8898
+ const [hasExecuted, setHasExecuted] = createSignal16(false);
8884
8899
  const [ContentWrapper, setContentWrapper] = createSignal16(
8885
8900
  props.contentWrapper || "div"
8886
8901
  );
@@ -9062,8 +9077,12 @@ function EnableEditor(props) {
9062
9077
  );
9063
9078
  }
9064
9079
  const shouldTrackImpression = props.builderContextSignal.content && getDefaultCanTrack(props.canTrack);
9065
- if (shouldTrackImpression) {
9066
- const variationId = props.builderContextSignal.content?.testVariationId;
9080
+ const winningVariantId = getCookieSync({
9081
+ name: `builder.tests.${props.builderContextSignal.content?.id}`,
9082
+ canTrack: true
9083
+ });
9084
+ const variationId = props.builderContextSignal.content?.testVariationId;
9085
+ if (shouldTrackImpression && variationId === winningVariantId) {
9067
9086
  const contentId = props.builderContextSignal.content?.id;
9068
9087
  const apiKeyProp = props.apiKey;
9069
9088
  _track({
@@ -9072,7 +9091,7 @@ function EnableEditor(props) {
9072
9091
  canTrack: true,
9073
9092
  contentId,
9074
9093
  apiKey: apiKeyProp,
9075
- variationId: variationId !== contentId ? variationId : void 0
9094
+ variationId: winningVariantId !== contentId ? winningVariantId : void 0
9076
9095
  });
9077
9096
  }
9078
9097
  if (isPreviewing() && !isEditing()) {
@@ -9107,15 +9126,15 @@ function EnableEditor(props) {
9107
9126
  mergeNewContent(props.content);
9108
9127
  }
9109
9128
  }
9110
- createEffect3(on3(() => [onUpdateFn_0_props_content()], onUpdateFn_0));
9129
+ createEffect4(on4(() => [onUpdateFn_0_props_content()], onUpdateFn_0));
9111
9130
  const onUpdateFn_1_props_builderContextSignal_rootState = createMemo16(
9112
9131
  () => props.builderContextSignal.rootState
9113
9132
  );
9114
9133
  function onUpdateFn_1() {
9115
9134
  emitStateUpdate();
9116
9135
  }
9117
- createEffect3(
9118
- on3(
9136
+ createEffect4(
9137
+ on4(
9119
9138
  () => [onUpdateFn_1_props_builderContextSignal_rootState()],
9120
9139
  onUpdateFn_1
9121
9140
  )
@@ -9126,7 +9145,7 @@ function EnableEditor(props) {
9126
9145
  mergeNewRootState(props.data);
9127
9146
  }
9128
9147
  }
9129
- createEffect3(on3(() => [onUpdateFn_2_props_data()], onUpdateFn_2));
9148
+ createEffect4(on4(() => [onUpdateFn_2_props_data()], onUpdateFn_2));
9130
9149
  const onUpdateFn_3_props_locale = createMemo16(() => props.locale);
9131
9150
  function onUpdateFn_3() {
9132
9151
  if (props.locale) {
@@ -9135,7 +9154,7 @@ function EnableEditor(props) {
9135
9154
  });
9136
9155
  }
9137
9156
  }
9138
- createEffect3(on3(() => [onUpdateFn_3_props_locale()], onUpdateFn_3));
9157
+ createEffect4(on4(() => [onUpdateFn_3_props_locale()], onUpdateFn_3));
9139
9158
  return <><builder_context_default.Provider value={props.builderContextSignal}><Show14
9140
9159
  when={props.builderContextSignal.content || needsElementRefDivForEditing()}
9141
9160
  ><Dynamic5
@@ -9513,7 +9532,7 @@ function Symbol2(props) {
9513
9532
  function onUpdateFn_0() {
9514
9533
  setContent();
9515
9534
  }
9516
- createEffect4(on4(() => [onUpdateFn_0_props_symbol()], onUpdateFn_0));
9535
+ createEffect5(on5(() => [onUpdateFn_0_props_symbol()], onUpdateFn_0));
9517
9536
  return <><div class={className()} {...{}} {...props.attributes} {...{}}><Content_variants_default
9518
9537
  nonce={props.builderContext.nonce}
9519
9538
  isNestedRender={true}
package/lib/edge/index.js CHANGED
@@ -7171,9 +7171,8 @@ var _tmpl$13 = /* @__PURE__ */ template(`<div>`);
7171
7171
  function CustomCode(props) {
7172
7172
  const [scriptsInserted, setScriptsInserted] = createSignal([]);
7173
7173
  const [scriptsRun, setScriptsRun] = createSignal([]);
7174
- let elementRef;
7175
- onMount(() => {
7176
- if (!elementRef?.getElementsByTagName || typeof window === "undefined") {
7174
+ function runScripts() {
7175
+ if (!elementRef || !elementRef?.getElementsByTagName || typeof window === "undefined") {
7177
7176
  return;
7178
7177
  }
7179
7178
  const scripts = elementRef.getElementsByTagName("script");
@@ -7196,10 +7195,22 @@ function CustomCode(props) {
7196
7195
  scriptsRun().push(script.innerText);
7197
7196
  new Function(script.innerText)();
7198
7197
  } catch (error) {
7198
+ logger.warn("[BUILDER.IO] `CustomCode`: Error running script:", error);
7199
7199
  }
7200
7200
  }
7201
7201
  }
7202
+ }
7203
+ let elementRef;
7204
+ onMount(() => {
7205
+ runScripts();
7202
7206
  });
7207
+ const onUpdateFn_0_props_code = createMemo(() => props.code);
7208
+ function onUpdateFn_0() {
7209
+ if (isEditing()) {
7210
+ runScripts();
7211
+ }
7212
+ }
7213
+ createEffect(on(() => [onUpdateFn_0_props_code()], onUpdateFn_0));
7203
7214
  return (() => {
7204
7215
  const _el$ = _tmpl$13();
7205
7216
  const _ref$ = elementRef;
@@ -7263,6 +7274,7 @@ function Embed(props) {
7263
7274
  scriptsRun().push(script.innerText);
7264
7275
  new Function(script.innerText)();
7265
7276
  } catch (error) {
7277
+ logger.warn("[BUILDER.IO] `Embed`: Error running script:", error);
7266
7278
  }
7267
7279
  }
7268
7280
  }
@@ -8446,7 +8458,7 @@ function serializeIncludingFunctions(info) {
8446
8458
  }
8447
8459
 
8448
8460
  // src/components/content-variants/inlined-fns.ts
8449
- var 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}";
8461
+ var UPDATE_COOKIES_AND_STYLES_SCRIPT = "function updateCookiesAndStyles(contentId, variants, isHydrationTarget, isAngularSDK) {\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 let styleEl = document.currentScript?.previousElementSibling;\n if (isAngularSDK) {\n styleEl = document.currentScript?.parentElement?.previousElementSibling?.querySelector('style');\n }\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}";
8450
8462
  var 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}";
8451
8463
 
8452
8464
  // src/components/content-variants/helpers.ts
@@ -8475,6 +8487,7 @@ var checkShouldRenderVariants2 = ({
8475
8487
  return true;
8476
8488
  };
8477
8489
  var getIsHydrationTarget = (target) => target === "react" || target === "reactNative";
8490
+ var isAngularSDK = TARGET === "angular";
8478
8491
  var isHydrationTarget = getIsHydrationTarget(TARGET);
8479
8492
  var getInitVariantsFnsScriptString = () => `
8480
8493
  window.${UPDATE_COOKIES_AND_STYLES_SCRIPT_NAME} = ${UPDATE_COOKIES_AND_STYLES_SCRIPT}
@@ -8482,7 +8495,7 @@ var getInitVariantsFnsScriptString = () => `
8482
8495
  `;
8483
8496
  var getUpdateCookieAndStylesScript = (variants, contentId) => `
8484
8497
  window.${UPDATE_COOKIES_AND_STYLES_SCRIPT_NAME}(
8485
- "${contentId}",${JSON.stringify(variants)}, ${isHydrationTarget}
8498
+ "${contentId}",${JSON.stringify(variants)}, ${isHydrationTarget}, ${isAngularSDK}
8486
8499
  )`;
8487
8500
  var getUpdateVariantVisibilityScript = ({
8488
8501
  contentId,
@@ -8497,7 +8510,7 @@ function getPreviewContent(_searchParams) {
8497
8510
  }
8498
8511
 
8499
8512
  // src/constants/sdk-version.ts
8500
- var SDK_VERSION = "4.0.1";
8513
+ var SDK_VERSION = "4.0.3";
8501
8514
 
8502
8515
  // src/helpers/sdk-headers.ts
8503
8516
  var getSdkHeaders = () => ({
@@ -9352,6 +9365,7 @@ var getWrapperClassName = (variationId) => {
9352
9365
 
9353
9366
  // src/components/content/components/enable-editor.tsx
9354
9367
  function EnableEditor(props) {
9368
+ createSignal(false);
9355
9369
  const [ContentWrapper, setContentWrapper] = createSignal(props.contentWrapper || "div");
9356
9370
  const [httpReqsData, setHttpReqsData] = createSignal({});
9357
9371
  const [httpReqsPending, setHttpReqsPending] = createSignal({});
@@ -9518,8 +9532,12 @@ function EnableEditor(props) {
9518
9532
  window.addEventListener("builder:component:stateChangeListenerActivated", emitStateUpdate);
9519
9533
  }
9520
9534
  const shouldTrackImpression = props.builderContextSignal.content && getDefaultCanTrack(props.canTrack);
9521
- if (shouldTrackImpression) {
9522
- const variationId = props.builderContextSignal.content?.testVariationId;
9535
+ const winningVariantId = getCookieSync({
9536
+ name: `builder.tests.${props.builderContextSignal.content?.id}`,
9537
+ canTrack: true
9538
+ });
9539
+ const variationId = props.builderContextSignal.content?.testVariationId;
9540
+ if (shouldTrackImpression && variationId === winningVariantId) {
9523
9541
  const contentId = props.builderContextSignal.content?.id;
9524
9542
  const apiKeyProp = props.apiKey;
9525
9543
  _track({
@@ -9528,7 +9546,7 @@ function EnableEditor(props) {
9528
9546
  canTrack: true,
9529
9547
  contentId,
9530
9548
  apiKey: apiKeyProp,
9531
- variationId: variationId !== contentId ? variationId : void 0
9549
+ variationId: winningVariantId !== contentId ? winningVariantId : void 0
9532
9550
  });
9533
9551
  }
9534
9552
  if (isPreviewing() && !isEditing()) {
@@ -5091,7 +5091,7 @@ function SectionComponent(props) {
5091
5091
  var section_default = SectionComponent;
5092
5092
 
5093
5093
  // src/blocks/symbol/symbol.tsx
5094
- import { onMount as onMount9, on as on4, createEffect as createEffect4, createMemo as createMemo20, createSignal as createSignal20 } from "solid-js";
5094
+ import { onMount as onMount9, on as on5, createEffect as createEffect5, createMemo as createMemo20, createSignal as createSignal20 } from "solid-js";
5095
5095
 
5096
5096
  // src/components/content-variants/content-variants.tsx
5097
5097
  import { Show as Show16, For as For9, onMount as onMount8, createSignal as createSignal19, createMemo as createMemo19 } from "solid-js";
@@ -6799,13 +6799,12 @@ var componentInfo12 = {
6799
6799
  };
6800
6800
 
6801
6801
  // src/blocks/custom-code/custom-code.tsx
6802
- import { onMount as onMount5, createSignal as createSignal12 } from "solid-js";
6802
+ import { onMount as onMount5, on as on2, createEffect as createEffect2, createMemo as createMemo12, createSignal as createSignal12 } from "solid-js";
6803
6803
  function CustomCode(props) {
6804
6804
  const [scriptsInserted, setScriptsInserted] = createSignal12([]);
6805
6805
  const [scriptsRun, setScriptsRun] = createSignal12([]);
6806
- let elementRef;
6807
- onMount5(() => {
6808
- if (!elementRef?.getElementsByTagName || typeof window === "undefined") {
6806
+ function runScripts() {
6807
+ if (!elementRef || !elementRef?.getElementsByTagName || typeof window === "undefined") {
6809
6808
  return;
6810
6809
  }
6811
6810
  const scripts = elementRef.getElementsByTagName("script");
@@ -6832,10 +6831,25 @@ function CustomCode(props) {
6832
6831
  scriptsRun().push(script.innerText);
6833
6832
  new Function(script.innerText)();
6834
6833
  } catch (error) {
6834
+ logger.warn(
6835
+ "[BUILDER.IO] `CustomCode`: Error running script:",
6836
+ error
6837
+ );
6835
6838
  }
6836
6839
  }
6837
6840
  }
6841
+ }
6842
+ let elementRef;
6843
+ onMount5(() => {
6844
+ runScripts();
6838
6845
  });
6846
+ const onUpdateFn_0_props_code = createMemo12(() => props.code);
6847
+ function onUpdateFn_0() {
6848
+ if (isEditing()) {
6849
+ runScripts();
6850
+ }
6851
+ }
6852
+ createEffect2(on2(() => [onUpdateFn_0_props_code()], onUpdateFn_0));
6839
6853
  return <><div
6840
6854
  class={"builder-custom-code" + (props.replaceNodes ? " replace-nodes" : "")}
6841
6855
  ref={elementRef}
@@ -6863,7 +6877,7 @@ var componentInfo13 = {
6863
6877
  };
6864
6878
 
6865
6879
  // src/blocks/embed/embed.tsx
6866
- import { on as on2, createEffect as createEffect2, createMemo as createMemo13, createSignal as createSignal13 } from "solid-js";
6880
+ import { on as on3, createEffect as createEffect3, createMemo as createMemo13, createSignal as createSignal13 } from "solid-js";
6867
6881
 
6868
6882
  // src/blocks/embed/helpers.ts
6869
6883
  var SCRIPT_MIME_TYPES = ["text/javascript", "application/javascript", "application/ecmascript"];
@@ -6891,6 +6905,7 @@ function Embed(props) {
6891
6905
  scriptsRun().push(script.innerText);
6892
6906
  new Function(script.innerText)();
6893
6907
  } catch (error) {
6908
+ logger.warn("[BUILDER.IO] `Embed`: Error running script:", error);
6894
6909
  }
6895
6910
  }
6896
6911
  }
@@ -6904,8 +6919,8 @@ function Embed(props) {
6904
6919
  findAndRunScripts();
6905
6920
  }
6906
6921
  }
6907
- createEffect2(
6908
- on2(() => [onUpdateFn_0_elem(), onUpdateFn_0_ranInitFn__()], onUpdateFn_0)
6922
+ createEffect3(
6923
+ on3(() => [onUpdateFn_0_elem(), onUpdateFn_0_ranInitFn__()], onUpdateFn_0)
6909
6924
  );
6910
6925
  return <><div class="builder-embed" ref={elem} innerHTML={props.content} /></>;
6911
6926
  }
@@ -7946,7 +7961,7 @@ function serializeIncludingFunctions(info) {
7946
7961
  }
7947
7962
 
7948
7963
  // src/components/content-variants/inlined-fns.ts
7949
- var 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}";
7964
+ var UPDATE_COOKIES_AND_STYLES_SCRIPT = "function updateCookiesAndStyles(contentId, variants, isHydrationTarget, isAngularSDK) {\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 let styleEl = document.currentScript?.previousElementSibling;\n if (isAngularSDK) {\n styleEl = document.currentScript?.parentElement?.previousElementSibling?.querySelector('style');\n }\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}";
7950
7965
  var 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}";
7951
7966
 
7952
7967
  // src/components/content-variants/helpers.ts
@@ -7975,6 +7990,7 @@ var checkShouldRenderVariants2 = ({
7975
7990
  return true;
7976
7991
  };
7977
7992
  var getIsHydrationTarget = (target) => target === "react" || target === "reactNative";
7993
+ var isAngularSDK = TARGET === "angular";
7978
7994
  var isHydrationTarget = getIsHydrationTarget(TARGET);
7979
7995
  var getInitVariantsFnsScriptString = () => `
7980
7996
  window.${UPDATE_COOKIES_AND_STYLES_SCRIPT_NAME} = ${UPDATE_COOKIES_AND_STYLES_SCRIPT}
@@ -7982,7 +7998,7 @@ var getInitVariantsFnsScriptString = () => `
7982
7998
  `;
7983
7999
  var getUpdateCookieAndStylesScript = (variants, contentId) => `
7984
8000
  window.${UPDATE_COOKIES_AND_STYLES_SCRIPT_NAME}(
7985
- "${contentId}",${JSON.stringify(variants)}, ${isHydrationTarget}
8001
+ "${contentId}",${JSON.stringify(variants)}, ${isHydrationTarget}, ${isAngularSDK}
7986
8002
  )`;
7987
8003
  var getUpdateVariantVisibilityScript = ({
7988
8004
  contentId,
@@ -7995,8 +8011,8 @@ var getUpdateVariantVisibilityScript = ({
7995
8011
  import {
7996
8012
  Show as Show14,
7997
8013
  onMount as onMount7,
7998
- on as on3,
7999
- createEffect as createEffect3,
8014
+ on as on4,
8015
+ createEffect as createEffect4,
8000
8016
  createMemo as createMemo16,
8001
8017
  createSignal as createSignal16
8002
8018
  } from "solid-js";
@@ -8008,7 +8024,7 @@ function getPreviewContent(_searchParams) {
8008
8024
  }
8009
8025
 
8010
8026
  // src/constants/sdk-version.ts
8011
- var SDK_VERSION = "4.0.1";
8027
+ var SDK_VERSION = "4.0.3";
8012
8028
 
8013
8029
  // src/helpers/sdk-headers.ts
8014
8030
  var getSdkHeaders = () => ({
@@ -8863,6 +8879,7 @@ var getWrapperClassName = (variationId) => {
8863
8879
 
8864
8880
  // src/components/content/components/enable-editor.tsx
8865
8881
  function EnableEditor(props) {
8882
+ const [hasExecuted, setHasExecuted] = createSignal16(false);
8866
8883
  const [ContentWrapper, setContentWrapper] = createSignal16(
8867
8884
  props.contentWrapper || "div"
8868
8885
  );
@@ -9043,8 +9060,12 @@ function EnableEditor(props) {
9043
9060
  );
9044
9061
  }
9045
9062
  const shouldTrackImpression = props.builderContextSignal.content && getDefaultCanTrack(props.canTrack);
9046
- if (shouldTrackImpression) {
9047
- const variationId = props.builderContextSignal.content?.testVariationId;
9063
+ const winningVariantId = getCookieSync({
9064
+ name: `builder.tests.${props.builderContextSignal.content?.id}`,
9065
+ canTrack: true
9066
+ });
9067
+ const variationId = props.builderContextSignal.content?.testVariationId;
9068
+ if (shouldTrackImpression && variationId === winningVariantId) {
9048
9069
  const contentId = props.builderContextSignal.content?.id;
9049
9070
  const apiKeyProp = props.apiKey;
9050
9071
  _track({
@@ -9053,7 +9074,7 @@ function EnableEditor(props) {
9053
9074
  canTrack: true,
9054
9075
  contentId,
9055
9076
  apiKey: apiKeyProp,
9056
- variationId: variationId !== contentId ? variationId : void 0
9077
+ variationId: winningVariantId !== contentId ? winningVariantId : void 0
9057
9078
  });
9058
9079
  }
9059
9080
  if (isPreviewing() && !isEditing()) {
@@ -9088,15 +9109,15 @@ function EnableEditor(props) {
9088
9109
  mergeNewContent(props.content);
9089
9110
  }
9090
9111
  }
9091
- createEffect3(on3(() => [onUpdateFn_0_props_content()], onUpdateFn_0));
9112
+ createEffect4(on4(() => [onUpdateFn_0_props_content()], onUpdateFn_0));
9092
9113
  const onUpdateFn_1_props_builderContextSignal_rootState = createMemo16(
9093
9114
  () => props.builderContextSignal.rootState
9094
9115
  );
9095
9116
  function onUpdateFn_1() {
9096
9117
  emitStateUpdate();
9097
9118
  }
9098
- createEffect3(
9099
- on3(
9119
+ createEffect4(
9120
+ on4(
9100
9121
  () => [onUpdateFn_1_props_builderContextSignal_rootState()],
9101
9122
  onUpdateFn_1
9102
9123
  )
@@ -9107,7 +9128,7 @@ function EnableEditor(props) {
9107
9128
  mergeNewRootState(props.data);
9108
9129
  }
9109
9130
  }
9110
- createEffect3(on3(() => [onUpdateFn_2_props_data()], onUpdateFn_2));
9131
+ createEffect4(on4(() => [onUpdateFn_2_props_data()], onUpdateFn_2));
9111
9132
  const onUpdateFn_3_props_locale = createMemo16(() => props.locale);
9112
9133
  function onUpdateFn_3() {
9113
9134
  if (props.locale) {
@@ -9116,7 +9137,7 @@ function EnableEditor(props) {
9116
9137
  });
9117
9138
  }
9118
9139
  }
9119
- createEffect3(on3(() => [onUpdateFn_3_props_locale()], onUpdateFn_3));
9140
+ createEffect4(on4(() => [onUpdateFn_3_props_locale()], onUpdateFn_3));
9120
9141
  return <><builder_context_default.Provider value={props.builderContextSignal}><Show14
9121
9142
  when={props.builderContextSignal.content || needsElementRefDivForEditing()}
9122
9143
  ><Dynamic5
@@ -9494,7 +9515,7 @@ function Symbol2(props) {
9494
9515
  function onUpdateFn_0() {
9495
9516
  setContent();
9496
9517
  }
9497
- createEffect4(on4(() => [onUpdateFn_0_props_symbol()], onUpdateFn_0));
9518
+ createEffect5(on5(() => [onUpdateFn_0_props_symbol()], onUpdateFn_0));
9498
9519
  return <><div class={className()} {...{}} {...props.attributes} {...{}}><Content_variants_default
9499
9520
  nonce={props.builderContext.nonce}
9500
9521
  isNestedRender={true}