@builder.io/sdk-solid 4.0.2 → 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.
@@ -4001,9 +4001,8 @@ var _tmpl$13 = /* @__PURE__ */ template(`<div>`);
4001
4001
  function CustomCode(props) {
4002
4002
  const [scriptsInserted, setScriptsInserted] = createSignal([]);
4003
4003
  const [scriptsRun, setScriptsRun] = createSignal([]);
4004
- let elementRef;
4005
- onMount(() => {
4006
- if (!elementRef?.getElementsByTagName || typeof window === "undefined") {
4004
+ function runScripts() {
4005
+ if (!elementRef || !elementRef?.getElementsByTagName || typeof window === "undefined") {
4007
4006
  return;
4008
4007
  }
4009
4008
  const scripts = elementRef.getElementsByTagName("script");
@@ -4026,11 +4025,22 @@ function CustomCode(props) {
4026
4025
  scriptsRun().push(script.innerText);
4027
4026
  new Function(script.innerText)();
4028
4027
  } catch (error) {
4029
- console.warn("`CustomCode`: Error running script:", error);
4028
+ logger.warn("[BUILDER.IO] `CustomCode`: Error running script:", error);
4030
4029
  }
4031
4030
  }
4032
4031
  }
4032
+ }
4033
+ let elementRef;
4034
+ onMount(() => {
4035
+ runScripts();
4033
4036
  });
4037
+ const onUpdateFn_0_props_code = createMemo(() => props.code);
4038
+ function onUpdateFn_0() {
4039
+ if (isEditing()) {
4040
+ runScripts();
4041
+ }
4042
+ }
4043
+ createEffect(on(() => [onUpdateFn_0_props_code()], onUpdateFn_0));
4034
4044
  return (() => {
4035
4045
  const _el$ = _tmpl$13();
4036
4046
  const _ref$ = elementRef;
@@ -4094,7 +4104,7 @@ function Embed(props) {
4094
4104
  scriptsRun().push(script.innerText);
4095
4105
  new Function(script.innerText)();
4096
4106
  } catch (error) {
4097
- console.warn("`Embed`: Error running script:", error);
4107
+ logger.warn("[BUILDER.IO] `Embed`: Error running script:", error);
4098
4108
  }
4099
4109
  }
4100
4110
  }
@@ -5279,7 +5289,7 @@ function serializeIncludingFunctions(info) {
5279
5289
  }
5280
5290
 
5281
5291
  // src/components/content-variants/inlined-fns.ts
5282
- 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}";
5292
+ 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}";
5283
5293
  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}";
5284
5294
 
5285
5295
  // src/components/content-variants/helpers.ts
