@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.
@@ -1644,9 +1644,10 @@ function Block(props) {
1644
1644
  var Block_default = Block;
1645
1645
 
1646
1646
  // src/components/blocks/blocks-wrapper.tsx
1647
- import { onMount as onMount3, createMemo as createMemo6 } from "solid-js";
1647
+ import { onMount as onMount3, on as on2, createEffect as createEffect2, createMemo as createMemo6, createSignal as createSignal6 } from "solid-js";
1648
1648
  import { Dynamic as Dynamic4 } from "solid-js/web";
1649
1649
  function BlocksWrapper(props) {
1650
+ const [shouldUpdate, setShouldUpdate] = createSignal6(false);
1650
1651
  const className = createMemo6(() => {
1651
1652
  return [
1652
1653
  "builder-blocks",
@@ -1693,9 +1694,13 @@ function BlocksWrapper(props) {
1693
1694
  let blocksWrapperRef;
1694
1695
  onMount3(() => {
1695
1696
  });
1697
+ const onUpdateFn_0_props_blocks = createMemo6(() => props.blocks);
1698
+ function onUpdateFn_0() {
1699
+ }
1700
+ createEffect2(on2(() => [onUpdateFn_0_props_blocks()], onUpdateFn_0));
1696
1701
  return <>
1697
1702
  <Dynamic4
1698
- class={className() + " dynamic-3d7ff108"}
1703
+ class={className() + " dynamic-023c60f2"}
1699
1704
  ref={blocksWrapperRef}
1700
1705
  builder-path={dataPath()}
1701
1706
  builder-parent-id={props.parent}
@@ -1707,7 +1712,7 @@ function BlocksWrapper(props) {
1707
1712
  {...props.BlocksWrapperProps}
1708
1713
  component={props.BlocksWrapper}
1709
1714
  >{props.children}</Dynamic4>
1710
- <style>{`.dynamic-3d7ff108 {
1715
+ <style>{`.dynamic-023c60f2 {
1711
1716
  display: flex;
1712
1717
  flex-direction: column;
1713
1718
  align-items: stretch;
@@ -2010,10 +2015,11 @@ function Image(props) {
2010
2015
  <picture>
2011
2016
  <Show8 when={webpSrcSet()}><source type="image/webp" srcset={webpSrcSet()} /></Show8>
2012
2017
  <img
2013
- class={"builder-image" + (props.className ? " " + props.className : "") + " img-dc6700b4"}
2018
+ class={"builder-image" + (props.className ? " " + props.className : "") + " img-040e729e"}
2014
2019
  loading={props.highPriority ? "eager" : "lazy"}
2015
2020
  fetchpriority={props.highPriority ? "high" : "auto"}
2016
2021
  alt={props.altText}
2022
+ title={props.title}
2017
2023
  role={props.altText ? void 0 : "presentation"}
2018
2024
  style={{
2019
2025
  "object-position": props.backgroundPosition || "center",
@@ -2028,22 +2034,22 @@ function Image(props) {
2028
2034
  <Show8
2029
2035
  when={props.aspectRatio && !(props.builderBlock?.children?.length && props.fitContent)}
2030
2036
  ><div
2031
- class="builder-image-sizer div-dc6700b4"
2037
+ class="builder-image-sizer div-040e729e"
2032
2038
  style={{
2033
2039
  "padding-top": props.aspectRatio * 100 + "%"
2034
2040
  }}
2035
2041
  /></Show8>
2036
2042
  <Show8 when={props.builderBlock?.children?.length && props.fitContent}>{props.children}</Show8>
2037
- <Show8 when={!props.fitContent && props.builderBlock?.children?.length}><div class="div-dc6700b4-2">{props.children}</div></Show8>
2043
+ <Show8 when={!props.fitContent && props.builderBlock?.children?.length}><div class="div-040e729e-2">{props.children}</div></Show8>
2038
2044
  </>
2039
- <style>{`.img-dc6700b4 {
2045
+ <style>{`.img-040e729e {
2040
2046
  opacity: 1;
2041
2047
  transition: opacity 0.2s ease-in-out;
2042
- }.div-dc6700b4 {
2048
+ }.div-040e729e {
2043
2049
  width: 100%;
2044
2050
  pointer-events: none;
2045
2051
  font-size: 0;
2046
- }.div-dc6700b4-2 {
2052
+ }.div-040e729e-2 {
2047
2053
  display: flex;
2048
2054
  flex-direction: column;
2049
2055
  align-items: stretch;
@@ -2079,7 +2085,7 @@ function SectionComponent(props) {
2079
2085
  var section_default = SectionComponent;
2080
2086
 
2081
2087
  // 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";
2088
+ import { onMount as onMount9, on as on6, createEffect as createEffect6, createMemo as createMemo20, createSignal as createSignal20 } from "solid-js";
2083
2089
 
2084
2090
  // src/components/content-variants/content-variants.tsx
2085
2091
  import { Show as Show16, For as For9, onMount as onMount8, createSignal as createSignal19, createMemo as createMemo19 } from "solid-js";
@@ -2977,6 +2983,10 @@ var componentInfo5 = {
2977
2983
  name: "altText",
2978
2984
  type: "string",
2979
2985
  helperText: "Text to display when the user has images off"
2986
+ }, {
2987
+ name: "title",
2988
+ type: "string",
2989
+ helperText: "Text to display when hovering over the asset"
2980
2990
  }, {
2981
2991
  name: "height",
2982
2992
  type: "number",
@@ -3787,13 +3797,12 @@ var componentInfo12 = {
3787
3797
  };
3788
3798
 
3789
3799
  // src/blocks/custom-code/custom-code.tsx
3790
- import { onMount as onMount5, createSignal as createSignal12 } from "solid-js";
3800
+ import { onMount as onMount5, on as on3, createEffect as createEffect3, createMemo as createMemo12, createSignal as createSignal12 } from "solid-js";
3791
3801
  function CustomCode(props) {
3792
3802
  const [scriptsInserted, setScriptsInserted] = createSignal12([]);
3793
3803
  const [scriptsRun, setScriptsRun] = createSignal12([]);
3794
- let elementRef;
3795
- onMount5(() => {
3796
- if (!elementRef?.getElementsByTagName || typeof window === "undefined") {
3804
+ function runScripts() {
3805
+ if (!elementRef || !elementRef?.getElementsByTagName || typeof window === "undefined") {
3797
3806
  return;
3798
3807
  }
3799
3808
  const scripts = elementRef.getElementsByTagName("script");
@@ -3820,10 +3829,25 @@ function CustomCode(props) {
3820
3829
  scriptsRun().push(script.innerText);
3821
3830
  new Function(script.innerText)();
3822
3831
  } catch (error2) {
3832
+ logger.warn(
3833
+ "[BUILDER.IO] `CustomCode`: Error running script:",
3834
+ error2
3835
+ );
3823
3836
  }
3824
3837
  }
3825
3838
  }
3839
+ }
3840
+ let elementRef;
3841
+ onMount5(() => {
3842
+ runScripts();
3826
3843
  });
3844
+ const onUpdateFn_0_props_code = createMemo12(() => props.code);
3845
+ function onUpdateFn_0() {
3846
+ if (isEditing()) {
3847
+ runScripts();
3848
+ }
3849
+ }
3850
+ createEffect3(on3(() => [onUpdateFn_0_props_code()], onUpdateFn_0));
3827
3851
  return <><div
3828
3852
  class={"builder-custom-code" + (props.replaceNodes ? " replace-nodes" : "")}
3829
3853
  ref={elementRef}
@@ -3851,7 +3875,7 @@ var componentInfo13 = {
3851
3875
  };
3852
3876
 
3853
3877
  // src/blocks/embed/embed.tsx
3854
- import { on as on2, createEffect as createEffect2, createMemo as createMemo13, createSignal as createSignal13 } from "solid-js";
3878
+ import { on as on4, createEffect as createEffect4, createMemo as createMemo13, createSignal as createSignal13 } from "solid-js";
3855
3879
 
3856
3880
  // src/blocks/embed/helpers.ts
3857
3881
  var SCRIPT_MIME_TYPES = ["text/javascript", "application/javascript", "application/ecmascript"];
@@ -3879,6 +3903,7 @@ function Embed(props) {
3879
3903
  scriptsRun().push(script.innerText);
3880
3904
  new Function(script.innerText)();
3881
3905
  } catch (error2) {
3906
+ logger.warn("[BUILDER.IO] `Embed`: Error running script:", error2);
3882
3907
  }
3883
3908
  }
3884
3909
  }
@@ -3892,8 +3917,8 @@ function Embed(props) {
3892
3917
  findAndRunScripts();
3893
3918
  }
3894
3919
  }
3895
- createEffect2(
3896
- on2(() => [onUpdateFn_0_elem(), onUpdateFn_0_ranInitFn__()], onUpdateFn_0)
3920
+ createEffect4(
3921
+ on4(() => [onUpdateFn_0_elem(), onUpdateFn_0_ranInitFn__()], onUpdateFn_0)
3897
3922
  );
3898
3923
  return <><div class="builder-embed" ref={elem} innerHTML={props.content} /></>;
3899
3924
  }
@@ -4934,7 +4959,7 @@ function serializeIncludingFunctions(info) {
4934
4959
  }
4935
4960
 
4936
4961
  // 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}";
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}";
4938
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}";
4939
4964
 
4940
4965
  // src/components/content-variants/helpers.ts
@@ -4963,6 +4988,7 @@ var checkShouldRenderVariants2 = ({
4963
4988
  return true;
4964
4989
  };
4965
4990
  var getIsHydrationTarget = (target) => target === "react" || target === "reactNative";
4991
+ var isAngularSDK = TARGET === "angular";
4966
4992
  var isHydrationTarget = getIsHydrationTarget(TARGET);
4967
4993
  var getInitVariantsFnsScriptString = () => `
4968
4994
  window.${UPDATE_COOKIES_AND_STYLES_SCRIPT_NAME} = ${UPDATE_COOKIES_AND_STYLES_SCRIPT}
@@ -4970,7 +4996,7 @@ var getInitVariantsFnsScriptString = () => `
4970
4996
  `;
4971
4997
  var getUpdateCookieAndStylesScript = (variants, contentId) => `
4972
4998
  window.${UPDATE_COOKIES_AND_STYLES_SCRIPT_NAME}(
4973
- "${contentId}",${JSON.stringify(variants)}, ${isHydrationTarget}
4999
+ "${contentId}",${JSON.stringify(variants)}, ${isHydrationTarget}, ${isAngularSDK}
4974
5000
  )`;
4975
5001
  var getUpdateVariantVisibilityScript = ({
4976
5002
  contentId,
@@ -4983,8 +5009,8 @@ var getUpdateVariantVisibilityScript = ({
4983
5009
  import {
4984
5010
  Show as Show14,
4985
5011
  onMount as onMount7,
4986
- on as on3,
4987
- createEffect as createEffect3,
5012
+ on as on5,
5013
+ createEffect as createEffect5,
4988
5014
  createMemo as createMemo16,
4989
5015
  createSignal as createSignal16
4990
5016
  } from "solid-js";
@@ -4996,7 +5022,7 @@ function getPreviewContent(_searchParams) {
4996
5022
  }
4997
5023
 
4998
5024
  // src/constants/sdk-version.ts
4999
- var SDK_VERSION = "4.0.2";
5025
+ var SDK_VERSION = "4.0.4";
5000
5026
 
5001
5027
  // src/helpers/sdk-headers.ts
5002
5028
  var getSdkHeaders = () => ({
@@ -6081,15 +6107,15 @@ function EnableEditor(props) {
6081
6107
  mergeNewContent(props.content);
6082
6108
  }
6083
6109
  }
6084
- createEffect3(on3(() => [onUpdateFn_0_props_content()], onUpdateFn_0));
6110
+ createEffect5(on5(() => [onUpdateFn_0_props_content()], onUpdateFn_0));
6085
6111
  const onUpdateFn_1_props_builderContextSignal_rootState = createMemo16(
6086
6112
  () => props.builderContextSignal.rootState
6087
6113
  );
6088
6114
  function onUpdateFn_1() {
6089
6115
  emitStateUpdate();
6090
6116
  }
6091
- createEffect3(
6092
- on3(
6117
+ createEffect5(
6118
+ on5(
6093
6119
  () => [onUpdateFn_1_props_builderContextSignal_rootState()],
6094
6120
  onUpdateFn_1
6095
6121
  )
@@ -6100,7 +6126,7 @@ function EnableEditor(props) {
6100
6126
  mergeNewRootState(props.data);
6101
6127
  }
6102
6128
  }
6103
- createEffect3(on3(() => [onUpdateFn_2_props_data()], onUpdateFn_2));
6129
+ createEffect5(on5(() => [onUpdateFn_2_props_data()], onUpdateFn_2));
6104
6130
  const onUpdateFn_3_props_locale = createMemo16(() => props.locale);
6105
6131
  function onUpdateFn_3() {
6106
6132
  if (props.locale) {
@@ -6109,7 +6135,7 @@ function EnableEditor(props) {
6109
6135
  });
6110
6136
  }
6111
6137
  }
6112
- createEffect3(on3(() => [onUpdateFn_3_props_locale()], onUpdateFn_3));
6138
+ createEffect5(on5(() => [onUpdateFn_3_props_locale()], onUpdateFn_3));
6113
6139
  return <><builder_context_default.Provider value={props.builderContextSignal}><Show14
6114
6140
  when={props.builderContextSignal.content || needsElementRefDivForEditing()}
6115
6141
  ><Dynamic5
@@ -6487,7 +6513,7 @@ function Symbol(props) {
6487
6513
  function onUpdateFn_0() {
6488
6514
  setContent();
6489
6515
  }
6490
- createEffect4(on4(() => [onUpdateFn_0_props_symbol()], onUpdateFn_0));
6516
+ createEffect6(on6(() => [onUpdateFn_0_props_symbol()], onUpdateFn_0));
6491
6517
  return <><div class={className()} {...{}} {...props.attributes} {...{}}><Content_variants_default
6492
6518
  nonce={props.builderContext.nonce}
6493
6519
  isNestedRender={true}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@builder.io/sdk-solid",
3
- "version": "4.0.2",
3
+ "version": "4.0.4",
4
4
  "description": "",
5
5
  "files": [
6
6
  "dist",