@builder.io/sdk-solid 1.0.15 → 1.0.17

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/node/dev.js CHANGED
@@ -996,7 +996,7 @@ function InlinedStyles(props) {
996
996
  effect((_p$) => {
997
997
  const _v$ = props.styles, _v$2 = props.id;
998
998
  _v$ !== _p$._v$ && (_el$.innerHTML = _p$._v$ = _v$);
999
- _v$2 !== _p$._v$2 && setAttribute(_el$, "id", _p$._v$2 = _v$2);
999
+ _v$2 !== _p$._v$2 && setAttribute(_el$, "data-id", _p$._v$2 = _v$2);
1000
1000
  return _p$;
1001
1001
  }, {
1002
1002
  _v$: void 0,
@@ -1067,6 +1067,7 @@ function BlockStyles(props) {
1067
1067
  },
1068
1068
  get children() {
1069
1069
  return createComponent(inlined_styles_default, {
1070
+ id: "builderio-block",
1070
1071
  get styles() {
1071
1072
  return css5();
1072
1073
  }
@@ -1783,6 +1784,7 @@ function Columns(props) {
1783
1784
  when: TARGET !== "reactNative",
1784
1785
  get children() {
1785
1786
  return createComponent(inlined_styles_default, {
1787
+ id: "builderio-columns",
1786
1788
  get styles() {
1787
1789
  return columnsStyles();
1788
1790
  }
@@ -4054,7 +4056,7 @@ var checkShouldRenderVariants = ({
4054
4056
  };
4055
4057
  var getIsHydrationTarget = (target) => target === "react" || target === "reactNative";
4056
4058
  var isHydrationTarget = getIsHydrationTarget(TARGET);
4057
- var getScriptString = () => `
4059
+ var getInitVariantsFnsScriptString = () => `
4058
4060
  window.${UPDATE_COOKIES_AND_STYLES_SCRIPT_NAME} = ${UPDATE_COOKIES_AND_STYLES_SCRIPT}
4059
4061
  window.${UPDATE_VARIANT_VISIBILITY_SCRIPT_FN_NAME} = ${UPDATE_VARIANT_VISIBILITY_SCRIPT}
4060
4062
  `;
@@ -4073,9 +4075,9 @@ function InlinedScript(props) {
4073
4075
  return (() => {
4074
4076
  const _el$ = _tmpl$16();
4075
4077
  effect((_p$) => {
4076
- const _v$ = props.scriptStr, _v$2 = props.id || "";
4078
+ const _v$ = props.scriptStr, _v$2 = props.id;
4077
4079
  _v$ !== _p$._v$ && (_el$.innerHTML = _p$._v$ = _v$);
4078
- _v$2 !== _p$._v$2 && setAttribute(_el$, "id", _p$._v$2 = _v$2);
4080
+ _v$2 !== _p$._v$2 && setAttribute(_el$, "data-id", _p$._v$2 = _v$2);
4079
4081
  return _p$;
4080
4082
  }, {
4081
4083
  _v$: void 0,
@@ -4572,7 +4574,7 @@ function isFromTrustedHost(trustedHosts, e) {
4572
4574
  }
4573
4575
 
4574
4576
  // src/constants/sdk-version.ts
4575
- var SDK_VERSION = "1.0.15";
4577
+ var SDK_VERSION = "1.0.17";
4576
4578
 
4577
4579
  // src/functions/register.ts
4578
4580
  var registry = {};
@@ -4773,6 +4775,7 @@ var subscribeToEditor = (model, callback, options) => {
4773
4775
  function EnableEditor(props) {
4774
4776
  const [ContentWrapper, setContentWrapper] = createSignal(props.contentWrapper || "div");
4775
4777
  const [httpReqsData, setHttpReqsData] = createSignal({});
4778
+ const [httpReqsPending, setHttpReqsPending] = createSignal({});
4776
4779
  const [clicked, setClicked] = createSignal(false);
4777
4780
  function mergeNewRootState(newData) {
4778
4781
  const combinedState = {
@@ -4871,41 +4874,34 @@ function EnableEditor(props) {
4871
4874
  setClicked(true);
4872
4875
  }
4873
4876
  }
4874
- function evalExpression(expression) {
4875
- return expression.replace(/{{([^}]+)}}/g, (_match, group) => String(evaluate({
4876
- code: group,
4877
- context: props.context || {},
4878
- localState: void 0,
4879
- rootState: props.builderContextSignal.rootState,
4880
- rootSetState: props.builderContextSignal.rootSetState,
4881
- enableCache: true
4882
- })));
4883
- }
4884
- function handleRequest({
4885
- url,
4886
- key
4887
- }) {
4888
- fetch2(url).then((response) => response.json()).then((json) => {
4889
- const newState = {
4890
- ...props.builderContextSignal.rootState,
4891
- [key]: json
4892
- };
4893
- props.builderContextSignal.rootSetState?.(newState);
4894
- httpReqsData()[key] = true;
4895
- }).catch((err) => {
4896
- console.error("error fetching dynamic data", url, err);
4897
- });
4898
- }
4899
4877
  function runHttpRequests() {
4900
4878
  const requests = props.builderContextSignal.content?.data?.httpRequests ?? {};
4901
4879
  Object.entries(requests).forEach(([key, url]) => {
4902
- if (url && (!httpReqsData()[key] || isEditing())) {
4903
- const evaluatedUrl = evalExpression(url);
4904
- handleRequest({
4905
- url: evaluatedUrl,
4906
- key
4880
+ if (!url)
4881
+ return;
4882
+ if (httpReqsPending()[key])
4883
+ return;
4884
+ if (httpReqsData()[key] && !isEditing())
4885
+ return;
4886
+ httpReqsPending()[key] = true;
4887
+ const evaluatedUrl = url.replace(/{{([^}]+)}}/g, (_match, group) => String(evaluate({
4888
+ code: group,
4889
+ context: props.context || {},
4890
+ localState: void 0,
4891
+ rootState: props.builderContextSignal.rootState,
4892
+ rootSetState: props.builderContextSignal.rootSetState,
4893
+ enableCache: true
4894
+ })));
4895
+ fetch2(evaluatedUrl).then((response) => response.json()).then((json) => {
4896
+ mergeNewRootState({
4897
+ [key]: json
4907
4898
  });
4908
- }
4899
+ httpReqsData()[key] = true;
4900
+ }).catch((err) => {
4901
+ console.error("error fetching dynamic data", url, err);
4902
+ }).finally(() => {
4903
+ httpReqsPending()[key] = false;
4904
+ });
4909
4905
  });
4910
4906
  }
4911
4907
  function emitStateUpdate() {
@@ -5154,6 +5150,7 @@ ${getFontCss({
5154
5150
  ${getDefaultStyles(props.isNestedRender)}
5155
5151
  `.trim());
5156
5152
  return createComponent(inlined_styles_default, {
5153
+ id: "builderio-content",
5157
5154
  get styles() {
5158
5155
  return injectedStyles();
5159
5156
  }
@@ -5307,6 +5304,7 @@ function ContentComponent(props) {
5307
5304
  },
5308
5305
  get children() {
5309
5306
  return createComponent(inlined_script_default, {
5307
+ id: "builderio-variant-visibility",
5310
5308
  get scriptStr() {
5311
5309
  return scriptStr();
5312
5310
  }
@@ -5384,8 +5382,9 @@ function ContentVariants(props) {
5384
5382
  },
5385
5383
  get children() {
5386
5384
  return createComponent(inlined_script_default, {
5385
+ id: "builderio-init-variants-fns",
5387
5386
  get scriptStr() {
5388
- return getScriptString();
5387
+ return getInitVariantsFnsScriptString();
5389
5388
  }
5390
5389
  });
5391
5390
  }
@@ -5395,13 +5394,12 @@ function ContentVariants(props) {
5395
5394
  },
5396
5395
  get children() {
5397
5396
  return [createComponent(inlined_styles_default, {
5398
- get id() {
5399
- return `variants-styles-${props.content?.id}`;
5400
- },
5397
+ id: "builderio-variants",
5401
5398
  get styles() {
5402
5399
  return hideVariantsStyleString();
5403
5400
  }
5404
5401
  }), createComponent(inlined_script_default, {
5402
+ id: "builderio-variants-visibility",
5405
5403
  get scriptStr() {
5406
5404
  return updateCookieAndStylesScriptStr();
5407
5405
  }
package/lib/node/dev.jsx CHANGED
@@ -984,7 +984,7 @@ var getSizesForBreakpoints = ({
984
984
 
985
985
  // src/components/inlined-styles.tsx
986
986
  function InlinedStyles(props) {
987
- return <style innerHTML={props.styles} id={props.id} />;
987
+ return <style innerHTML={props.styles} data-id={props.id} />;
988
988
  }
989
989
  var Inlined_styles_default = InlinedStyles;
990
990
 
@@ -1050,7 +1050,7 @@ function BlockStyles(props) {
1050
1050
  }) : "";
1051
1051
  return [largeStylesClass, mediumStylesClass, smallStylesClass].join(" ");
1052
1052
  });
1053
- return <Show2 when={TARGET !== "reactNative" && css5() && canShowBlock()}><Inlined_styles_default styles={css5()} /></Show2>;
1053
+ return <Show2 when={TARGET !== "reactNative" && css5() && canShowBlock()}><Inlined_styles_default id="builderio-block" styles={css5()} /></Show2>;
1054
1054
  }
1055
1055
  var Block_styles_default = BlockStyles;
1056
1056
 
@@ -1585,7 +1585,10 @@ function Columns(props) {
1585
1585
  style={columnsCssVars()}
1586
1586
  {...{}}
1587
1587
  >
1588
- <Show6 when={TARGET !== "reactNative"}><Inlined_styles_default styles={columnsStyles()} /></Show6>
1588
+ <Show6 when={TARGET !== "reactNative"}><Inlined_styles_default
1589
+ id="builderio-columns"
1590
+ styles={columnsStyles()}
1591
+ /></Show6>
1589
1592
  <For4 each={props.columns}>{(column, _index) => {
1590
1593
  const index = _index();
1591
1594
  return <Dynamic_renderer_default
@@ -3639,7 +3642,7 @@ var checkShouldRenderVariants = ({
3639
3642
  };
3640
3643
  var getIsHydrationTarget = (target) => target === "react" || target === "reactNative";
3641
3644
  var isHydrationTarget = getIsHydrationTarget(TARGET);
3642
- var getScriptString = () => `
3645
+ var getInitVariantsFnsScriptString = () => `
3643
3646
  window.${UPDATE_COOKIES_AND_STYLES_SCRIPT_NAME} = ${UPDATE_COOKIES_AND_STYLES_SCRIPT}
3644
3647
  window.${UPDATE_VARIANT_VISIBILITY_SCRIPT_FN_NAME} = ${UPDATE_VARIANT_VISIBILITY_SCRIPT}
3645
3648
  `;
@@ -3656,7 +3659,7 @@ var getUpdateVariantVisibilityScript = ({
3656
3659
 
3657
3660
  // src/components/inlined-script.tsx
3658
3661
  function InlinedScript(props) {
3659
- return <script innerHTML={props.scriptStr} id={props.id || ""} />;
3662
+ return <script innerHTML={props.scriptStr} data-id={props.id} />;
3660
3663
  }
3661
3664
  var Inlined_script_default = InlinedScript;
3662
3665
 
@@ -4157,7 +4160,7 @@ function isFromTrustedHost(trustedHosts, e) {
4157
4160
  }
4158
4161
 
4159
4162
  // src/constants/sdk-version.ts
4160
- var SDK_VERSION = "1.0.15";
4163
+ var SDK_VERSION = "1.0.17";
4161
4164
 
4162
4165
  // src/functions/register.ts
4163
4166
  var registry = {};
@@ -4360,6 +4363,7 @@ function EnableEditor(props) {
4360
4363
  props.contentWrapper || "div"
4361
4364
  );
4362
4365
  const [httpReqsData, setHttpReqsData] = createSignal12({});
4366
+ const [httpReqsPending, setHttpReqsPending] = createSignal12({});
4363
4367
  const [clicked, setClicked] = createSignal12(false);
4364
4368
  function mergeNewRootState(newData) {
4365
4369
  const combinedState = {
@@ -4455,43 +4459,39 @@ function EnableEditor(props) {
4455
4459
  setClicked(true);
4456
4460
  }
4457
4461
  }
4458
- function evalExpression(expression) {
4459
- return expression.replace(
4460
- /{{([^}]+)}}/g,
4461
- (_match, group) => String(
4462
- evaluate({
4463
- code: group,
4464
- context: props.context || {},
4465
- localState: void 0,
4466
- rootState: props.builderContextSignal.rootState,
4467
- rootSetState: props.builderContextSignal.rootSetState,
4468
- enableCache: true
4469
- })
4470
- )
4471
- );
4472
- }
4473
- function handleRequest({ url, key }) {
4474
- fetch2(url).then((response) => response.json()).then((json) => {
4475
- const newState = {
4476
- ...props.builderContextSignal.rootState,
4477
- [key]: json
4478
- };
4479
- props.builderContextSignal.rootSetState?.(newState);
4480
- httpReqsData()[key] = true;
4481
- }).catch((err) => {
4482
- console.error("error fetching dynamic data", url, err);
4483
- });
4484
- }
4485
4462
  function runHttpRequests() {
4486
4463
  const requests = props.builderContextSignal.content?.data?.httpRequests ?? {};
4487
4464
  Object.entries(requests).forEach(([key, url]) => {
4488
- if (url && (!httpReqsData()[key] || isEditing())) {
4489
- const evaluatedUrl = evalExpression(url);
4490
- handleRequest({
4491
- url: evaluatedUrl,
4492
- key
4465
+ if (!url)
4466
+ return;
4467
+ if (httpReqsPending()[key])
4468
+ return;
4469
+ if (httpReqsData()[key] && !isEditing())
4470
+ return;
4471
+ httpReqsPending()[key] = true;
4472
+ const evaluatedUrl = url.replace(
4473
+ /{{([^}]+)}}/g,
4474
+ (_match, group) => String(
4475
+ evaluate({
4476
+ code: group,
4477
+ context: props.context || {},
4478
+ localState: void 0,
4479
+ rootState: props.builderContextSignal.rootState,
4480
+ rootSetState: props.builderContextSignal.rootSetState,
4481
+ enableCache: true
4482
+ })
4483
+ )
4484
+ );
4485
+ fetch2(evaluatedUrl).then((response) => response.json()).then((json) => {
4486
+ mergeNewRootState({
4487
+ [key]: json
4493
4488
  });
4494
- }
4489
+ httpReqsData()[key] = true;
4490
+ }).catch((err) => {
4491
+ console.error("error fetching dynamic data", url, err);
4492
+ }).finally(() => {
4493
+ httpReqsPending()[key] = false;
4494
+ });
4495
4495
  });
4496
4496
  }
4497
4497
  function emitStateUpdate() {
@@ -4751,7 +4751,10 @@ ${getFontCss({
4751
4751
  ${getDefaultStyles(props.isNestedRender)}
4752
4752
  `.trim()
4753
4753
  );
4754
- return <Inlined_styles_default styles={injectedStyles()} />;
4754
+ return <Inlined_styles_default
4755
+ id="builderio-content"
4756
+ styles={injectedStyles()}
4757
+ />;
4755
4758
  }
4756
4759
  var Styles_default = ContentStyles;
4757
4760
 
@@ -4874,7 +4877,10 @@ function ContentComponent(props) {
4874
4877
  setBuilderContextSignal
4875
4878
  }}
4876
4879
  >
4877
- <Show11 when={props.isSsrAbTest}><Inlined_script_default scriptStr={scriptStr()} /></Show11>
4880
+ <Show11 when={props.isSsrAbTest}><Inlined_script_default
4881
+ id="builderio-variant-visibility"
4882
+ scriptStr={scriptStr()}
4883
+ /></Show11>
4878
4884
  <Show11 when={TARGET !== "reactNative"}><Styles_default
4879
4885
  isNestedRender={props.isNestedRender}
4880
4886
  contentId={builderContextSignal().content?.id}
@@ -4924,13 +4930,17 @@ function ContentVariants(props) {
4924
4930
  setShouldRenderVariants(false);
4925
4931
  });
4926
4932
  return <>
4927
- <Show12 when={!props.isNestedRender && TARGET !== "reactNative"}><Inlined_script_default scriptStr={getScriptString()} /></Show12>
4933
+ <Show12 when={!props.isNestedRender && TARGET !== "reactNative"}><Inlined_script_default
4934
+ id="builderio-init-variants-fns"
4935
+ scriptStr={getInitVariantsFnsScriptString()}
4936
+ /></Show12>
4928
4937
  <Show12 when={shouldRenderVariants()}>
4929
4938
  <Inlined_styles_default
4930
- id={`variants-styles-${props.content?.id}`}
4939
+ id="builderio-variants"
4931
4940
  styles={hideVariantsStyleString()}
4932
4941
  />
4933
4942
  <Inlined_script_default
4943
+ id="builderio-variants-visibility"
4934
4944
  scriptStr={updateCookieAndStylesScriptStr()}
4935
4945
  />
4936
4946
  <For7 each={getVariants(props.content)}>{(variant, _index) => {
package/lib/node/index.js CHANGED
@@ -989,7 +989,7 @@ function InlinedStyles(props) {
989
989
  effect((_p$) => {
990
990
  const _v$ = props.styles, _v$2 = props.id;
991
991
  _v$ !== _p$._v$ && (_el$.innerHTML = _p$._v$ = _v$);
992
- _v$2 !== _p$._v$2 && setAttribute(_el$, "id", _p$._v$2 = _v$2);
992
+ _v$2 !== _p$._v$2 && setAttribute(_el$, "data-id", _p$._v$2 = _v$2);
993
993
  return _p$;
994
994
  }, {
995
995
  _v$: void 0,
@@ -1060,6 +1060,7 @@ function BlockStyles(props) {
1060
1060
  },
1061
1061
  get children() {
1062
1062
  return createComponent(inlined_styles_default, {
1063
+ id: "builderio-block",
1063
1064
  get styles() {
1064
1065
  return css5();
1065
1066
  }
@@ -1776,6 +1777,7 @@ function Columns(props) {
1776
1777
  when: TARGET !== "reactNative",
1777
1778
  get children() {
1778
1779
  return createComponent(inlined_styles_default, {
1780
+ id: "builderio-columns",
1779
1781
  get styles() {
1780
1782
  return columnsStyles();
1781
1783
  }
@@ -4043,7 +4045,7 @@ var checkShouldRenderVariants = ({
4043
4045
  };
4044
4046
  var getIsHydrationTarget = (target) => target === "react" || target === "reactNative";
4045
4047
  var isHydrationTarget = getIsHydrationTarget(TARGET);
4046
- var getScriptString = () => `
4048
+ var getInitVariantsFnsScriptString = () => `
4047
4049
  window.${UPDATE_COOKIES_AND_STYLES_SCRIPT_NAME} = ${UPDATE_COOKIES_AND_STYLES_SCRIPT}
4048
4050
  window.${UPDATE_VARIANT_VISIBILITY_SCRIPT_FN_NAME} = ${UPDATE_VARIANT_VISIBILITY_SCRIPT}
4049
4051
  `;
@@ -4062,9 +4064,9 @@ function InlinedScript(props) {
4062
4064
  return (() => {
4063
4065
  const _el$ = _tmpl$16();
4064
4066
  effect((_p$) => {
4065
- const _v$ = props.scriptStr, _v$2 = props.id || "";
4067
+ const _v$ = props.scriptStr, _v$2 = props.id;
4066
4068
  _v$ !== _p$._v$ && (_el$.innerHTML = _p$._v$ = _v$);
4067
- _v$2 !== _p$._v$2 && setAttribute(_el$, "id", _p$._v$2 = _v$2);
4069
+ _v$2 !== _p$._v$2 && setAttribute(_el$, "data-id", _p$._v$2 = _v$2);
4068
4070
  return _p$;
4069
4071
  }, {
4070
4072
  _v$: void 0,
@@ -4556,7 +4558,7 @@ function isFromTrustedHost(trustedHosts, e) {
4556
4558
  }
4557
4559
 
4558
4560
  // src/constants/sdk-version.ts
4559
- var SDK_VERSION = "1.0.15";
4561
+ var SDK_VERSION = "1.0.17";
4560
4562
 
4561
4563
  // src/functions/register.ts
4562
4564
  var registry = {};
@@ -4756,6 +4758,7 @@ var subscribeToEditor = (model, callback, options) => {
4756
4758
  function EnableEditor(props) {
4757
4759
  const [ContentWrapper, setContentWrapper] = createSignal(props.contentWrapper || "div");
4758
4760
  const [httpReqsData, setHttpReqsData] = createSignal({});
4761
+ const [httpReqsPending, setHttpReqsPending] = createSignal({});
4759
4762
  const [clicked, setClicked] = createSignal(false);
4760
4763
  function mergeNewRootState(newData) {
4761
4764
  const combinedState = {
@@ -4854,40 +4857,33 @@ function EnableEditor(props) {
4854
4857
  setClicked(true);
4855
4858
  }
4856
4859
  }
4857
- function evalExpression(expression) {
4858
- return expression.replace(/{{([^}]+)}}/g, (_match, group) => String(evaluate({
4859
- code: group,
4860
- context: props.context || {},
4861
- localState: void 0,
4862
- rootState: props.builderContextSignal.rootState,
4863
- rootSetState: props.builderContextSignal.rootSetState,
4864
- enableCache: true
4865
- })));
4866
- }
4867
- function handleRequest({
4868
- url,
4869
- key
4870
- }) {
4871
- fetch2(url).then((response) => response.json()).then((json) => {
4872
- const newState = {
4873
- ...props.builderContextSignal.rootState,
4874
- [key]: json
4875
- };
4876
- props.builderContextSignal.rootSetState?.(newState);
4877
- httpReqsData()[key] = true;
4878
- }).catch((err) => {
4879
- });
4880
- }
4881
4860
  function runHttpRequests() {
4882
4861
  const requests = props.builderContextSignal.content?.data?.httpRequests ?? {};
4883
4862
  Object.entries(requests).forEach(([key, url]) => {
4884
- if (url && (!httpReqsData()[key] || isEditing())) {
4885
- const evaluatedUrl = evalExpression(url);
4886
- handleRequest({
4887
- url: evaluatedUrl,
4888
- key
4863
+ if (!url)
4864
+ return;
4865
+ if (httpReqsPending()[key])
4866
+ return;
4867
+ if (httpReqsData()[key] && !isEditing())
4868
+ return;
4869
+ httpReqsPending()[key] = true;
4870
+ const evaluatedUrl = url.replace(/{{([^}]+)}}/g, (_match, group) => String(evaluate({
4871
+ code: group,
4872
+ context: props.context || {},
4873
+ localState: void 0,
4874
+ rootState: props.builderContextSignal.rootState,
4875
+ rootSetState: props.builderContextSignal.rootSetState,
4876
+ enableCache: true
4877
+ })));
4878
+ fetch2(evaluatedUrl).then((response) => response.json()).then((json) => {
4879
+ mergeNewRootState({
4880
+ [key]: json
4889
4881
  });
4890
- }
4882
+ httpReqsData()[key] = true;
4883
+ }).catch((err) => {
4884
+ }).finally(() => {
4885
+ httpReqsPending()[key] = false;
4886
+ });
4891
4887
  });
4892
4888
  }
4893
4889
  function emitStateUpdate() {
@@ -5136,6 +5132,7 @@ ${getFontCss({
5136
5132
  ${getDefaultStyles(props.isNestedRender)}
5137
5133
  `.trim());
5138
5134
  return createComponent(inlined_styles_default, {
5135
+ id: "builderio-content",
5139
5136
  get styles() {
5140
5137
  return injectedStyles();
5141
5138
  }
@@ -5289,6 +5286,7 @@ function ContentComponent(props) {
5289
5286
  },
5290
5287
  get children() {
5291
5288
  return createComponent(inlined_script_default, {
5289
+ id: "builderio-variant-visibility",
5292
5290
  get scriptStr() {
5293
5291
  return scriptStr();
5294
5292
  }
@@ -5366,8 +5364,9 @@ function ContentVariants(props) {
5366
5364
  },
5367
5365
  get children() {
5368
5366
  return createComponent(inlined_script_default, {
5367
+ id: "builderio-init-variants-fns",
5369
5368
  get scriptStr() {
5370
- return getScriptString();
5369
+ return getInitVariantsFnsScriptString();
5371
5370
  }
5372
5371
  });
5373
5372
  }
@@ -5377,13 +5376,12 @@ function ContentVariants(props) {
5377
5376
  },
5378
5377
  get children() {
5379
5378
  return [createComponent(inlined_styles_default, {
5380
- get id() {
5381
- return `variants-styles-${props.content?.id}`;
5382
- },
5379
+ id: "builderio-variants",
5383
5380
  get styles() {
5384
5381
  return hideVariantsStyleString();
5385
5382
  }
5386
5383
  }), createComponent(inlined_script_default, {
5384
+ id: "builderio-variants-visibility",
5387
5385
  get scriptStr() {
5388
5386
  return updateCookieAndStylesScriptStr();
5389
5387
  }
@@ -977,7 +977,7 @@ var getSizesForBreakpoints = ({
977
977
 
978
978
  // src/components/inlined-styles.tsx
979
979
  function InlinedStyles(props) {
980
- return <style innerHTML={props.styles} id={props.id} />;
980
+ return <style innerHTML={props.styles} data-id={props.id} />;
981
981
  }
982
982
  var Inlined_styles_default = InlinedStyles;
983
983
 
@@ -1043,7 +1043,7 @@ function BlockStyles(props) {
1043
1043
  }) : "";
1044
1044
  return [largeStylesClass, mediumStylesClass, smallStylesClass].join(" ");
1045
1045
  });
1046
- return <Show2 when={TARGET !== "reactNative" && css5() && canShowBlock()}><Inlined_styles_default styles={css5()} /></Show2>;
1046
+ return <Show2 when={TARGET !== "reactNative" && css5() && canShowBlock()}><Inlined_styles_default id="builderio-block" styles={css5()} /></Show2>;
1047
1047
  }
1048
1048
  var Block_styles_default = BlockStyles;
1049
1049
 
@@ -1578,7 +1578,10 @@ function Columns(props) {
1578
1578
  style={columnsCssVars()}
1579
1579
  {...{}}
1580
1580
  >
1581
- <Show6 when={TARGET !== "reactNative"}><Inlined_styles_default styles={columnsStyles()} /></Show6>
1581
+ <Show6 when={TARGET !== "reactNative"}><Inlined_styles_default
1582
+ id="builderio-columns"
1583
+ styles={columnsStyles()}
1584
+ /></Show6>
1582
1585
  <For4 each={props.columns}>{(column, _index) => {
1583
1586
  const index = _index();
1584
1587
  return <Dynamic_renderer_default
@@ -3628,7 +3631,7 @@ var checkShouldRenderVariants = ({
3628
3631
  };
3629
3632
  var getIsHydrationTarget = (target) => target === "react" || target === "reactNative";
3630
3633
  var isHydrationTarget = getIsHydrationTarget(TARGET);
3631
- var getScriptString = () => `
3634
+ var getInitVariantsFnsScriptString = () => `
3632
3635
  window.${UPDATE_COOKIES_AND_STYLES_SCRIPT_NAME} = ${UPDATE_COOKIES_AND_STYLES_SCRIPT}
3633
3636
  window.${UPDATE_VARIANT_VISIBILITY_SCRIPT_FN_NAME} = ${UPDATE_VARIANT_VISIBILITY_SCRIPT}
3634
3637
  `;
@@ -3645,7 +3648,7 @@ var getUpdateVariantVisibilityScript = ({
3645
3648
 
3646
3649
  // src/components/inlined-script.tsx
3647
3650
  function InlinedScript(props) {
3648
- return <script innerHTML={props.scriptStr} id={props.id || ""} />;
3651
+ return <script innerHTML={props.scriptStr} data-id={props.id} />;
3649
3652
  }
3650
3653
  var Inlined_script_default = InlinedScript;
3651
3654
 
@@ -4141,7 +4144,7 @@ function isFromTrustedHost(trustedHosts, e) {
4141
4144
  }
4142
4145
 
4143
4146
  // src/constants/sdk-version.ts
4144
- var SDK_VERSION = "1.0.15";
4147
+ var SDK_VERSION = "1.0.17";
4145
4148
 
4146
4149
  // src/functions/register.ts
4147
4150
  var registry = {};
@@ -4343,6 +4346,7 @@ function EnableEditor(props) {
4343
4346
  props.contentWrapper || "div"
4344
4347
  );
4345
4348
  const [httpReqsData, setHttpReqsData] = createSignal12({});
4349
+ const [httpReqsPending, setHttpReqsPending] = createSignal12({});
4346
4350
  const [clicked, setClicked] = createSignal12(false);
4347
4351
  function mergeNewRootState(newData) {
4348
4352
  const combinedState = {
@@ -4438,42 +4442,38 @@ function EnableEditor(props) {
4438
4442
  setClicked(true);
4439
4443
  }
4440
4444
  }
4441
- function evalExpression(expression) {
4442
- return expression.replace(
4443
- /{{([^}]+)}}/g,
4444
- (_match, group) => String(
4445
- evaluate({
4446
- code: group,
4447
- context: props.context || {},
4448
- localState: void 0,
4449
- rootState: props.builderContextSignal.rootState,
4450
- rootSetState: props.builderContextSignal.rootSetState,
4451
- enableCache: true
4452
- })
4453
- )
4454
- );
4455
- }
4456
- function handleRequest({ url, key }) {
4457
- fetch2(url).then((response) => response.json()).then((json) => {
4458
- const newState = {
4459
- ...props.builderContextSignal.rootState,
4460
- [key]: json
4461
- };
4462
- props.builderContextSignal.rootSetState?.(newState);
4463
- httpReqsData()[key] = true;
4464
- }).catch((err) => {
4465
- });
4466
- }
4467
4445
  function runHttpRequests() {
4468
4446
  const requests = props.builderContextSignal.content?.data?.httpRequests ?? {};
4469
4447
  Object.entries(requests).forEach(([key, url]) => {
4470
- if (url && (!httpReqsData()[key] || isEditing())) {
4471
- const evaluatedUrl = evalExpression(url);
4472
- handleRequest({
4473
- url: evaluatedUrl,
4474
- key
4448
+ if (!url)
4449
+ return;
4450
+ if (httpReqsPending()[key])
4451
+ return;
4452
+ if (httpReqsData()[key] && !isEditing())
4453
+ return;
4454
+ httpReqsPending()[key] = true;
4455
+ const evaluatedUrl = url.replace(
4456
+ /{{([^}]+)}}/g,
4457
+ (_match, group) => String(
4458
+ evaluate({
4459
+ code: group,
4460
+ context: props.context || {},
4461
+ localState: void 0,
4462
+ rootState: props.builderContextSignal.rootState,
4463
+ rootSetState: props.builderContextSignal.rootSetState,
4464
+ enableCache: true
4465
+ })
4466
+ )
4467
+ );
4468
+ fetch2(evaluatedUrl).then((response) => response.json()).then((json) => {
4469
+ mergeNewRootState({
4470
+ [key]: json
4475
4471
  });
4476
- }
4472
+ httpReqsData()[key] = true;
4473
+ }).catch((err) => {
4474
+ }).finally(() => {
4475
+ httpReqsPending()[key] = false;
4476
+ });
4477
4477
  });
4478
4478
  }
4479
4479
  function emitStateUpdate() {
@@ -4733,7 +4733,10 @@ ${getFontCss({
4733
4733
  ${getDefaultStyles(props.isNestedRender)}
4734
4734
  `.trim()
4735
4735
  );
4736
- return <Inlined_styles_default styles={injectedStyles()} />;
4736
+ return <Inlined_styles_default
4737
+ id="builderio-content"
4738
+ styles={injectedStyles()}
4739
+ />;
4737
4740
  }
4738
4741
  var Styles_default = ContentStyles;
4739
4742
 
@@ -4856,7 +4859,10 @@ function ContentComponent(props) {
4856
4859
  setBuilderContextSignal
4857
4860
  }}
4858
4861
  >
4859
- <Show11 when={props.isSsrAbTest}><Inlined_script_default scriptStr={scriptStr()} /></Show11>
4862
+ <Show11 when={props.isSsrAbTest}><Inlined_script_default
4863
+ id="builderio-variant-visibility"
4864
+ scriptStr={scriptStr()}
4865
+ /></Show11>
4860
4866
  <Show11 when={TARGET !== "reactNative"}><Styles_default
4861
4867
  isNestedRender={props.isNestedRender}
4862
4868
  contentId={builderContextSignal().content?.id}
@@ -4906,13 +4912,17 @@ function ContentVariants(props) {
4906
4912
  setShouldRenderVariants(false);
4907
4913
  });
4908
4914
  return <>
4909
- <Show12 when={!props.isNestedRender && TARGET !== "reactNative"}><Inlined_script_default scriptStr={getScriptString()} /></Show12>
4915
+ <Show12 when={!props.isNestedRender && TARGET !== "reactNative"}><Inlined_script_default
4916
+ id="builderio-init-variants-fns"
4917
+ scriptStr={getInitVariantsFnsScriptString()}
4918
+ /></Show12>
4910
4919
  <Show12 when={shouldRenderVariants()}>
4911
4920
  <Inlined_styles_default
4912
- id={`variants-styles-${props.content?.id}`}
4921
+ id="builderio-variants"
4913
4922
  styles={hideVariantsStyleString()}
4914
4923
  />
4915
4924
  <Inlined_script_default
4925
+ id="builderio-variants-visibility"
4916
4926
  scriptStr={updateCookieAndStylesScriptStr()}
4917
4927
  />
4918
4928
  <For7 each={getVariants(props.content)}>{(variant, _index) => {