@builder.io/sdk-solid 4.0.2 → 4.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/node/dev.jsx CHANGED
@@ -1651,9 +1651,10 @@ function Block(props) {
1651
1651
  var Block_default = Block;
1652
1652
 
1653
1653
  // src/components/blocks/blocks-wrapper.tsx
1654
- import { onMount as onMount3, createMemo as createMemo6 } from "solid-js";
1654
+ import { onMount as onMount3, on as on2, createEffect as createEffect2, createMemo as createMemo6, createSignal as createSignal6 } from "solid-js";
1655
1655
  import { Dynamic as Dynamic4 } from "solid-js/web";
1656
1656
  function BlocksWrapper(props) {
1657
+ const [shouldUpdate, setShouldUpdate] = createSignal6(false);
1657
1658
  const className = createMemo6(() => {
1658
1659
  return [
1659
1660
  "builder-blocks",
@@ -1700,9 +1701,13 @@ function BlocksWrapper(props) {
1700
1701
  let blocksWrapperRef;
1701
1702
  onMount3(() => {
1702
1703
  });
1704
+ const onUpdateFn_0_props_blocks = createMemo6(() => props.blocks);
1705
+ function onUpdateFn_0() {
1706
+ }
1707
+ createEffect2(on2(() => [onUpdateFn_0_props_blocks()], onUpdateFn_0));
1703
1708
  return <>
1704
1709
  <Dynamic4
1705
- class={className() + " dynamic-3d7ff108"}
1710
+ class={className() + " dynamic-023c60f2"}
1706
1711
  ref={blocksWrapperRef}
1707
1712
  builder-path={dataPath()}
1708
1713
  builder-parent-id={props.parent}
@@ -1714,7 +1719,7 @@ function BlocksWrapper(props) {
1714
1719
  {...props.BlocksWrapperProps}
1715
1720
  component={props.BlocksWrapper}
1716
1721
  >{props.children}</Dynamic4>
1717
- <style>{`.dynamic-3d7ff108 {
1722
+ <style>{`.dynamic-023c60f2 {
1718
1723
  display: flex;
1719
1724
  flex-direction: column;
1720
1725
  align-items: stretch;
@@ -2018,10 +2023,11 @@ function Image(props) {
2018
2023
  <picture>
2019
2024
  <Show8 when={webpSrcSet()}><source type="image/webp" srcset={webpSrcSet()} /></Show8>
2020
2025
  <img
2021
- class={"builder-image" + (props.className ? " " + props.className : "") + " img-dc6700b4"}
2026
+ class={"builder-image" + (props.className ? " " + props.className : "") + " img-040e729e"}
2022
2027
  loading={props.highPriority ? "eager" : "lazy"}
2023
2028
  fetchpriority={props.highPriority ? "high" : "auto"}
2024
2029
  alt={props.altText}
2030
+ title={props.title}
2025
2031
  role={props.altText ? void 0 : "presentation"}
2026
2032
  style={{
2027
2033
  "object-position": props.backgroundPosition || "center",
@@ -2036,22 +2042,22 @@ function Image(props) {
2036
2042
  <Show8
2037
2043
  when={props.aspectRatio && !(props.builderBlock?.children?.length && props.fitContent)}
2038
2044
  ><div
2039
- class="builder-image-sizer div-dc6700b4"
2045
+ class="builder-image-sizer div-040e729e"
2040
2046
  style={{
2041
2047
  "padding-top": props.aspectRatio * 100 + "%"
2042
2048
  }}
2043
2049
  /></Show8>
2044
2050
  <Show8 when={props.builderBlock?.children?.length && props.fitContent}>{props.children}</Show8>
2045
- <Show8 when={!props.fitContent && props.builderBlock?.children?.length}><div class="div-dc6700b4-2">{props.children}</div></Show8>
2051
+ <Show8 when={!props.fitContent && props.builderBlock?.children?.length}><div class="div-040e729e-2">{props.children}</div></Show8>
2046
2052
  </>
2047
- <style>{`.img-dc6700b4 {
2053
+ <style>{`.img-040e729e {
2048
2054
  opacity: 1;
2049
2055
  transition: opacity 0.2s ease-in-out;
2050
- }.div-dc6700b4 {
2056
+ }.div-040e729e {
2051
2057
  width: 100%;
2052
2058
  pointer-events: none;
2053
2059
  font-size: 0;
2054
- }.div-dc6700b4-2 {
2060
+ }.div-040e729e-2 {
2055
2061
  display: flex;
2056
2062
  flex-direction: column;
2057
2063
  align-items: stretch;
@@ -2087,7 +2093,7 @@ function SectionComponent(props) {
2087
2093
  var section_default = SectionComponent;
2088
2094
 
2089
2095
  // 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";
2096
+ import { onMount as onMount9, on as on6, createEffect as createEffect6, createMemo as createMemo20, createSignal as createSignal20 } from "solid-js";
2091
2097
 
2092
2098
  // src/components/content-variants/content-variants.tsx
2093
2099
  import { Show as Show16, For as For9, onMount as onMount8, createSignal as createSignal19, createMemo as createMemo19 } from "solid-js";
@@ -2986,6 +2992,10 @@ var componentInfo5 = {
2986
2992
  name: "altText",
2987
2993
  type: "string",
2988
2994
  helperText: "Text to display when the user has images off"
2995
+ }, {
2996
+ name: "title",
2997
+ type: "string",
2998
+ helperText: "Text to display when hovering over the asset"
2989
2999
  }, {
2990
3000
  name: "height",
2991
3001
  type: "number",
@@ -3796,13 +3806,12 @@ var componentInfo12 = {
3796
3806
  };
3797
3807
 
3798
3808
  // src/blocks/custom-code/custom-code.tsx
3799
- import { onMount as onMount5, createSignal as createSignal12 } from "solid-js";
3809
+ import { onMount as onMount5, on as on3, createEffect as createEffect3, createMemo as createMemo12, createSignal as createSignal12 } from "solid-js";
3800
3810
  function CustomCode(props) {
3801
3811
  const [scriptsInserted, setScriptsInserted] = createSignal12([]);
3802
3812
  const [scriptsRun, setScriptsRun] = createSignal12([]);
3803
- let elementRef;
3804
- onMount5(() => {
3805
- if (!elementRef?.getElementsByTagName || typeof window === "undefined") {
3813
+ function runScripts() {
3814
+ if (!elementRef || !elementRef?.getElementsByTagName || typeof window === "undefined") {
3806
3815
  return;
3807
3816
  }
3808
3817
  const scripts = elementRef.getElementsByTagName("script");
@@ -3829,11 +3838,25 @@ function CustomCode(props) {
3829
3838
  scriptsRun().push(script.innerText);
3830
3839
  new Function(script.innerText)();
3831
3840
  } catch (error2) {
3832
- console.warn("`CustomCode`: Error running script:", error2);
3841
+ logger.warn(
3842
+ "[BUILDER.IO] `CustomCode`: Error running script:",
3843
+ error2
3844
+ );
3833
3845
  }
3834
3846
  }
3835
3847
  }
3848
+ }
3849
+ let elementRef;
3850
+ onMount5(() => {
3851
+ runScripts();
3836
3852
  });
3853
+ const onUpdateFn_0_props_code = createMemo12(() => props.code);
3854
+ function onUpdateFn_0() {
3855
+ if (isEditing()) {
3856
+ runScripts();
3857
+ }
3858
+ }
3859
+ createEffect3(on3(() => [onUpdateFn_0_props_code()], onUpdateFn_0));
3837
3860
  return <><div
3838
3861
  class={"builder-custom-code" + (props.replaceNodes ? " replace-nodes" : "")}
3839
3862
  ref={elementRef}
@@ -3861,7 +3884,7 @@ var componentInfo13 = {
3861
3884
  };
3862
3885
 
3863
3886
  // src/blocks/embed/embed.tsx
3864
- import { on as on2, createEffect as createEffect2, createMemo as createMemo13, createSignal as createSignal13 } from "solid-js";
3887
+ import { on as on4, createEffect as createEffect4, createMemo as createMemo13, createSignal as createSignal13 } from "solid-js";
3865
3888
 
3866
3889
  // src/blocks/embed/helpers.ts
3867
3890
  var SCRIPT_MIME_TYPES = ["text/javascript", "application/javascript", "application/ecmascript"];
@@ -3889,7 +3912,7 @@ function Embed(props) {
3889
3912
  scriptsRun().push(script.innerText);
3890
3913
  new Function(script.innerText)();
3891
3914
  } catch (error2) {
3892
- console.warn("`Embed`: Error running script:", error2);
3915
+ logger.warn("[BUILDER.IO] `Embed`: Error running script:", error2);
3893
3916
  }
3894
3917
  }
3895
3918
  }
@@ -3903,8 +3926,8 @@ function Embed(props) {
3903
3926
  findAndRunScripts();
3904
3927
  }
3905
3928
  }
3906
- createEffect2(
3907
- on2(() => [onUpdateFn_0_elem(), onUpdateFn_0_ranInitFn__()], onUpdateFn_0)
3929
+ createEffect4(
3930
+ on4(() => [onUpdateFn_0_elem(), onUpdateFn_0_ranInitFn__()], onUpdateFn_0)
3908
3931
  );
3909
3932
  return <><div class="builder-embed" ref={elem} innerHTML={props.content} /></>;
3910
3933
  }
@@ -4946,7 +4969,7 @@ function serializeIncludingFunctions(info) {
4946
4969
  }
4947
4970
 
4948
4971
  // 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}";
4972
+ 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
4973
  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
4974
 
4952
4975
  // src/components/content-variants/helpers.ts
@@ -4975,6 +4998,7 @@ var checkShouldRenderVariants2 = ({
4975
4998
  return true;
4976
4999
  };
4977
5000
  var getIsHydrationTarget = (target) => target === "react" || target === "reactNative";
5001
+ var isAngularSDK = TARGET === "angular";
4978
5002
  var isHydrationTarget = getIsHydrationTarget(TARGET);
4979
5003
  var getInitVariantsFnsScriptString = () => `
4980
5004
  window.${UPDATE_COOKIES_AND_STYLES_SCRIPT_NAME} = ${UPDATE_COOKIES_AND_STYLES_SCRIPT}
@@ -4982,7 +5006,7 @@ var getInitVariantsFnsScriptString = () => `
4982
5006
  `;
4983
5007
  var getUpdateCookieAndStylesScript = (variants, contentId) => `
4984
5008
  window.${UPDATE_COOKIES_AND_STYLES_SCRIPT_NAME}(
4985
- "${contentId}",${JSON.stringify(variants)}, ${isHydrationTarget}
5009
+ "${contentId}",${JSON.stringify(variants)}, ${isHydrationTarget}, ${isAngularSDK}
4986
5010
  )`;
4987
5011
  var getUpdateVariantVisibilityScript = ({
4988
5012
  contentId,
@@ -4995,8 +5019,8 @@ var getUpdateVariantVisibilityScript = ({
4995
5019
  import {
4996
5020
  Show as Show14,
4997
5021
  onMount as onMount7,
4998
- on as on3,
4999
- createEffect as createEffect3,
5022
+ on as on5,
5023
+ createEffect as createEffect5,
5000
5024
  createMemo as createMemo16,
5001
5025
  createSignal as createSignal16
5002
5026
  } from "solid-js";
@@ -5008,7 +5032,7 @@ function getPreviewContent(_searchParams) {
5008
5032
  }
5009
5033
 
5010
5034
  // src/constants/sdk-version.ts
5011
- var SDK_VERSION = "4.0.2";
5035
+ var SDK_VERSION = "4.0.4";
5012
5036
 
5013
5037
  // src/helpers/sdk-headers.ts
5014
5038
  var getSdkHeaders = () => ({
@@ -6100,15 +6124,15 @@ function EnableEditor(props) {
6100
6124
  mergeNewContent(props.content);
6101
6125
  }
6102
6126
  }
6103
- createEffect3(on3(() => [onUpdateFn_0_props_content()], onUpdateFn_0));
6127
+ createEffect5(on5(() => [onUpdateFn_0_props_content()], onUpdateFn_0));
6104
6128
  const onUpdateFn_1_props_builderContextSignal_rootState = createMemo16(
6105
6129
  () => props.builderContextSignal.rootState
6106
6130
  );
6107
6131
  function onUpdateFn_1() {
6108
6132
  emitStateUpdate();
6109
6133
  }
6110
- createEffect3(
6111
- on3(
6134
+ createEffect5(
6135
+ on5(
6112
6136
  () => [onUpdateFn_1_props_builderContextSignal_rootState()],
6113
6137
  onUpdateFn_1
6114
6138
  )
@@ -6119,7 +6143,7 @@ function EnableEditor(props) {
6119
6143
  mergeNewRootState(props.data);
6120
6144
  }
6121
6145
  }
6122
- createEffect3(on3(() => [onUpdateFn_2_props_data()], onUpdateFn_2));
6146
+ createEffect5(on5(() => [onUpdateFn_2_props_data()], onUpdateFn_2));
6123
6147
  const onUpdateFn_3_props_locale = createMemo16(() => props.locale);
6124
6148
  function onUpdateFn_3() {
6125
6149
  if (props.locale) {
@@ -6128,7 +6152,7 @@ function EnableEditor(props) {
6128
6152
  });
6129
6153
  }
6130
6154
  }
6131
- createEffect3(on3(() => [onUpdateFn_3_props_locale()], onUpdateFn_3));
6155
+ createEffect5(on5(() => [onUpdateFn_3_props_locale()], onUpdateFn_3));
6132
6156
  return <><builder_context_default.Provider value={props.builderContextSignal}><Show14
6133
6157
  when={props.builderContextSignal.content || needsElementRefDivForEditing()}
6134
6158
  ><Dynamic5
@@ -6506,7 +6530,7 @@ function Symbol(props) {
6506
6530
  function onUpdateFn_0() {
6507
6531
  setContent();
6508
6532
  }
6509
- createEffect4(on4(() => [onUpdateFn_0_props_symbol()], onUpdateFn_0));
6533
+ createEffect6(on6(() => [onUpdateFn_0_props_symbol()], onUpdateFn_0));
6510
6534
  return <><div class={className()} {...{}} {...props.attributes} {...{}}><Content_variants_default
6511
6535
  nonce={props.builderContext.nonce}
6512
6536
  isNestedRender={true}
package/lib/node/index.js CHANGED
@@ -1801,12 +1801,13 @@ function Block(props) {
1801
1801
  });
1802
1802
  }
1803
1803
  var block_default = Block;
1804
- var _tmpl$2 = /* @__PURE__ */ template(`<style>.dynamic-3d7ff108 {
1804
+ var _tmpl$2 = /* @__PURE__ */ template(`<style>.dynamic-023c60f2 {
1805
1805
  display: flex;
1806
1806
  flex-direction: column;
1807
1807
  align-items: stretch;
1808
1808
  }`);
1809
1809
  function BlocksWrapper(props) {
1810
+ createSignal(false);
1810
1811
  const className = createMemo(() => {
1811
1812
  return ["builder-blocks", !props.blocks?.length ? "no-blocks" : "", props.classNameProp].filter(Boolean).join(" ");
1812
1813
  });
@@ -1843,9 +1844,13 @@ function BlocksWrapper(props) {
1843
1844
  let blocksWrapperRef;
1844
1845
  onMount(() => {
1845
1846
  });
1847
+ const onUpdateFn_0_props_blocks = createMemo(() => props.blocks);
1848
+ function onUpdateFn_0() {
1849
+ }
1850
+ createEffect(on(() => [onUpdateFn_0_props_blocks()], onUpdateFn_0));
1846
1851
  return [createComponent(Dynamic, mergeProps({
1847
1852
  get ["class"]() {
1848
- return className() + " dynamic-3d7ff108";
1853
+ return className() + " dynamic-023c60f2";
1849
1854
  },
1850
1855
  ref(r$) {
1851
1856
  const _ref$ = blocksWrapperRef;
@@ -2198,16 +2203,16 @@ function getSrcSet(url) {
2198
2203
  // src/blocks/image/image.tsx
2199
2204
  var _tmpl$5 = /* @__PURE__ */ template(`<source type=image/webp>`);
2200
2205
  var _tmpl$23 = /* @__PURE__ */ template(`<picture><img>`);
2201
- var _tmpl$32 = /* @__PURE__ */ template(`<div class="builder-image-sizer div-dc6700b4">`);
2202
- var _tmpl$42 = /* @__PURE__ */ template(`<div class=div-dc6700b4-2>`);
2203
- var _tmpl$52 = /* @__PURE__ */ template(`<style>.img-dc6700b4 {
2206
+ var _tmpl$32 = /* @__PURE__ */ template(`<div class="builder-image-sizer div-040e729e">`);
2207
+ var _tmpl$42 = /* @__PURE__ */ template(`<div class=div-040e729e-2>`);
2208
+ var _tmpl$52 = /* @__PURE__ */ template(`<style>.img-040e729e {
2204
2209
  opacity: 1;
2205
2210
  transition: opacity 0.2s ease-in-out;
2206
- }.div-dc6700b4 {
2211
+ }.div-040e729e {
2207
2212
  width: 100%;
2208
2213
  pointer-events: none;
2209
2214
  font-size: 0;
2210
- }.div-dc6700b4-2 {
2215
+ }.div-040e729e-2 {
2211
2216
  display: flex;
2212
2217
  flex-direction: column;
2213
2218
  align-items: stretch;
@@ -2269,20 +2274,21 @@ function Image(props) {
2269
2274
  }
2270
2275
  }), _el$3);
2271
2276
  effect((_p$) => {
2272
- const _v$ = "builder-image" + (props.className ? " " + props.className : "") + " img-dc6700b4", _v$2 = props.highPriority ? "eager" : "lazy", _v$3 = props.highPriority ? "high" : "auto", _v$4 = props.altText, _v$5 = props.altText ? void 0 : "presentation", _v$6 = {
2277
+ const _v$ = "builder-image" + (props.className ? " " + props.className : "") + " img-040e729e", _v$2 = props.highPriority ? "eager" : "lazy", _v$3 = props.highPriority ? "high" : "auto", _v$4 = props.altText, _v$5 = props.title, _v$6 = props.altText ? void 0 : "presentation", _v$7 = {
2273
2278
  "object-position": props.backgroundPosition || "center",
2274
2279
  "object-fit": props.backgroundSize || "cover",
2275
2280
  ...aspectRatioCss()
2276
- }, _v$7 = props.image, _v$8 = srcSetToUse(), _v$9 = props.sizes;
2281
+ }, _v$8 = props.image, _v$9 = srcSetToUse(), _v$10 = props.sizes;
2277
2282
  _v$ !== _p$._v$ && className(_el$3, _p$._v$ = _v$);
2278
2283
  _v$2 !== _p$._v$2 && setAttribute(_el$3, "loading", _p$._v$2 = _v$2);
2279
2284
  _v$3 !== _p$._v$3 && setAttribute(_el$3, "fetchpriority", _p$._v$3 = _v$3);
2280
2285
  _v$4 !== _p$._v$4 && setAttribute(_el$3, "alt", _p$._v$4 = _v$4);
2281
- _v$5 !== _p$._v$5 && setAttribute(_el$3, "role", _p$._v$5 = _v$5);
2282
- _p$._v$6 = style(_el$3, _v$6, _p$._v$6);
2283
- _v$7 !== _p$._v$7 && setAttribute(_el$3, "src", _p$._v$7 = _v$7);
2284
- _v$8 !== _p$._v$8 && setAttribute(_el$3, "srcset", _p$._v$8 = _v$8);
2285
- _v$9 !== _p$._v$9 && setAttribute(_el$3, "sizes", _p$._v$9 = _v$9);
2286
+ _v$5 !== _p$._v$5 && setAttribute(_el$3, "title", _p$._v$5 = _v$5);
2287
+ _v$6 !== _p$._v$6 && setAttribute(_el$3, "role", _p$._v$6 = _v$6);
2288
+ _p$._v$7 = style(_el$3, _v$7, _p$._v$7);
2289
+ _v$8 !== _p$._v$8 && setAttribute(_el$3, "src", _p$._v$8 = _v$8);
2290
+ _v$9 !== _p$._v$9 && setAttribute(_el$3, "srcset", _p$._v$9 = _v$9);
2291
+ _v$10 !== _p$._v$10 && setAttribute(_el$3, "sizes", _p$._v$10 = _v$10);
2286
2292
  return _p$;
2287
2293
  }, {
2288
2294
  _v$: void 0,
@@ -2293,7 +2299,8 @@ function Image(props) {
2293
2299
  _v$6: void 0,
2294
2300
  _v$7: void 0,
2295
2301
  _v$8: void 0,
2296
- _v$9: void 0
2302
+ _v$9: void 0,
2303
+ _v$10: void 0
2297
2304
  });
2298
2305
  return _el$;
2299
2306
  })(), createComponent(Show, {
@@ -3276,6 +3283,10 @@ var componentInfo5 = {
3276
3283
  name: "altText",
3277
3284
  type: "string",
3278
3285
  helperText: "Text to display when the user has images off"
3286
+ }, {
3287
+ name: "title",
3288
+ type: "string",
3289
+ helperText: "Text to display when hovering over the asset"
3279
3290
  }, {
3280
3291
  name: "height",
3281
3292
  type: "number",
@@ -4159,9 +4170,8 @@ var _tmpl$13 = /* @__PURE__ */ template(`<div>`);
4159
4170
  function CustomCode(props) {
4160
4171
  const [scriptsInserted, setScriptsInserted] = createSignal([]);
4161
4172
  const [scriptsRun, setScriptsRun] = createSignal([]);
4162
- let elementRef;
4163
- onMount(() => {
4164
- if (!elementRef?.getElementsByTagName || typeof window === "undefined") {
4173
+ function runScripts() {
4174
+ if (!elementRef || !elementRef?.getElementsByTagName || typeof window === "undefined") {
4165
4175
  return;
4166
4176
  }
4167
4177
  const scripts = elementRef.getElementsByTagName("script");
@@ -4184,10 +4194,22 @@ function CustomCode(props) {
4184
4194
  scriptsRun().push(script.innerText);
4185
4195
  new Function(script.innerText)();
4186
4196
  } catch (error2) {
4197
+ logger.warn("[BUILDER.IO] `CustomCode`: Error running script:", error2);
4187
4198
  }
4188
4199
  }
4189
4200
  }
4201
+ }
4202
+ let elementRef;
4203
+ onMount(() => {
4204
+ runScripts();
4190
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));
4191
4213
  return (() => {
4192
4214
  const _el$ = _tmpl$13();
4193
4215
  const _ref$ = elementRef;
@@ -4251,6 +4273,7 @@ function Embed(props) {
4251
4273
  scriptsRun().push(script.innerText);
4252
4274
  new Function(script.innerText)();
4253
4275
  } catch (error2) {
4276
+ logger.warn("[BUILDER.IO] `Embed`: Error running script:", error2);
4254
4277
  }
4255
4278
  }
4256
4279
  }
@@ -5434,7 +5457,7 @@ function serializeIncludingFunctions(info) {
5434
5457
  }
5435
5458
 
5436
5459
  // 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}";
5460
+ 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
5461
  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
5462
 
5440
5463
  // src/components/content-variants/helpers.ts
@@ -5463,6 +5486,7 @@ var checkShouldRenderVariants2 = ({
5463
5486
  return true;
5464
5487
  };
5465
5488
  var getIsHydrationTarget = (target) => target === "react" || target === "reactNative";
5489
+ var isAngularSDK = TARGET === "angular";
5466
5490
  var isHydrationTarget = getIsHydrationTarget(TARGET);
5467
5491
  var getInitVariantsFnsScriptString = () => `
5468
5492
  window.${UPDATE_COOKIES_AND_STYLES_SCRIPT_NAME} = ${UPDATE_COOKIES_AND_STYLES_SCRIPT}
@@ -5470,7 +5494,7 @@ var getInitVariantsFnsScriptString = () => `
5470
5494
  `;
5471
5495
  var getUpdateCookieAndStylesScript = (variants, contentId) => `
5472
5496
  window.${UPDATE_COOKIES_AND_STYLES_SCRIPT_NAME}(
5473
- "${contentId}",${JSON.stringify(variants)}, ${isHydrationTarget}
5497
+ "${contentId}",${JSON.stringify(variants)}, ${isHydrationTarget}, ${isAngularSDK}
5474
5498
  )`;
5475
5499
  var getUpdateVariantVisibilityScript = ({
5476
5500
  contentId,
@@ -5485,7 +5509,7 @@ function getPreviewContent(_searchParams) {
5485
5509
  }
5486
5510
 
5487
5511
  // src/constants/sdk-version.ts
5488
- var SDK_VERSION = "4.0.2";
5512
+ var SDK_VERSION = "4.0.4";
5489
5513
 
5490
5514
  // src/helpers/sdk-headers.ts
5491
5515
  var getSdkHeaders = () => ({