@builder.io/sdk-solid 2.0.16 → 2.0.21

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.
@@ -255,29 +255,6 @@ var parseCode = (code, {
255
255
  const useCode = useReturn ? `return (${code});` : code;
256
256
  return useCode;
257
257
  };
258
-
259
- // src/functions/evaluate/browser-runtime/browser.ts
260
- var runInBrowser = ({
261
- code,
262
- builder,
263
- context,
264
- event,
265
- localState,
266
- rootSetState,
267
- rootState
268
- }) => {
269
- const functionArgs = getFunctionArguments({
270
- builder,
271
- context,
272
- event,
273
- state: flattenState({
274
- rootState,
275
- localState,
276
- rootSetState
277
- })
278
- });
279
- return new Function(...functionArgs.map(([name]) => name), code)(...functionArgs.map(([, value]) => value));
280
- };
281
258
  function flattenState({
282
259
  rootState,
283
260
  localState,
@@ -312,6 +289,29 @@ function flattenState({
312
289
  });
313
290
  }
314
291
 
292
+ // src/functions/evaluate/browser-runtime/browser.ts
293
+ var runInBrowser = ({
294
+ code,
295
+ builder,
296
+ context,
297
+ event,
298
+ localState,
299
+ rootSetState,
300
+ rootState
301
+ }) => {
302
+ const functionArgs = getFunctionArguments({
303
+ builder,
304
+ context,
305
+ event,
306
+ state: flattenState({
307
+ rootState,
308
+ localState,
309
+ rootSetState
310
+ })
311
+ });
312
+ return new Function(...functionArgs.map(([name]) => name), code)(...functionArgs.map(([, value]) => value));
313
+ };
314
+
315
315
  // src/helpers/nullable.ts
316
316
  var checkIsDefined = (maybeT) => maybeT !== null && maybeT !== void 0;
317
317
 
@@ -1102,6 +1102,14 @@ function BlockWrapper(props) {
1102
1102
  });
1103
1103
  }
1104
1104
  var block_wrapper_default = BlockWrapper;
1105
+ function Awaiter(props) {
1106
+ onMount(() => {
1107
+ });
1108
+ return memo(() => props.children);
1109
+ }
1110
+ var awaiter_default = Awaiter;
1111
+
1112
+ // src/components/block/components/interactive-element.tsx
1105
1113
  function InteractiveElement(props) {
1106
1114
  const attributes = createMemo(() => {
1107
1115
  return props.includeBlockProps ? {
@@ -1118,17 +1126,43 @@ function InteractiveElement(props) {
1118
1126
  })
1119
1127
  } : {};
1120
1128
  });
1121
- return createComponent(Dynamic, mergeProps(() => props.wrapperProps, {
1122
- get attributes() {
1123
- return attributes();
1129
+ return createComponent(Show, {
1130
+ get fallback() {
1131
+ return createComponent(Dynamic, mergeProps(() => props.wrapperProps, {
1132
+ get attributes() {
1133
+ return attributes();
1134
+ },
1135
+ get component() {
1136
+ return props.Wrapper;
1137
+ },
1138
+ get children() {
1139
+ return props.children;
1140
+ }
1141
+ }));
1124
1142
  },
1125
- get component() {
1126
- return props.Wrapper;
1143
+ get when() {
1144
+ return props.Wrapper.load;
1127
1145
  },
1128
1146
  get children() {
1129
- return props.children;
1147
+ return createComponent(awaiter_default, {
1148
+ get load() {
1149
+ return props.Wrapper.load;
1150
+ },
1151
+ get fallback() {
1152
+ return props.Wrapper.fallback;
1153
+ },
1154
+ get props() {
1155
+ return props.wrapperProps;
1156
+ },
1157
+ get attributes() {
1158
+ return attributes();
1159
+ },
1160
+ get children() {
1161
+ return props.children;
1162
+ }
1163
+ });
1130
1164
  }
1131
- }));
1165
+ });
1132
1166
  }
1133
1167
  var interactive_element_default = InteractiveElement;
1134
1168
 
@@ -1503,7 +1537,7 @@ function Block(props) {
1503
1537
  });
1504
1538
  }
1505
1539
  var block_default = Block;
