@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/node/dev.js CHANGED
@@ -4170,9 +4170,8 @@ var _tmpl$13 = /* @__PURE__ */ template(`<div>`);
4170
4170
  function CustomCode(props) {
4171
4171
  const [scriptsInserted, setScriptsInserted] = createSignal([]);
4172
4172
  const [scriptsRun, setScriptsRun] = createSignal([]);
4173
- let elementRef;
4174
- onMount(() => {
4175
- if (!elementRef?.getElementsByTagName || typeof window === "undefined") {
4173
+ function runScripts() {
4174
+ if (!elementRef || !elementRef?.getElementsByTagName || typeof window === "undefined") {
4176
4175
  return;
4177
4176
  }
4178
4177
  const scripts = elementRef.getElementsByTagName("script");
@@ -4195,11 +4194,22 @@ function CustomCode(props) {
4195
4194
  scriptsRun().push(script.innerText);
4196
4195
  new Function(script.innerText)();
4197
4196
  } catch (error2) {
4198
- console.warn("`CustomCode`: Error running script:", error2);
4197
+ logger.warn("[BUILDER.IO] `CustomCode`: Error running script:", error2);
4199
4198
  }
4200
4199
  }
4201
4200
  }
4201
+ }
4202
+ let elementRef;
4203
+ onMount(() => {
4204
+ runScripts();
4202
4205
  });
4206
+ const onUpdateFn_0_props_code = createMemo(() => props.code);
4207
+ function onUpdateFn_0() {
4208
+ if (isEditing()) {
4209
+ runScripts();
4210
+ }
4211
+ }
4212
+ createEffect(on(() => [onUpdateFn_0_props_code()], onUpdateFn_0));
4203
4213
  return (() => {
4204
4214
  const _el$ = _tmpl$13();
4205
4215
  const _ref$ = elementRef;
@@ -4263,7 +4273,7 @@ function Embed(props) {
4263
4273
  scriptsRun().push(script.innerText);
4264
4274
  new Function(script.innerText)();
4265
4275
  } catch (error2) {
4266
- console.warn("`Embed`: Error running script:", error2);
4276
+ logger.warn("[BUILDER.IO] `Embed`: Error running script:", error2);
4267
4277
  }
4268
4278
  }
4269
4279
  }
@@ -5448,7 +5458,7 @@ function serializeIncludingFunctions(info) {
5448
5458
  }
5449
5459
 
5450
5460
  // src/components/content-variants/inlined-fns.ts
5451
- 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}";
5461
+ 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}";
5452
5462
  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}";
5453
5463
 
5454
5464
  // src/components/content-variants/helpers.ts