@@ -5308,6 +5318,7 @@ var checkShouldRenderVariants2 = ({
5308
5318
  return true;
5309
5319
  };
5310
5320
  var getIsHydrationTarget = (target) => target === "react" || target === "reactNative";
5321
+ var isAngularSDK = TARGET === "angular";
5311
5322
  var isHydrationTarget = getIsHydrationTarget(TARGET);
5312
5323
  var getInitVariantsFnsScriptString = () => `
5313
5324
  window.${UPDATE_COOKIES_AND_STYLES_SCRIPT_NAME} = ${UPDATE_COOKIES_AND_STYLES_SCRIPT}
@@ -5315,7 +5326,7 @@ var getInitVariantsFnsScriptString = () => `
5315
5326
  `;
5316
5327
  var getUpdateCookieAndStylesScript = (variants, contentId) => `
5317
5328
  window.${UPDATE_COOKIES_AND_STYLES_SCRIPT_NAME}(
5318
- "${contentId}",${JSON.stringify(variants)}, ${isHydrationTarget}
5329
+ "${contentId}",${JSON.stringify(variants)}, ${isHydrationTarget}, ${isAngularSDK}
5319
5330
  )`;
5320
5331
  var getUpdateVariantVisibilityScript = ({
5321
5332
  contentId,
@@ -5330,7 +5341,7 @@ function getPreviewContent(_searchParams) {
5330
5341
  }
5331
5342
 
5332
5343
  // src/constants/sdk-version.ts
5333
- var SDK_VERSION = "4.0.2";
5344
+ var SDK_VERSION = "4.0.3";
5334
5345
 
5335
5346
  // src/helpers/sdk-headers.ts
5336
5347
  var getSdkHeaders = () => ({
@@ -1916,7 +1916,7 @@ function SectionComponent(props) {
1916
1916
  var section_default = SectionComponent;
1917
1917
 
1918
1918
  // src/blocks/symbol/symbol.tsx
1919
- import { onMount as onMount9, on as on4, createEffect as createEffect4, createMemo as createMemo20, createSignal as createSignal20 } from "solid-js";
1919
+ import { onMount as onMount9, on as on5, createEffect as createEffect5, createMemo as createMemo20, createSignal as createSignal20 } from "solid-js";
1920
1920
 
1921
1921
  // src/components/content-variants/content-variants.tsx
1922
1922
  import { Show as Show16, For as For9, onMount as onMount8, createSignal as createSignal19, createMemo as createMemo19 } from "solid-js";
@@ -3625,13 +3625,12 @@ var componentInfo12 = {
3625
3625
  };
3626
3626
 
3627
3627
  // src/blocks/custom-code/custom-code.tsx
3628
- import { onMount as onMount5, createSignal as createSignal12 } from "solid-js";
3628
+ import { onMount as onMount5, on as on2, createEffect as createEffect2, createMemo as createMemo12, createSignal as createSignal12 } from "solid-js";
3629
3629
  function CustomCode(props) {
3630
3630
  const [scriptsInserted, setScriptsInserted] = createSignal12([]);
3631
3631
  const [scriptsRun, setScriptsRun] = createSignal12([]);
3632
- let elementRef;
3633
- onMount5(() => {
3634
- if (!elementRef?.getElementsByTagName || typeof window === "undefined") {
3632
+ function runScripts() {
3633
+ if (!elementRef || !elementRef?.getElementsByTagName || typeof window === "undefined") {
3635
3634
  return;
3636
3635
  }
3637
3636
  const scripts = elementRef.getElementsByTagName("script");
@@ -3658,11 +3657,25 @@ function CustomCode(props) {
3658
3657
  scriptsRun().push(script.innerText);
3659
3658
  new Function(script.innerText)();
3660
3659
  } catch (error) {
3661
- console.warn("`CustomCode`: Error running script:", error);
3660
+ logger.warn(
3661
+ "[BUILDER.IO] `CustomCode`: Error running script:",
3662
+ error
3663
+ );
3662
3664
  }
3663
3665
  }
3664
3666
  }
3667
+ }
3668
+ let elementRef;
3669
+ onMount5(() => {
3670
+ runScripts();
3665
3671
  });
3672
+ const onUpdateFn_0_props_code = createMemo12(() => props.code);
3673
+ function onUpdateFn_0() {
3674
+ if (isEditing()) {
3675
+ runScripts();
3676
+ }
3677
+ }
3678
+ createEffect2(on2(() => [onUpdateFn_0_props_code()], onUpdateFn_0));
3666
3679
  return <><div
3667
3680
  class={"builder-custom-code" + (props.replaceNodes ? " replace-nodes" : "")}
3668
3681
  ref={elementRef}
@@ -3690,7 +3703,7 @@ var componentInfo13 = {
3690
3703
  };
3691
3704
 
3692
3705
  // src/blocks/embed/embed.tsx
3693
- import { on as on2, createEffect as createEffect2, createMemo as createMemo13, createSignal as createSignal13 } from "solid-js";
3706
+ import { on as on3, createEffect as createEffect3, createMemo as createMemo13, createSignal as createSignal13 } from "solid-js";
3694
3707
 
3695
3708
  // src/blocks/embed/helpers.ts
3696
3709
  var SCRIPT_MIME_TYPES = ["text/javascript", "application/javascript", "application/ecmascript"];
@@ -3718,7 +3731,7 @@ function Embed(props) {
3718
3731
  scriptsRun().push(script.innerText);
3719
3732
  new Function(script.innerText)();
3720
3733
  } catch (error) {
3721
- console.warn("`Embed`: Error running script:", error);
3734
+ logger.warn("[BUILDER.IO] `Embed`: Error running script:", error);
3722
3735
  }
3723
3736
  }
3724
3737
  }
@@ -3732,8 +3745,8 @@ function Embed(props) {
3732
3745
  findAndRunScripts();
3733
3746
  }
3734
3747
  }
3735
- createEffect2(
3736
- on2(() => [onUpdateFn_0_elem(), onUpdateFn_0_ranInitFn__()], onUpdateFn_0)
3748
+ createEffect3(
3749
+ on3(() => [onUpdateFn_0_elem(), onUpdateFn_0_ranInitFn__()], onUpdateFn_0)
3737
3750
  );
3738
3751
  return <><div class="builder-embed" ref={elem} innerHTML={props.content} /></>;
3739
3752
  }
@@ -4775,7 +4788,7 @@ function serializeIncludingFunctions(info) {
4775
4788
  }
4776
4789
 
4777
4790
  // src/components/content-variants/inlined-fns.ts
4778
- 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}";
4791
+ 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}";
4779
4792
  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}";
4780
4793
 
4781
4794
  // src/components/content-variants/helpers.ts
@@ -4804,6 +4817,7 @@ var checkShouldRenderVariants2 = ({
4804
4817
  return true;
4805
4818
  };
4806
4819
  var getIsHydrationTarget = (target) => target === "react" || target === "reactNative";
4820
+ var isAngularSDK = TARGET === "angular";
4807
4821
  var isHydrationTarget = getIsHydrationTarget(TARGET);
4808
4822
  var getInitVariantsFnsScriptString = () => `
4809
4823
  window.${UPDATE_COOKIES_AND_STYLES_SCRIPT_NAME} = ${UPDATE_COOKIES_AND_STYLES_SCRIPT}
@@ -4811,7 +4825,7 @@ var getInitVariantsFnsScriptString = () => `
4811
4825
  `;
4812
4826
  var getUpdateCookieAndStylesScript = (variants, contentId) => `
4813
4827
  window.${UPDATE_COOKIES_AND_STYLES_SCRIPT_NAME}(
4814
- "${contentId}",${JSON.stringify(variants)}, ${isHydrationTarget}
4828
+ "${contentId}",${JSON.stringify(variants)}, ${isHydrationTarget}, ${isAngularSDK}
4815
4829
  )`;
4816
4830
  var getUpdateVariantVisibilityScript = ({
4817
4831
  contentId,
@@ -4824,8 +4838,8 @@ var getUpdateVariantVisibilityScript = ({
4824
4838
  import {
4825
4839
  Show as Show14,
4826
4840
  onMount as onMount7,
4827
- on as on3,
4828
- createEffect as createEffect3,
4841
+ on as on4,
4842
+ createEffect as createEffect4,
4829
4843
  createMemo as createMemo16,
4830
4844
  createSignal as createSignal16
4831
4845
  } from "solid-js";
@@ -4837,7 +4851,7 @@ function getPreviewContent(_searchParams) {
4837
4851
  }
4838
4852
 
4839
4853
  // src/constants/sdk-version.ts
4840
- var SDK_VERSION = "4.0.2";
4854
+ var SDK_VERSION = "4.0.3";
4841
4855
 
4842
4856
  // src/helpers/sdk-headers.ts
4843
4857
  var getSdkHeaders = () => ({
@@ -5929,15 +5943,15 @@ function EnableEditor(props) {
5929
5943
  mergeNewContent(props.content);
5930
5944
  }
5931
5945
  }
5932
- createEffect3(on3(() => [onUpdateFn_0_props_content()], onUpdateFn_0));
5946
+ createEffect4(on4(() => [onUpdateFn_0_props_content()], onUpdateFn_0));
5933
5947
  const onUpdateFn_1_props_builderContextSignal_rootState = createMemo16(
5934
5948
  () => props.builderContextSignal.rootState
5935
5949
  );
5936
5950
  function onUpdateFn_1() {
5937
5951
  emitStateUpdate();
5938
5952
  }
5939
- createEffect3(
5940
- on3(
5953
+ createEffect4(
5954
+ on4(
5941
5955
  () => [onUpdateFn_1_props_builderContextSignal_rootState()],
5942
5956
  onUpdateFn_1
5943
5957
  )
@@ -5948,7 +5962,7 @@ function EnableEditor(props) {
5948
5962
  mergeNewRootState(props.data);
5949
5963
  }
5950
5964
  }
5951
- createEffect3(on3(() => [onUpdateFn_2_props_data()], onUpdateFn_2));
5965
+ createEffect4(on4(() => [onUpdateFn_2_props_data()], onUpdateFn_2));
5952
5966
  const onUpdateFn_3_props_locale = createMemo16(() => props.locale);
5953
5967
  function onUpdateFn_3() {
5954
5968
  if (props.locale) {
@@ -5957,7 +5971,7 @@ function EnableEditor(props) {
5957
5971
  });
5958
5972
  }
5959
5973
  }
5960
- createEffect3(on3(() => [onUpdateFn_3_props_locale()], onUpdateFn_3));
5974
+ createEffect4(on4(() => [onUpdateFn_3_props_locale()], onUpdateFn_3));
5961
5975
  return <><builder_context_default.Provider value={props.builderContextSignal}><Show14
5962
5976
  when={props.builderContextSignal.content || needsElementRefDivForEditing()}
5963
5977
  ><Dynamic5
@@ -6335,7 +6349,7 @@ function Symbol(props) {
6335
6349
  function onUpdateFn_0() {
6336
6350
  setContent();
6337
6351
  }
6338
- createEffect4(on4(() => [onUpdateFn_0_props_symbol()], onUpdateFn_0));
6352
+ createEffect5(on5(() => [onUpdateFn_0_props_symbol()], onUpdateFn_0));
6339
6353
  return <><div class={className()} {...{}} {...props.attributes} {...{}}><Content_variants_default
6340
6354
  nonce={props.builderContext.nonce}
6341
6355
  isNestedRender={true}
@@ -3990,9 +3990,8 @@ var _tmpl$13 = /* @__PURE__ */ template(`<div>`);
3990
3990
  function CustomCode(props) {
3991
3991
  const [scriptsInserted, setScriptsInserted] = createSignal([]);
3992
3992
  const [scriptsRun, setScriptsRun] = createSignal([]);
3993
- let elementRef;
3994
- onMount(() => {
3995
- if (!elementRef?.getElementsByTagName || typeof window === "undefined") {
3993
+ function runScripts() {
3994
+ if (!elementRef || !elementRef?.getElementsByTagName || typeof window === "undefined") {
3996
3995
  return;
3997
3996
  }
3998
3997
  const scripts = elementRef.getElementsByTagName("script");
@@ -4015,10 +4014,22 @@ function CustomCode(props) {
4015
4014
  scriptsRun().push(script.innerText);
4016
4015
  new Function(script.innerText)();
4017
4016
  } catch (error) {
4017
+ logger.warn("[BUILDER.IO] `CustomCode`: Error running script:", error);
4018
4018
  }
4019
4019
  }
4020
4020
  }
4021
+ }
4022
+ let elementRef;
4023
+ onMount(() => {
4024
+ runScripts();
4021
4025
  });
4026
+ const onUpdateFn_0_props_code = createMemo(() => props.code);
4027
+ function onUpdateFn_0() {
4028
+ if (isEditing()) {
4029
+ runScripts();
4030
+ }
4031
+ }
4032
+ createEffect(on(() => [onUpdateFn_0_props_code()], onUpdateFn_0));
4022
4033
  return (() => {
4023
4034
  const _el$ = _tmpl$13();
4024
4035
  const _ref$ = elementRef;
@@ -4082,6 +4093,7 @@ function Embed(props) {
4082
4093
  scriptsRun().push(script.innerText);
4083
4094
  new Function(script.innerText)();
4084
4095
  } catch (error) {
4096
+ logger.warn("[BUILDER.IO] `Embed`: Error running script:", error);
4085
4097
  }
4086
4098
  }
4087
4099
  }
@@ -5265,7 +5277,7 @@ function serializeIncludingFunctions(info) {
5265
5277
  }
5266
5278
 
5267
5279
  // src/components/content-variants/inlined-fns.ts
5268
- 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}";
5280
+ 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}";
5269
5281
  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}";
5270
5282
 
5271
5283
  // src/components/content-variants/helpers.ts
@@ -5294,6 +5306,7 @@ var checkShouldRenderVariants2 = ({
5294
5306
  return true;
5295
5307
  };
5296
5308
  var getIsHydrationTarget = (target) => target === "react" || target === "reactNative";
5309
+ var isAngularSDK = TARGET === "angular";
5297
5310
  var isHydrationTarget = getIsHydrationTarget(TARGET);
5298
5311
  var getInitVariantsFnsScriptString = () => `
5299
5312
  window.${UPDATE_COOKIES_AND_STYLES_SCRIPT_NAME} = ${UPDATE_COOKIES_AND_STYLES_SCRIPT}
@@ -5301,7 +5314,7 @@ var getInitVariantsFnsScriptString = () => `
5301
5314
  `;
5302
5315
  var getUpdateCookieAndStylesScript = (variants, contentId) => `
5303
5316
  window.${UPDATE_COOKIES_AND_STYLES_SCRIPT_NAME}(
5304
- "${contentId}",${JSON.stringify(variants)}, ${isHydrationTarget}
5317
+ "${contentId}",${JSON.stringify(variants)}, ${isHydrationTarget}, ${isAngularSDK}
5305
5318
  )`;
5306
5319
  var getUpdateVariantVisibilityScript = ({
5307
5320
  contentId,
@@ -5316,7 +5329,7 @@ function getPreviewContent(_searchParams) {
5316
5329
  }
5317
5330
 
5318
5331
  // src/constants/sdk-version.ts
5319
- var SDK_VERSION = "4.0.2";
5332
+ var SDK_VERSION = "4.0.3";
5320
5333
 
5321
5334
  // src/helpers/sdk-headers.ts
5322
5335
  var getSdkHeaders = () => ({
@@ -1908,7 +1908,7 @@ function SectionComponent(props) {
1908
1908
  var section_default = SectionComponent;
1909
1909
 
1910
1910
  // src/blocks/symbol/symbol.tsx
1911
- import { onMount as onMount9, on as on4, createEffect as createEffect4, createMemo as createMemo20, createSignal as createSignal20 } from "solid-js";
1911
+ import { onMount as onMount9, on as on5, createEffect as createEffect5, createMemo as createMemo20, createSignal as createSignal20 } from "solid-js";
1912
1912
 
1913
1913
  // src/components/content-variants/content-variants.tsx
1914
1914
  import { Show as Show16, For as For9, onMount as onMount8, createSignal as createSignal19, createMemo as createMemo19 } from "solid-js";
@@ -3616,13 +3616,12 @@ var componentInfo12 = {
3616
3616
  };
3617
3617
 
3618
3618
  // src/blocks/custom-code/custom-code.tsx
3619
- import { onMount as onMount5, createSignal as createSignal12 } from "solid-js";
3619
+ import { onMount as onMount5, on as on2, createEffect as createEffect2, createMemo as createMemo12, createSignal as createSignal12 } from "solid-js";
3620
3620
  function CustomCode(props) {
3621
3621
  const [scriptsInserted, setScriptsInserted] = createSignal12([]);
3622
3622
  const [scriptsRun, setScriptsRun] = createSignal12([]);
3623
- let elementRef;
3624
- onMount5(() => {
3625
- if (!elementRef?.getElementsByTagName || typeof window === "undefined") {
3623
+ function runScripts() {
3624
+ if (!elementRef || !elementRef?.getElementsByTagName || typeof window === "undefined") {
3626
3625
  return;
3627
3626
  }
3628
3627
  const scripts = elementRef.getElementsByTagName("script");
@@ -3649,10 +3648,25 @@ function CustomCode(props) {
3649
3648
  scriptsRun().push(script.innerText);
3650
3649
  new Function(script.innerText)();
3651
3650
  } catch (error) {
3651
+ logger.warn(
3652
+ "[BUILDER.IO] `CustomCode`: Error running script:",
3653
+ error
3654
+ );
3652
3655
  }
3653
3656
  }
3654
3657
  }
3658
+ }
3659
+ let elementRef;
3660
+ onMount5(() => {
3661
+ runScripts();
3655
3662
  });
3663
+ const onUpdateFn_0_props_code = createMemo12(() => props.code);
3664
+ function onUpdateFn_0() {
3665
+ if (isEditing()) {
3666
+ runScripts();
3667
+ }
3668
+ }
3669
+ createEffect2(on2(() => [onUpdateFn_0_props_code()], onUpdateFn_0));
3656
3670
  return <><div
3657
3671
  class={"builder-custom-code" + (props.replaceNodes ? " replace-nodes" : "")}
3658
3672
  ref={elementRef}
@@ -3680,7 +3694,7 @@ var componentInfo13 = {
3680
3694
  };
3681
3695
 
3682
3696
  // src/blocks/embed/embed.tsx
3683
- import { on as on2, createEffect as createEffect2, createMemo as createMemo13, createSignal as createSignal13 } from "solid-js";
3697
+ import { on as on3, createEffect as createEffect3, createMemo as createMemo13, createSignal as createSignal13 } from "solid-js";
3684
3698
 
3685
3699
  // src/blocks/embed/helpers.ts
3686
3700
  var SCRIPT_MIME_TYPES = ["text/javascript", "application/javascript", "application/ecmascript"];
@@ -3708,6 +3722,7 @@ function Embed(props) {
3708
3722
  scriptsRun().push(script.innerText);
3709
3723
  new Function(script.innerText)();
3710
3724
  } catch (error) {
3725
+ logger.warn("[BUILDER.IO] `Embed`: Error running script:", error);
3711
3726
  }
3712
3727
  }
3713
3728
  }
@@ -3721,8 +3736,8 @@ function Embed(props) {
3721
3736
  findAndRunScripts();
3722
3737
  }
3723
3738
  }
3724
- createEffect2(
3725
- on2(() => [onUpdateFn_0_elem(), onUpdateFn_0_ranInitFn__()], onUpdateFn_0)
3739
+ createEffect3(
3740
+ on3(() => [onUpdateFn_0_elem(), onUpdateFn_0_ranInitFn__()], onUpdateFn_0)
3726
3741
  );
3727
3742
  return <><div class="builder-embed" ref={elem} innerHTML={props.content} /></>;
3728
3743
  }
@@ -4763,7 +4778,7 @@ function serializeIncludingFunctions(info) {
4763
4778
  }
4764
4779
 
4765
4780
  // src/components/content-variants/inlined-fns.ts
4766
- 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}";
4781
+ 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}";
4767
4782
  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}";
4768
4783
 
4769
4784
  // src/components/content-variants/helpers.ts
@@ -4792,6 +4807,7 @@ var checkShouldRenderVariants2 = ({
4792
4807
  return true;
4793
4808
  };
4794
4809
  var getIsHydrationTarget = (target) => target === "react" || target === "reactNative";
4810
+ var isAngularSDK = TARGET === "angular";
4795
4811
  var isHydrationTarget = getIsHydrationTarget(TARGET);
4796
4812
  var getInitVariantsFnsScriptString = () => `
4797
4813
  window.${UPDATE_COOKIES_AND_STYLES_SCRIPT_NAME} = ${UPDATE_COOKIES_AND_STYLES_SCRIPT}
@@ -4799,7 +4815,7 @@ var getInitVariantsFnsScriptString = () => `
4799
4815
  `;
4800
4816
  var getUpdateCookieAndStylesScript = (variants, contentId) => `
4801
4817
  window.${UPDATE_COOKIES_AND_STYLES_SCRIPT_NAME}(
4802
- "${contentId}",${JSON.stringify(variants)}, ${isHydrationTarget}
4818
+ "${contentId}",${JSON.stringify(variants)}, ${isHydrationTarget}, ${isAngularSDK}
4803
4819
  )`;
4804
4820
  var getUpdateVariantVisibilityScript = ({
4805
4821
  contentId,
@@ -4812,8 +4828,8 @@ var getUpdateVariantVisibilityScript = ({
4812
4828
  import {
4813
4829
  Show as Show14,
4814
4830
  onMount as onMount7,
4815
- on as on3,
4816
- createEffect as createEffect3,
4831
+ on as on4,
4832
+ createEffect as createEffect4,
4817
4833
  createMemo as createMemo16,
4818
4834
  createSignal as createSignal16
4819
4835
  } from "solid-js";
@@ -4825,7 +4841,7 @@ function getPreviewContent(_searchParams) {
4825
4841
  }
4826
4842
 
4827
4843
  // src/constants/sdk-version.ts
4828
- var SDK_VERSION = "4.0.2";
4844
+ var SDK_VERSION = "4.0.3";
4829
4845
 
4830
4846
  // src/helpers/sdk-headers.ts
4831
4847
  var getSdkHeaders = () => ({
@@ -5910,15 +5926,15 @@ function EnableEditor(props) {
5910
5926
  mergeNewContent(props.content);
5911
5927
  }
5912
5928
  }
5913
- createEffect3(on3(() => [onUpdateFn_0_props_content()], onUpdateFn_0));
5929
+ createEffect4(on4(() => [onUpdateFn_0_props_content()], onUpdateFn_0));
5914
5930
  const onUpdateFn_1_props_builderContextSignal_rootState = createMemo16(
5915
5931
  () => props.builderContextSignal.rootState
5916
5932
  );
5917
5933
  function onUpdateFn_1() {
5918
5934
  emitStateUpdate();
5919
5935
  }
5920
- createEffect3(
5921
- on3(
5936
+ createEffect4(
5937
+ on4(
5922
5938
  () => [onUpdateFn_1_props_builderContextSignal_rootState()],
5923
5939
  onUpdateFn_1
5924
5940
  )
@@ -5929,7 +5945,7 @@ function EnableEditor(props) {
5929
5945
  mergeNewRootState(props.data);
5930
5946
  }
5931
5947
  }
5932
- createEffect3(on3(() => [onUpdateFn_2_props_data()], onUpdateFn_2));
5948
+ createEffect4(on4(() => [onUpdateFn_2_props_data()], onUpdateFn_2));
5933
5949
  const onUpdateFn_3_props_locale = createMemo16(() => props.locale);
5934
5950
  function onUpdateFn_3() {
5935
5951
  if (props.locale) {
@@ -5938,7 +5954,7 @@ function EnableEditor(props) {
5938
5954
  });
5939
5955
  }
5940
5956
  }
5941
- createEffect3(on3(() => [onUpdateFn_3_props_locale()], onUpdateFn_3));
5957
+ createEffect4(on4(() => [onUpdateFn_3_props_locale()], onUpdateFn_3));
5942
5958
  return <><builder_context_default.Provider value={props.builderContextSignal}><Show14
5943
5959
  when={props.builderContextSignal.content || needsElementRefDivForEditing()}
5944
5960
  ><Dynamic5
@@ -6316,7 +6332,7 @@ function Symbol(props) {
6316
6332
  function onUpdateFn_0() {
6317
6333
  setContent();
6318
6334
  }
6319
- createEffect4(on4(() => [onUpdateFn_0_props_symbol()], onUpdateFn_0));
6335
+ createEffect5(on5(() => [onUpdateFn_0_props_symbol()], onUpdateFn_0));
6320
6336
  return <><div class={className()} {...{}} {...props.attributes} {...{}}><Content_variants_default
6321
6337
  nonce={props.builderContext.nonce}
6322
6338
  isNestedRender={true}
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.2";
8525
+ var SDK_VERSION = "4.0.3";
8515
8526
 
8516
8527
  // src/helpers/sdk-headers.ts
8517
8528
  var getSdkHeaders = () => ({