1506
- var _tmpl$2 = /* @__PURE__ */ template(`<style>.dynamic-4da8c6f4 {
1540
+ var _tmpl$2 = /* @__PURE__ */ template(`<style>.dynamic-68b2d7fe {
1507
1541
  display: flex;
1508
1542
  flex-direction: column;
1509
1543
  align-items: stretch;
@@ -1539,7 +1573,7 @@ function BlocksWrapper(props) {
1539
1573
  });
1540
1574
  return [createComponent(Dynamic, mergeProps({
1541
1575
  get ["class"]() {
1542
- return className() + " dynamic-4da8c6f4";
1576
+ return className() + " dynamic-68b2d7fe";
1543
1577
  },
1544
1578
  ref(r$) {
1545
1579
  const _ref$ = blocksWrapperRef;
@@ -1635,7 +1669,7 @@ var getColumnsClass = (id) => {
1635
1669
 
1636
1670
  // src/blocks/columns/columns.tsx
1637
1671
  var _tmpl$3 = /* @__PURE__ */ template(`<div>`);
1638
- var _tmpl$22 = /* @__PURE__ */ template(`<style>.div-3ff242de {
1672
+ var _tmpl$22 = /* @__PURE__ */ template(`<style>.div-46766f1c {
1639
1673
  display: flex;
1640
1674
  line-height: normal;
1641
1675
  }`);
@@ -1756,7 +1790,7 @@ function Columns(props) {
1756
1790
  const _el$ = _tmpl$3();
1757
1791
  spread(_el$, mergeProps({
1758
1792
  get ["class"]() {
1759
- return getColumnsClass(props.builderBlock?.id) + " div-3ff242de";
1793
+ return getColumnsClass(props.builderBlock?.id) + " div-46766f1c";
1760
1794
  },
1761
1795
  get style() {
1762
1796
  return columnsCssVars();
@@ -1881,16 +1915,16 @@ function getSrcSet(url) {
1881
1915
  // src/blocks/image/image.tsx
1882
1916
  var _tmpl$5 = /* @__PURE__ */ template(`<source type=image/webp>`);
1883
1917
  var _tmpl$23 = /* @__PURE__ */ template(`<picture><img>`);
1884
- var _tmpl$32 = /* @__PURE__ */ template(`<div class="builder-image-sizer div-4512e110">`);
1885
- var _tmpl$42 = /* @__PURE__ */ template(`<div class=div-4512e110-2>`);
1886
- var _tmpl$52 = /* @__PURE__ */ template(`<style>.img-4512e110 {
1918
+ var _tmpl$32 = /* @__PURE__ */ template(`<div class="builder-image-sizer div-7e6ffddc">`);
1919
+ var _tmpl$42 = /* @__PURE__ */ template(`<div class=div-7e6ffddc-2>`);
1920
+ var _tmpl$52 = /* @__PURE__ */ template(`<style>.img-7e6ffddc {
1887
1921
  opacity: 1;
1888
1922
  transition: opacity 0.2s ease-in-out;
1889
- }.div-4512e110 {
1923
+ }.div-7e6ffddc {
1890
1924
  width: 100%;
1891
1925
  pointer-events: none;
1892
1926
  font-size: 0;
1893
- }.div-4512e110-2 {
1927
+ }.div-7e6ffddc-2 {
1894
1928
  display: flex;
1895
1929
  flex-direction: column;
1896
1930
  align-items: stretch;
@@ -1954,7 +1988,7 @@ function Image(props) {
1954
1988
  }
1955
1989
  }), _el$3);
1956
1990
  effect((_p$) => {
1957
- const _v$ = "builder-image" + (props.className ? " " + props.className : "") + " img-4512e110", _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 = {
1991
+ const _v$ = "builder-image" + (props.className ? " " + props.className : "") + " img-7e6ffddc", _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 = {
1958
1992
  "object-position": props.backgroundPosition || "center",
1959
1993
  "object-fit": props.backgroundSize || "cover",
1960
1994
  ...aspectRatioCss()
@@ -5236,7 +5270,7 @@ function isFromTrustedHost(trustedHosts, e) {
5236
5270
  }
5237
5271
 
5238
5272
  // src/constants/sdk-version.ts
5239
- var SDK_VERSION = "2.0.16";
5273
+ var SDK_VERSION = "2.0.21";
5240
5274
 
5241
5275
  // src/functions/register.ts
5242
5276
  var registry = {};
@@ -5589,22 +5623,6 @@ function EnableEditor(props) {
5589
5623
  }
5590
5624
  })(event);
5591
5625
  }
5592
- function evaluateJsCode() {
5593
- const jsCode = props.builderContextSignal.content?.data?.jsCode;
5594
- if (jsCode) {
5595
- evaluate({
5596
- code: jsCode,
5597
- context: props.context || {},
5598
- localState: void 0,
5599
- rootState: props.builderContextSignal.rootState,
5600
- rootSetState: props.builderContextSignal.rootSetState,
5601
- /**
5602
- * We don't want to cache the result of the JS code, since it's arbitrary side effect code.
5603
- */
5604
- enableCache: false
5605
- });
5606
- }
5607
- }
5608
5626
  function onClick(event) {
5609
5627
  if (props.builderContextSignal.content) {
5610
5628
  const variationId = props.builderContextSignal.content?.testVariationId;
@@ -5641,7 +5659,7 @@ function EnableEditor(props) {
5641
5659
  rootSetState: props.builderContextSignal.rootSetState,
5642
5660
  enableCache: true
5643
5661
  })));
5644
- fetch2(evaluatedUrl).then((response) => response.json()).then((json) => {
5662
+ fetch(evaluatedUrl).then((response) => response.json()).then((json) => {
5645
5663
  mergeNewRootState({
5646
5664
  [key]: json
5647
5665
  });
@@ -5665,6 +5683,8 @@ function EnableEditor(props) {
5665
5683
  }
5666
5684
  }
5667
5685
  let elementRef;
5686
+ runHttpRequests();
5687
+ emitStateUpdate();
5668
5688
  onMount(() => {
5669
5689
  if (isBrowser()) {
5670
5690
  if (isEditing()) {
@@ -5719,14 +5739,6 @@ function EnableEditor(props) {
5719
5739
  }
5720
5740
  }
5721
5741
  });
5722
- onMount(() => {
5723
- if (!props.apiKey) {
5724
- logger.error("No API key provided to `Content` component. This can cause issues. Please provide an API key using the `apiKey` prop.");
5725
- }
5726
- evaluateJsCode();
5727
- runHttpRequests();
5728
- emitStateUpdate();
5729
- });
5730
5742
  const onUpdateFn_0_props_content = createMemo(() => props.content);
5731
5743
  function onUpdateFn_0() {
5732
5744
  if (props.content) {
@@ -5734,37 +5746,27 @@ function EnableEditor(props) {
5734
5746
  }
5735
5747
  }
5736
5748
  createEffect(on(() => [onUpdateFn_0_props_content()], onUpdateFn_0));
5737
- const onUpdateFn_1_props_builderContextSignal_content__data__jsCode = createMemo(() => props.builderContextSignal.content?.data?.jsCode);
5749
+ const onUpdateFn_1_props_builderContextSignal_rootState = createMemo(() => props.builderContextSignal.rootState);
5738
5750
  function onUpdateFn_1() {
5739
- evaluateJsCode();
5740
- }
5741
- createEffect(on(() => [onUpdateFn_1_props_builderContextSignal_content__data__jsCode()], onUpdateFn_1));
5742
- const onUpdateFn_2_props_builderContextSignal_content__data__httpRequests = createMemo(() => props.builderContextSignal.content?.data?.httpRequests);
5743
- function onUpdateFn_2() {
5744
- runHttpRequests();
5745
- }
5746
- createEffect(on(() => [onUpdateFn_2_props_builderContextSignal_content__data__httpRequests()], onUpdateFn_2));
5747
- const onUpdateFn_3_props_builderContextSignal_rootState = createMemo(() => props.builderContextSignal.rootState);
5748
- function onUpdateFn_3() {
5749
5751
  emitStateUpdate();
5750
5752
  }
5751
- createEffect(on(() => [onUpdateFn_3_props_builderContextSignal_rootState()], onUpdateFn_3));
5752
- const onUpdateFn_4_props_data = createMemo(() => props.data);
5753
- function onUpdateFn_4() {
5753
+ createEffect(on(() => [onUpdateFn_1_props_builderContextSignal_rootState()], onUpdateFn_1));
5754
+ const onUpdateFn_2_props_data = createMemo(() => props.data);
5755
+ function onUpdateFn_2() {
5754
5756
  if (props.data) {
5755
5757
  mergeNewRootState(props.data);
5756
5758
  }
5757
5759
  }
5758
- createEffect(on(() => [onUpdateFn_4_props_data()], onUpdateFn_4));
5759
- const onUpdateFn_5_props_locale = createMemo(() => props.locale);
5760
- function onUpdateFn_5() {
5760
+ createEffect(on(() => [onUpdateFn_2_props_data()], onUpdateFn_2));
5761
+ const onUpdateFn_3_props_locale = createMemo(() => props.locale);
5762
+ function onUpdateFn_3() {
5761
5763
  if (props.locale) {
5762
5764
  mergeNewRootState({
5763
5765
  locale: props.locale
5764
5766
  });
5765
5767
  }
5766
5768
  }
5767
- createEffect(on(() => [onUpdateFn_5_props_locale()], onUpdateFn_5));
5769
+ createEffect(on(() => [onUpdateFn_3_props_locale()], onUpdateFn_3));
5768
5770
  return createComponent(builder_context_default.Provider, {
5769
5771
  get value() {
5770
5772
  return props.builderContextSignal;
@@ -5932,6 +5934,29 @@ function ContentComponent(props) {
5932
5934
  rootState: newRootState
5933
5935
  }));
5934
5936
  }
5937
+ if (!props.apiKey) {
5938
+ logger.error("No API key provided to `Content` component. This can cause issues. Please provide an API key using the `apiKey` prop.");
5939
+ }
5940
+ const jsCode = builderContextSignal().content?.data?.jsCode;
5941
+ if (jsCode) {
5942
+ evaluate({
5943
+ code: jsCode,
5944
+ context: props.context || {},
5945
+ localState: void 0,
5946
+ rootState: builderContextSignal().rootState,
5947
+ rootSetState: (newState) => {
5948
+ setBuilderContextSignal((PREVIOUS_VALUE) => ({
5949
+ ...PREVIOUS_VALUE,
5950
+ rootState: newState
5951
+ }));
5952
+ },
5953
+ isExpression: false,
5954
+ /**
5955
+ * We don't want to cache the result of the JS code, since it's arbitrary side effect code.
5956
+ */
5957
+ enableCache: false
5958
+ });
5959
+ }
5935
5960
  return createComponent(components_context_default.Provider, {
5936
5961
  get value() {
5937
5962
  return {