@@ -5477,6 +5487,7 @@ var checkShouldRenderVariants2 = ({
5477
5487
  return true;
5478
5488
  };
5479
5489
  var getIsHydrationTarget = (target) => target === "react" || target === "reactNative";
5490
+ var isAngularSDK = TARGET === "angular";
5480
5491
  var isHydrationTarget = getIsHydrationTarget(TARGET);
5481
5492
  var getInitVariantsFnsScriptString = () => `
5482
5493
  window.${UPDATE_COOKIES_AND_STYLES_SCRIPT_NAME} = ${UPDATE_COOKIES_AND_STYLES_SCRIPT}
@@ -5484,7 +5495,7 @@ var getInitVariantsFnsScriptString = () => `
5484
5495
  `;
5485
5496
  var getUpdateCookieAndStylesScript = (variants, contentId) => `
5486
5497
  window.${UPDATE_COOKIES_AND_STYLES_SCRIPT_NAME}(
5487
- "${contentId}",${JSON.stringify(variants)}, ${isHydrationTarget}
5498
+ "${contentId}",${JSON.stringify(variants)}, ${isHydrationTarget}, ${isAngularSDK}
5488
5499
  )`;
5489
5500
  var getUpdateVariantVisibilityScript = ({
5490
5501
  contentId,
@@ -5499,7 +5510,7 @@ function getPreviewContent(_searchParams) {
5499
5510
  }
5500
5511
 
5501
5512
  // src/constants/sdk-version.ts
5502
- var SDK_VERSION = "4.0.1";
5513
+ var SDK_VERSION = "4.0.3";
5503
5514
 
5504
5515
  // src/helpers/sdk-headers.ts
5505
5516
  var getSdkHeaders = () => ({
@@ -6360,6 +6371,7 @@ var getWrapperClassName = (variationId) => {
6360
6371
 
6361
6372
  // src/components/content/components/enable-editor.tsx
6362
6373
  function EnableEditor(props) {
6374
+ createSignal(false);
6363
6375
  const [ContentWrapper, setContentWrapper] = createSignal(props.contentWrapper || "div");
6364
6376
  const [httpReqsData, setHttpReqsData] = createSignal({});
6365
6377
  const [httpReqsPending, setHttpReqsPending] = createSignal({});
@@ -6527,8 +6539,12 @@ function EnableEditor(props) {
6527
6539
  window.addEventListener("builder:component:stateChangeListenerActivated", emitStateUpdate);
6528
6540
  }
6529
6541
  const shouldTrackImpression = props.builderContextSignal.content && getDefaultCanTrack(props.canTrack);
6530
- if (shouldTrackImpression) {
6531
- const variationId = props.builderContextSignal.content?.testVariationId;
6542
+ const winningVariantId = getCookieSync({
6543
+ name: `builder.tests.${props.builderContextSignal.content?.id}`,
6544
+ canTrack: true
6545
+ });
6546
+ const variationId = props.builderContextSignal.content?.testVariationId;
6547
+ if (shouldTrackImpression && variationId === winningVariantId) {
6532
6548
  const contentId = props.builderContextSignal.content?.id;
6533
6549
  const apiKeyProp = props.apiKey;
6534
6550
  _track({
@@ -6537,7 +6553,7 @@ function EnableEditor(props) {
6537
6553
  canTrack: true,
6538
6554
  contentId,
6539
6555
  apiKey: apiKeyProp,
6540
- variationId: variationId !== contentId ? variationId : void 0
6556
+ variationId: winningVariantId !== contentId ? winningVariantId : void 0
6541
6557
  });
6542
6558
  }
6543
6559
  if (isPreviewing() && !isEditing()) {
package/lib/node/dev.jsx CHANGED
@@ -2087,7 +2087,7 @@ function SectionComponent(props) {
2087
2087
  var section_default = SectionComponent;
2088
2088
 
2089
2089
  // src/blocks/symbol/symbol.tsx
2090
- import { onMount as onMount9, on as on4, createEffect as createEffect4, createMemo as createMemo20, createSignal as createSignal20 } from "solid-js";
2090
+ import { onMount as onMount9, on as on5, createEffect as createEffect5, createMemo as createMemo20, createSignal as createSignal20 } from "solid-js";
2091
2091
 
2092
2092
  // src/components/content-variants/content-variants.tsx
2093
2093
  import { Show as Show16, For as For9, onMount as onMount8, createSignal as createSignal19, createMemo as createMemo19 } from "solid-js";
@@ -3796,13 +3796,12 @@ var componentInfo12 = {
3796
3796
  };
3797
3797
 
3798
3798
  // src/blocks/custom-code/custom-code.tsx
3799
- import { onMount as onMount5, createSignal as createSignal12 } from "solid-js";
3799
+ import { onMount as onMount5, on as on2, createEffect as createEffect2, createMemo as createMemo12, createSignal as createSignal12 } from "solid-js";
3800
3800
  function CustomCode(props) {
3801
3801
  const [scriptsInserted, setScriptsInserted] = createSignal12([]);
3802
3802
  const [scriptsRun, setScriptsRun] = createSignal12([]);
3803
- let elementRef;
3804
- onMount5(() => {
3805
- if (!elementRef?.getElementsByTagName || typeof window === "undefined") {
3803
+ function runScripts() {
3804
+ if (!elementRef || !elementRef?.getElementsByTagName || typeof window === "undefined") {
3806
3805
  return;
3807
3806
  }
3808
3807
  const scripts = elementRef.getElementsByTagName("script");
@@ -3829,11 +3828,25 @@ function CustomCode(props) {
3829
3828
  scriptsRun().push(script.innerText);
3830
3829
  new Function(script.innerText)();
3831
3830
  } catch (error2) {
3832
- console.warn("`CustomCode`: Error running script:", error2);
3831
+ logger.warn(
3832
+ "[BUILDER.IO] `CustomCode`: Error running script:",
3833
+ error2
3834
+ );
3833
3835
  }
3834
3836
  }
3835
3837
  }
3838
+ }
3839
+ let elementRef;
3840
+ onMount5(() => {
3841
+ runScripts();
3836
3842
  });
3843
+ const onUpdateFn_0_props_code = createMemo12(() => props.code);
3844
+ function onUpdateFn_0() {
3845
+ if (isEditing()) {
3846
+ runScripts();
3847
+ }
3848
+ }
3849
+ createEffect2(on2(() => [onUpdateFn_0_props_code()], onUpdateFn_0));
3837
3850
  return <><div
3838
3851
  class={"builder-custom-code" + (props.replaceNodes ? " replace-nodes" : "")}
3839
3852
  ref={elementRef}
@@ -3861,7 +3874,7 @@ var componentInfo13 = {
3861
3874
  };
3862
3875
 
3863
3876
  // src/blocks/embed/embed.tsx
3864
- import { on as on2, createEffect as createEffect2, createMemo as createMemo13, createSignal as createSignal13 } from "solid-js";
3877
+ import { on as on3, createEffect as createEffect3, createMemo as createMemo13, createSignal as createSignal13 } from "solid-js";
3865
3878
 
3866
3879
  // src/blocks/embed/helpers.ts
3867
3880
  var SCRIPT_MIME_TYPES = ["text/javascript", "application/javascript", "application/ecmascript"];
@@ -3889,7 +3902,7 @@ function Embed(props) {
3889
3902
  scriptsRun().push(script.innerText);
3890
3903
  new Function(script.innerText)();
3891
3904
  } catch (error2) {
3892
- console.warn("`Embed`: Error running script:", error2);
3905
+ logger.warn("[BUILDER.IO] `Embed`: Error running script:", error2);
3893
3906
  }
3894
3907
  }
3895
3908
  }
@@ -3903,8 +3916,8 @@ function Embed(props) {
3903
3916
  findAndRunScripts();
3904
3917
  }
3905
3918
  }
3906
- createEffect2(
3907
- on2(() => [onUpdateFn_0_elem(), onUpdateFn_0_ranInitFn__()], onUpdateFn_0)
3919
+ createEffect3(
3920
+ on3(() => [onUpdateFn_0_elem(), onUpdateFn_0_ranInitFn__()], onUpdateFn_0)
3908
3921
  );
3909
3922
  return <><div class="builder-embed" ref={elem} innerHTML={props.content} /></>;
3910
3923
  }
@@ -4946,7 +4959,7 @@ function serializeIncludingFunctions(info) {
4946
4959
  }
4947
4960
 
4948
4961
  // src/components/content-variants/inlined-fns.ts
4949
- 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}";
4962
+ 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}";
4950
4963
  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}";
4951
4964
 
4952
4965
  // src/components/content-variants/helpers.ts
@@ -4975,6 +4988,7 @@ var checkShouldRenderVariants2 = ({
4975
4988
  return true;
4976
4989
  };
4977
4990
  var getIsHydrationTarget = (target) => target === "react" || target === "reactNative";
4991
+ var isAngularSDK = TARGET === "angular";
4978
4992
  var isHydrationTarget = getIsHydrationTarget(TARGET);
4979
4993
  var getInitVariantsFnsScriptString = () => `
4980
4994
  window.${UPDATE_COOKIES_AND_STYLES_SCRIPT_NAME} = ${UPDATE_COOKIES_AND_STYLES_SCRIPT}
@@ -4982,7 +4996,7 @@ var getInitVariantsFnsScriptString = () => `
4982
4996
  `;
4983
4997
  var getUpdateCookieAndStylesScript = (variants, contentId) => `
4984
4998
  window.${UPDATE_COOKIES_AND_STYLES_SCRIPT_NAME}(
4985
- "${contentId}",${JSON.stringify(variants)}, ${isHydrationTarget}
4999
+ "${contentId}",${JSON.stringify(variants)}, ${isHydrationTarget}, ${isAngularSDK}
4986
5000
  )`;
4987
5001
  var getUpdateVariantVisibilityScript = ({
4988
5002
  contentId,
@@ -4995,8 +5009,8 @@ var getUpdateVariantVisibilityScript = ({
4995
5009
  import {
4996
5010
  Show as Show14,
4997
5011
  onMount as onMount7,
4998
- on as on3,
4999
- createEffect as createEffect3,
5012
+ on as on4,
5013
+ createEffect as createEffect4,
5000
5014
  createMemo as createMemo16,
5001
5015
  createSignal as createSignal16
5002
5016
  } from "solid-js";
@@ -5008,7 +5022,7 @@ function getPreviewContent(_searchParams) {
5008
5022
  }
5009
5023
 
5010
5024
  // src/constants/sdk-version.ts
5011
- var SDK_VERSION = "4.0.1";
5025
+ var SDK_VERSION = "4.0.3";
5012
5026
 
5013
5027
  // src/helpers/sdk-headers.ts
5014
5028
  var getSdkHeaders = () => ({
@@ -5869,6 +5883,7 @@ var getWrapperClassName = (variationId) => {
5869
5883
 
5870
5884
  // src/components/content/components/enable-editor.tsx
5871
5885
  function EnableEditor(props) {
5886
+ const [hasExecuted, setHasExecuted] = createSignal16(false);
5872
5887
  const [ContentWrapper, setContentWrapper] = createSignal16(
5873
5888
  props.contentWrapper || "div"
5874
5889
  );
@@ -6050,8 +6065,12 @@ function EnableEditor(props) {
6050
6065
  );
6051
6066
  }
6052
6067
  const shouldTrackImpression = props.builderContextSignal.content && getDefaultCanTrack(props.canTrack);
6053
- if (shouldTrackImpression) {
6054
- const variationId = props.builderContextSignal.content?.testVariationId;
6068
+ const winningVariantId = getCookieSync({
6069
+ name: `builder.tests.${props.builderContextSignal.content?.id}`,
6070
+ canTrack: true
6071
+ });
6072
+ const variationId = props.builderContextSignal.content?.testVariationId;
6073
+ if (shouldTrackImpression && variationId === winningVariantId) {
6055
6074
  const contentId = props.builderContextSignal.content?.id;
6056
6075
  const apiKeyProp = props.apiKey;
6057
6076
  _track({
@@ -6060,7 +6079,7 @@ function EnableEditor(props) {
6060
6079
  canTrack: true,
6061
6080
  contentId,
6062
6081
  apiKey: apiKeyProp,
6063
- variationId: variationId !== contentId ? variationId : void 0
6082
+ variationId: winningVariantId !== contentId ? winningVariantId : void 0
6064
6083
  });
6065
6084
  }
6066
6085
  if (isPreviewing() && !isEditing()) {
@@ -6095,15 +6114,15 @@ function EnableEditor(props) {
6095
6114
  mergeNewContent(props.content);
6096
6115
  }
6097
6116
  }
6098
- createEffect3(on3(() => [onUpdateFn_0_props_content()], onUpdateFn_0));
6117
+ createEffect4(on4(() => [onUpdateFn_0_props_content()], onUpdateFn_0));
6099
6118
  const onUpdateFn_1_props_builderContextSignal_rootState = createMemo16(
6100
6119
  () => props.builderContextSignal.rootState
6101
6120
  );
6102
6121
  function onUpdateFn_1() {
6103
6122
  emitStateUpdate();
6104
6123
  }
6105
- createEffect3(
6106
- on3(
6124
+ createEffect4(
6125
+ on4(
6107
6126
  () => [onUpdateFn_1_props_builderContextSignal_rootState()],
6108
6127
  onUpdateFn_1
6109
6128
  )
@@ -6114,7 +6133,7 @@ function EnableEditor(props) {
6114
6133
  mergeNewRootState(props.data);
6115
6134
  }
6116
6135
  }
6117
- createEffect3(on3(() => [onUpdateFn_2_props_data()], onUpdateFn_2));
6136
+ createEffect4(on4(() => [onUpdateFn_2_props_data()], onUpdateFn_2));
6118
6137
  const onUpdateFn_3_props_locale = createMemo16(() => props.locale);
6119
6138
  function onUpdateFn_3() {
6120
6139
  if (props.locale) {
@@ -6123,7 +6142,7 @@ function EnableEditor(props) {
6123
6142
  });
6124
6143
  }
6125
6144
  }
6126
- createEffect3(on3(() => [onUpdateFn_3_props_locale()], onUpdateFn_3));
6145
+ createEffect4(on4(() => [onUpdateFn_3_props_locale()], onUpdateFn_3));
6127
6146
  return <><builder_context_default.Provider value={props.builderContextSignal}><Show14
6128
6147
  when={props.builderContextSignal.content || needsElementRefDivForEditing()}
6129
6148
  ><Dynamic5
@@ -6501,7 +6520,7 @@ function Symbol(props) {
6501
6520
  function onUpdateFn_0() {
6502
6521
  setContent();
6503
6522
  }
6504
- createEffect4(on4(() => [onUpdateFn_0_props_symbol()], onUpdateFn_0));
6523
+ createEffect5(on5(() => [onUpdateFn_0_props_symbol()], onUpdateFn_0));
6505
6524
  return <><div class={className()} {...{}} {...props.attributes} {...{}}><Content_variants_default
6506
6525
  nonce={props.builderContext.nonce}
6507
6526
  isNestedRender={true}
package/lib/node/index.js CHANGED
@@ -4159,9 +4159,8 @@ var _tmpl$13 = /* @__PURE__ */ template(`<div>`);
4159
4159
  function CustomCode(props) {
4160
4160
  const [scriptsInserted, setScriptsInserted] = createSignal([]);
4161
4161
  const [scriptsRun, setScriptsRun] = createSignal([]);
4162
- let elementRef;
4163
- onMount(() => {
4164
- if (!elementRef?.getElementsByTagName || typeof window === "undefined") {
4162
+ function runScripts() {
4163
+ if (!elementRef || !elementRef?.getElementsByTagName || typeof window === "undefined") {
4165
4164
  return;
4166
4165
  }
4167
4166
  const scripts = elementRef.getElementsByTagName("script");
@@ -4184,10 +4183,22 @@ function CustomCode(props) {
4184
4183
  scriptsRun().push(script.innerText);
4185
4184
  new Function(script.innerText)();
4186
4185
  } catch (error2) {
4186
+ logger.warn("[BUILDER.IO] `CustomCode`: Error running script:", error2);
4187
4187
  }
4188
4188
  }
4189
4189
  }
4190
+ }
4191
+ let elementRef;
4192
+ onMount(() => {
4193
+ runScripts();
4190
4194
  });
4195
+ const onUpdateFn_0_props_code = createMemo(() => props.code);
4196
+ function onUpdateFn_0() {
4197
+ if (isEditing()) {
4198
+ runScripts();
4199
+ }
4200
+ }
4201
+ createEffect(on(() => [onUpdateFn_0_props_code()], onUpdateFn_0));
4191
4202
  return (() => {
4192
4203
  const _el$ = _tmpl$13();
4193
4204
  const _ref$ = elementRef;
@@ -4251,6 +4262,7 @@ function Embed(props) {
4251
4262
  scriptsRun().push(script.innerText);
4252
4263
  new Function(script.innerText)();
4253
4264
  } catch (error2) {
4265
+ logger.warn("[BUILDER.IO] `Embed`: Error running script:", error2);
4254
4266
  }
4255
4267
  }
4256
4268
  }
@@ -5434,7 +5446,7 @@ function serializeIncludingFunctions(info) {
5434
5446
  }
5435
5447
 
5436
5448
  // src/components/content-variants/inlined-fns.ts
5437
- 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}";
5449
+ 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}";
5438
5450
  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}";
5439
5451
 
5440
5452
  // src/components/content-variants/helpers.ts
@@ -5463,6 +5475,7 @@ var checkShouldRenderVariants2 = ({
5463
5475
  return true;
5464
5476
  };
5465
5477
  var getIsHydrationTarget = (target) => target === "react" || target === "reactNative";
5478
+ var isAngularSDK = TARGET === "angular";
5466
5479
  var isHydrationTarget = getIsHydrationTarget(TARGET);
5467
5480
  var getInitVariantsFnsScriptString = () => `
5468
5481
  window.${UPDATE_COOKIES_AND_STYLES_SCRIPT_NAME} = ${UPDATE_COOKIES_AND_STYLES_SCRIPT}
@@ -5470,7 +5483,7 @@ var getInitVariantsFnsScriptString = () => `
5470
5483
  `;
5471
5484
  var getUpdateCookieAndStylesScript = (variants, contentId) => `
5472
5485
  window.${UPDATE_COOKIES_AND_STYLES_SCRIPT_NAME}(
5473
- "${contentId}",${JSON.stringify(variants)}, ${isHydrationTarget}
5486
+ "${contentId}",${JSON.stringify(variants)}, ${isHydrationTarget}, ${isAngularSDK}
5474
5487
  )`;
5475
5488
  var getUpdateVariantVisibilityScript = ({
5476
5489
  contentId,
@@ -5485,7 +5498,7 @@ function getPreviewContent(_searchParams) {
5485
5498
  }
5486
5499
 
5487
5500
  // src/constants/sdk-version.ts
5488
- var SDK_VERSION = "4.0.1";
5501
+ var SDK_VERSION = "4.0.3";
5489
5502
 
5490
5503
  // src/helpers/sdk-headers.ts
5491
5504
  var getSdkHeaders = () => ({
@@ -6340,6 +6353,7 @@ var getWrapperClassName = (variationId) => {
6340
6353
 
6341
6354
  // src/components/content/components/enable-editor.tsx
6342
6355
  function EnableEditor(props) {
6356
+ createSignal(false);
6343
6357
  const [ContentWrapper, setContentWrapper] = createSignal(props.contentWrapper || "div");
6344
6358
  const [httpReqsData, setHttpReqsData] = createSignal({});
6345
6359
  const [httpReqsPending, setHttpReqsPending] = createSignal({});
@@ -6506,8 +6520,12 @@ function EnableEditor(props) {
6506
6520
  window.addEventListener("builder:component:stateChangeListenerActivated", emitStateUpdate);
6507
6521
  }
6508
6522
  const shouldTrackImpression = props.builderContextSignal.content && getDefaultCanTrack(props.canTrack);
6509
- if (shouldTrackImpression) {
6510
- const variationId = props.builderContextSignal.content?.testVariationId;
6523
+ const winningVariantId = getCookieSync({
6524
+ name: `builder.tests.${props.builderContextSignal.content?.id}`,
6525
+ canTrack: true
6526
+ });
6527
+ const variationId = props.builderContextSignal.content?.testVariationId;
6528
+ if (shouldTrackImpression && variationId === winningVariantId) {
6511
6529
  const contentId = props.builderContextSignal.content?.id;
6512
6530
  const apiKeyProp = props.apiKey;
6513
6531
  _track({
@@ -6516,7 +6534,7 @@ function EnableEditor(props) {
6516
6534
  canTrack: true,
6517
6535
  contentId,
6518
6536
  apiKey: apiKeyProp,
6519
- variationId: variationId !== contentId ? variationId : void 0
6537
+ variationId: winningVariantId !== contentId ? winningVariantId : void 0
6520
6538
  });
6521
6539
  }
6522
6540
  if (isPreviewing() && !isEditing()) {
@@ -2079,7 +2079,7 @@ function SectionComponent(props) {
2079
2079
  var section_default = SectionComponent;
2080
2080
 
2081
2081
  // src/blocks/symbol/symbol.tsx
2082
- import { onMount as onMount9, on as on4, createEffect as createEffect4, createMemo as createMemo20, createSignal as createSignal20 } from "solid-js";
2082
+ import { onMount as onMount9, on as on5, createEffect as createEffect5, createMemo as createMemo20, createSignal as createSignal20 } from "solid-js";
2083
2083
 
2084
2084
  // src/components/content-variants/content-variants.tsx
2085
2085
  import { Show as Show16, For as For9, onMount as onMount8, createSignal as createSignal19, createMemo as createMemo19 } from "solid-js";
@@ -3787,13 +3787,12 @@ var componentInfo12 = {
3787
3787
  };
3788
3788
 
3789
3789
  // src/blocks/custom-code/custom-code.tsx
3790
- import { onMount as onMount5, createSignal as createSignal12 } from "solid-js";
3790
+ import { onMount as onMount5, on as on2, createEffect as createEffect2, createMemo as createMemo12, createSignal as createSignal12 } from "solid-js";
3791
3791
  function CustomCode(props) {
3792
3792
  const [scriptsInserted, setScriptsInserted] = createSignal12([]);
3793
3793
  const [scriptsRun, setScriptsRun] = createSignal12([]);
3794
- let elementRef;
3795
- onMount5(() => {
3796
- if (!elementRef?.getElementsByTagName || typeof window === "undefined") {
3794
+ function runScripts() {
3795
+ if (!elementRef || !elementRef?.getElementsByTagName || typeof window === "undefined") {
3797
3796
  return;
3798
3797
  }
3799
3798
  const scripts = elementRef.getElementsByTagName("script");
@@ -3820,10 +3819,25 @@ function CustomCode(props) {
3820
3819
  scriptsRun().push(script.innerText);
3821
3820
  new Function(script.innerText)();
3822
3821
  } catch (error2) {
3822
+ logger.warn(
3823
+ "[BUILDER.IO] `CustomCode`: Error running script:",
3824
+ error2
3825
+ );
3823
3826
  }
3824
3827
  }
3825
3828
  }
3829
+ }
3830
+ let elementRef;
3831
+ onMount5(() => {
3832
+ runScripts();
3826
3833
  });
3834
+ const onUpdateFn_0_props_code = createMemo12(() => props.code);
3835
+ function onUpdateFn_0() {
3836
+ if (isEditing()) {
3837
+ runScripts();
3838
+ }
3839
+ }
3840
+ createEffect2(on2(() => [onUpdateFn_0_props_code()], onUpdateFn_0));
3827
3841
  return <><div
3828
3842
  class={"builder-custom-code" + (props.replaceNodes ? " replace-nodes" : "")}
3829
3843
  ref={elementRef}
@@ -3851,7 +3865,7 @@ var componentInfo13 = {
3851
3865
  };
3852
3866
 
3853
3867
  // src/blocks/embed/embed.tsx
3854
- import { on as on2, createEffect as createEffect2, createMemo as createMemo13, createSignal as createSignal13 } from "solid-js";
3868
+ import { on as on3, createEffect as createEffect3, createMemo as createMemo13, createSignal as createSignal13 } from "solid-js";
3855
3869
 
3856
3870
  // src/blocks/embed/helpers.ts
3857
3871
  var SCRIPT_MIME_TYPES = ["text/javascript", "application/javascript", "application/ecmascript"];
@@ -3879,6 +3893,7 @@ function Embed(props) {
3879
3893
  scriptsRun().push(script.innerText);
3880
3894
  new Function(script.innerText)();
3881
3895
  } catch (error2) {
3896
+ logger.warn("[BUILDER.IO] `Embed`: Error running script:", error2);
3882
3897
  }
3883
3898
  }
3884
3899
  }
@@ -3892,8 +3907,8 @@ function Embed(props) {
3892
3907
  findAndRunScripts();
3893
3908
  }
3894
3909
  }
3895
- createEffect2(
3896
- on2(() => [onUpdateFn_0_elem(), onUpdateFn_0_ranInitFn__()], onUpdateFn_0)
3910
+ createEffect3(
3911
+ on3(() => [onUpdateFn_0_elem(), onUpdateFn_0_ranInitFn__()], onUpdateFn_0)
3897
3912
  );
3898
3913
  return <><div class="builder-embed" ref={elem} innerHTML={props.content} /></>;
3899
3914
  }
@@ -4934,7 +4949,7 @@ function serializeIncludingFunctions(info) {
4934
4949
  }
4935
4950
 
4936
4951
  // src/components/content-variants/inlined-fns.ts
4937
- 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}";
4952
+ 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}";
4938
4953
  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}";
4939
4954
 
4940
4955
  // src/components/content-variants/helpers.ts
@@ -4963,6 +4978,7 @@ var checkShouldRenderVariants2 = ({
4963
4978
  return true;
4964
4979
  };
4965
4980
  var getIsHydrationTarget = (target) => target === "react" || target === "reactNative";
4981
+ var isAngularSDK = TARGET === "angular";
4966
4982
  var isHydrationTarget = getIsHydrationTarget(TARGET);
4967
4983
  var getInitVariantsFnsScriptString = () => `
4968
4984
  window.${UPDATE_COOKIES_AND_STYLES_SCRIPT_NAME} = ${UPDATE_COOKIES_AND_STYLES_SCRIPT}
@@ -4970,7 +4986,7 @@ var getInitVariantsFnsScriptString = () => `
4970
4986
  `;
4971
4987
  var getUpdateCookieAndStylesScript = (variants, contentId) => `
4972
4988
  window.${UPDATE_COOKIES_AND_STYLES_SCRIPT_NAME}(
4973
- "${contentId}",${JSON.stringify(variants)}, ${isHydrationTarget}
4989
+ "${contentId}",${JSON.stringify(variants)}, ${isHydrationTarget}, ${isAngularSDK}
4974
4990
  )`;
4975
4991
  var getUpdateVariantVisibilityScript = ({
4976
4992
  contentId,
@@ -4983,8 +4999,8 @@ var getUpdateVariantVisibilityScript = ({
4983
4999
  import {
4984
5000
  Show as Show14,
4985
5001
  onMount as onMount7,
4986
- on as on3,
4987
- createEffect as createEffect3,
5002
+ on as on4,
5003
+ createEffect as createEffect4,
4988
5004
  createMemo as createMemo16,
4989
5005
  createSignal as createSignal16
4990
5006
  } from "solid-js";
@@ -4996,7 +5012,7 @@ function getPreviewContent(_searchParams) {
4996
5012
  }
4997
5013
 
4998
5014
  // src/constants/sdk-version.ts
4999
- var SDK_VERSION = "4.0.1";
5015
+ var SDK_VERSION = "4.0.3";
5000
5016
 
5001
5017
  // src/helpers/sdk-headers.ts
5002
5018
  var getSdkHeaders = () => ({
@@ -5851,6 +5867,7 @@ var getWrapperClassName = (variationId) => {
5851
5867
 
5852
5868
  // src/components/content/components/enable-editor.tsx
5853
5869
  function EnableEditor(props) {
5870
+ const [hasExecuted, setHasExecuted] = createSignal16(false);
5854
5871
  const [ContentWrapper, setContentWrapper] = createSignal16(
5855
5872
  props.contentWrapper || "div"
5856
5873
  );
@@ -6031,8 +6048,12 @@ function EnableEditor(props) {
6031
6048
  );
6032
6049
  }
6033
6050
  const shouldTrackImpression = props.builderContextSignal.content && getDefaultCanTrack(props.canTrack);
6034
- if (shouldTrackImpression) {
6035
- const variationId = props.builderContextSignal.content?.testVariationId;
6051
+ const winningVariantId = getCookieSync({
6052
+ name: `builder.tests.${props.builderContextSignal.content?.id}`,
6053
+ canTrack: true
6054
+ });
6055
+ const variationId = props.builderContextSignal.content?.testVariationId;
6056
+ if (shouldTrackImpression && variationId === winningVariantId) {
6036
6057
  const contentId = props.builderContextSignal.content?.id;
6037
6058
  const apiKeyProp = props.apiKey;
6038
6059
  _track({
@@ -6041,7 +6062,7 @@ function EnableEditor(props) {
6041
6062
  canTrack: true,
6042
6063
  contentId,
6043
6064
  apiKey: apiKeyProp,
6044
- variationId: variationId !== contentId ? variationId : void 0
6065
+ variationId: winningVariantId !== contentId ? winningVariantId : void 0
6045
6066
  });
6046
6067
  }
6047
6068
  if (isPreviewing() && !isEditing()) {
@@ -6076,15 +6097,15 @@ function EnableEditor(props) {
6076
6097
  mergeNewContent(props.content);
6077
6098
  }
6078
6099
  }
6079
- createEffect3(on3(() => [onUpdateFn_0_props_content()], onUpdateFn_0));
6100
+ createEffect4(on4(() => [onUpdateFn_0_props_content()], onUpdateFn_0));
6080
6101
  const onUpdateFn_1_props_builderContextSignal_rootState = createMemo16(
6081
6102
  () => props.builderContextSignal.rootState
6082
6103
  );
6083
6104
  function onUpdateFn_1() {
6084
6105
  emitStateUpdate();
6085
6106
  }
6086
- createEffect3(
6087
- on3(
6107
+ createEffect4(
6108
+ on4(
6088
6109
  () => [onUpdateFn_1_props_builderContextSignal_rootState()],
6089
6110
  onUpdateFn_1
6090
6111
  )
@@ -6095,7 +6116,7 @@ function EnableEditor(props) {
6095
6116
  mergeNewRootState(props.data);
6096
6117
  }
6097
6118
  }
6098
- createEffect3(on3(() => [onUpdateFn_2_props_data()], onUpdateFn_2));
6119
+ createEffect4(on4(() => [onUpdateFn_2_props_data()], onUpdateFn_2));
6099
6120
  const onUpdateFn_3_props_locale = createMemo16(() => props.locale);
6100
6121
  function onUpdateFn_3() {
6101
6122
  if (props.locale) {
@@ -6104,7 +6125,7 @@ function EnableEditor(props) {
6104
6125
  });
6105
6126
  }
6106
6127
  }
6107
- createEffect3(on3(() => [onUpdateFn_3_props_locale()], onUpdateFn_3));
6128
+ createEffect4(on4(() => [onUpdateFn_3_props_locale()], onUpdateFn_3));
6108
6129
  return <><builder_context_default.Provider value={props.builderContextSignal}><Show14
6109
6130
  when={props.builderContextSignal.content || needsElementRefDivForEditing()}
6110
6131
  ><Dynamic5
@@ -6482,7 +6503,7 @@ function Symbol(props) {
6482
6503
  function onUpdateFn_0() {
6483
6504
  setContent();
6484
6505
  }
6485
- createEffect4(on4(() => [onUpdateFn_0_props_symbol()], onUpdateFn_0));
6506
+ createEffect5(on5(() => [onUpdateFn_0_props_symbol()], onUpdateFn_0));
6486
6507
  return <><div class={className()} {...{}} {...props.attributes} {...{}}><Content_variants_default
6487
6508
  nonce={props.builderContext.nonce}
6488
6509
  isNestedRender={true}