@builder.io/sdk-solid 0.8.0 → 0.9.0

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.
@@ -41,7 +41,9 @@ var builder_context_default = createContext({
41
41
  apiKey: null,
42
42
  apiVersion: void 0,
43
43
  componentInfos: {},
44
- inheritedStyles: {}
44
+ inheritedStyles: {},
45
+ BlocksWrapper: "div",
46
+ BlocksWrapperProps: {}
45
47
  });
46
48
 
47
49
  // src/context/components.context.ts
@@ -223,11 +225,16 @@ var set = (obj, _path, value) => {
223
225
 
224
226
  // src/functions/evaluate/node-runtime/safeDynamicRequire.ts
225
227
  import { createRequire } from "node:module";
226
- var noop = () => null;
228
+ var noop = () => {
229
+ };
227
230
  var safeDynamicRequire = noop;
228
231
  try {
229
232
  safeDynamicRequire = createRequire(import.meta.url);
230
233
  } catch (error) {
234
+ try {
235
+ safeDynamicRequire = eval("require");
236
+ } catch (error2) {
237
+ }
231
238
  }
232
239
 
233
240
  // src/functions/evaluate/node-runtime/node-runtime.ts
@@ -713,83 +720,10 @@ function getBlockActions(options) {
713
720
  return obj;
714
721
  }
715
722
 
716
- // src/functions/sanitize-react-native-block-styles.ts
717
- var propertiesThatMustBeNumber = /* @__PURE__ */ new Set(["lineHeight"]);
718
- var displayValues = /* @__PURE__ */ new Set(["flex", "none"]);
719
- var SHOW_WARNINGS = false;
720
- var normalizeNumber = (value) => {
721
- if (Number.isNaN(value)) {
722
- return void 0;
723
- } else if (value < 0) {
724
- return 0;
725
- } else {
726
- return value;
727
- }
728
- };
729
- var sanitizeReactNativeBlockStyles = (styles) => {
730
- return Object.keys(styles).reduce((acc, key) => {
731
- const propertyValue = styles[key];
732
- if (key === "display" && !displayValues.has(propertyValue)) {
733
- if (SHOW_WARNINGS) {
734
- }
735
- return acc;
736
- }
737
- if (propertiesThatMustBeNumber.has(key) && typeof propertyValue !== "number") {
738
- if (SHOW_WARNINGS) {
739
- }
740
- return acc;
741
- }
742
- if (typeof propertyValue === "string") {
743
- const isPixelUnit = propertyValue.match(/^-?(\d*)(\.?)(\d*)*px$/);
744
- if (isPixelUnit) {
745
- const newValue = parseFloat(propertyValue);
746
- const normalizedValue = normalizeNumber(newValue);
747
- if (normalizedValue) {
748
- return {
749
- ...acc,
750
- [key]: normalizedValue
751
- };
752
- } else {
753
- return acc;
754
- }
755
- } else if (propertyValue === "0") {
756
- return {
757
- ...acc,
758
- [key]: 0
759
- };
760
- }
761
- }
762
- return {
763
- ...acc,
764
- [key]: propertyValue
765
- };
766
- }, {});
767
- };
768
-
769
- // src/functions/get-react-native-block-styles.ts
770
- function getReactNativeBlockStyles({
771
- block,
772
- context,
773
- blockStyles
774
- }) {
775
- const responsiveStyles = block.responsiveStyles;
776
- if (!responsiveStyles) {
777
- return {};
778
- }
779
- const styles = {
780
- // recursively apply inherited styles so that they can be passed down to children `Text` blocks
781
- ...context.inheritedStyles,
782
- ...responsiveStyles.large || {},
783
- ...responsiveStyles.medium || {},
784
- ...responsiveStyles.small || {},
785
- ...blockStyles
786
- };
787
- const newStyles = sanitizeReactNativeBlockStyles(styles);
788
- return newStyles;
789
- }
790
-
791
723
  // src/functions/transform-block-properties.ts
792
- function transformBlockProperties(properties) {
724
+ function transformBlockProperties({
725
+ properties
726
+ }) {
793
727
  return properties;
794
728
  }
795
729
 
@@ -810,14 +744,11 @@ function getBlockProperties({
810
744
  style: block.style ? getStyleAttribute(block.style) : void 0,
811
745
  class: [block.id, "builder-block", block.class, block.properties?.class].filter(Boolean).join(" ")
812
746
  };
813
- if (TARGET === "reactNative") {
814
- properties.style = getReactNativeBlockStyles({
815
- block,
816
- context,
817
- blockStyles: properties.style
818
- });
819
- }
820
- return transformBlockProperties(properties);
747
+ return transformBlockProperties({
748
+ properties,
749
+ context,
750
+ block
751
+ });
821
752
  }
822
753
  function getStyleAttribute(style) {
823
754
  switch (TARGET) {
@@ -1107,6 +1038,7 @@ function Block(props) {
1107
1038
  var Block_default = Block;
1108
1039
 
1109
1040
  // src/components/blocks/blocks-wrapper.tsx
1041
+ import { Dynamic as Dynamic4 } from "solid-js/web";
1110
1042
  import { css as css2 } from "solid-styled-components";
1111
1043
  function BlocksWrapper(props) {
1112
1044
  function className() {
@@ -1140,7 +1072,7 @@ function BlocksWrapper(props) {
1140
1072
  );
1141
1073
  }
1142
1074
  }
1143
- return <div
1075
+ return <Dynamic4
1144
1076
  class={className() + " " + css2({
1145
1077
  display: "flex",
1146
1078
  flexDirection: "column",
@@ -1153,7 +1085,9 @@ function BlocksWrapper(props) {
1153
1085
  onClick={(event) => onClick()}
1154
1086
  onMouseEnter={(event) => onMouseEnter()}
1155
1087
  onKeyPress={(event) => onClick()}
1156
- >{props.children}</div>;
1088
+ {...props.BlocksWrapperProps}
1089
+ component={props.BlocksWrapper}
1090
+ >{props.children}</Dynamic4>;
1157
1091
  }
1158
1092
  var Blocks_wrapper_default = BlocksWrapper;
1159
1093
 
@@ -1166,6 +1100,8 @@ function Blocks(props) {
1166
1100
  parent={props.parent}
1167
1101
  path={props.path}
1168
1102
  styleProp={props.styleProp}
1103
+ BlocksWrapper={props.context?.BlocksWrapper}
1104
+ BlocksWrapperProps={props.context?.BlocksWrapperProps}
1169
1105
  >
1170
1106
  <Show6 when={props.blocks}><For3 each={props.blocks}>{(block, _index) => {
1171
1107
  const index = _index();
@@ -2001,7 +1937,7 @@ function CustomCode(props) {
2001
1937
  try {
2002
1938
  scriptsRun().push(script.innerText);
2003
1939
  new Function(script.innerText)();
2004
- } catch (error) {
1940
+ } catch (error2) {
2005
1941
  }
2006
1942
  }
2007
1943
  }
@@ -2080,7 +2016,7 @@ function Embed(props) {
2080
2016
  try {
2081
2017
  scriptsRun().push(script.innerText);
2082
2018
  new Function(script.innerText)();
2083
- } catch (error) {
2019
+ } catch (error2) {
2084
2020
  }
2085
2021
  }
2086
2022
  }
@@ -2656,6 +2592,7 @@ var Inlined_script_default = InlinedScript;
2656
2592
 
2657
2593
  // src/components/content/components/enable-editor.tsx
2658
2594
  import { Show as Show10, onMount as onMount2, on as on2, createEffect as createEffect2, createSignal as createSignal10 } from "solid-js";
2595
+ import { Dynamic as Dynamic5 } from "solid-js/web";
2659
2596
 
2660
2597
  // src/helpers/preview-lru-cache/get.ts
2661
2598
  function getPreviewContent(_searchParams) {
@@ -2882,8 +2819,8 @@ async function fetchEntries(options) {
2882
2819
  return null;
2883
2820
  }
2884
2821
  return _processContentResult(options, content);
2885
- } catch (error) {
2886
- logger.error("Error fetching data. ", error);
2822
+ } catch (error2) {
2823
+ logger.error("Error fetching data. ", error2);
2887
2824
  return null;
2888
2825
  }
2889
2826
  }
@@ -3137,7 +3074,7 @@ var getInteractionPropertiesForEvent = (event) => {
3137
3074
  };
3138
3075
 
3139
3076
  // src/constants/sdk-version.ts
3140
- var SDK_VERSION = "0.8.0";
3077
+ var SDK_VERSION = "0.9.0";
3141
3078
 
3142
3079
  // src/functions/register.ts
3143
3080
  var registry = {};
@@ -3227,18 +3164,18 @@ var setupBrowserForEditing = (options = {}) => {
3227
3164
  const id = data.data.id;
3228
3165
  const fn = new Function(text);
3229
3166
  let result;
3230
- let error = null;
3167
+ let error2 = null;
3231
3168
  try {
3232
3169
  result = fn.apply(null, args);
3233
3170
  } catch (err) {
3234
- error = err;
3171
+ error2 = err;
3235
3172
  }
3236
- if (error) {
3173
+ if (error2) {
3237
3174
  window.parent?.postMessage({
3238
3175
  type: "builder.evaluateError",
3239
3176
  data: {
3240
3177
  id,
3241
- error: error.message
3178
+ error: error2.message
3242
3179
  }
3243
3180
  }, "*");
3244
3181
  } else {
@@ -3274,6 +3211,9 @@ function EnableEditor(props) {
3274
3211
  const [forceReRenderCount, setForceReRenderCount] = createSignal10(0);
3275
3212
  const [lastUpdated, setLastUpdated] = createSignal10(0);
3276
3213
  const [shouldSendResetCookie, setShouldSendResetCookie] = createSignal10(false);
3214
+ const [ContentWrapper, setContentWrapper] = createSignal10(
3215
+ props.contentWrapper || "div"
3216
+ );
3277
3217
  const [httpReqsData, setHttpReqsData] = createSignal10({});
3278
3218
  const [clicked, setClicked] = createSignal10(false);
3279
3219
  function mergeNewContent(newContent) {
@@ -3517,7 +3457,7 @@ function EnableEditor(props) {
3517
3457
  emitStateUpdate();
3518
3458
  }
3519
3459
  createEffect2(on2(() => [props.builderContextSignal.rootState], onUpdateFn_4));
3520
- return <builder_context_default.Provider value={props.builderContextSignal}><Show10 when={props.builderContextSignal.content}><div
3460
+ return <builder_context_default.Provider value={props.builderContextSignal}><Show10 when={props.builderContextSignal.content}><Dynamic5
3521
3461
  class={`variant-${props.content?.testVariationId || props.content?.id}`}
3522
3462
  {...{}}
3523
3463
  key={forceReRenderCount()}
@@ -3530,7 +3470,9 @@ function EnableEditor(props) {
3530
3470
  hidden: true,
3531
3471
  "aria-hidden": true
3532
3472
  }}
3533
- >{props.children}</div></Show10></builder_context_default.Provider>;
3473
+ {...props.contentWrapperProps}
3474
+ component={ContentWrapper()}
3475
+ >{props.children}</Dynamic5></Show10></builder_context_default.Provider>;
3534
3476
  }
3535
3477
  var Enable_editor_default = EnableEditor;
3536
3478
 
@@ -3720,7 +3662,9 @@ function ContentComponent(props) {
3720
3662
  }),
3721
3663
  {}
3722
3664
  ),
3723
- inheritedStyles: {}
3665
+ inheritedStyles: {},
3666
+ BlocksWrapper: props.blocksWrapper || "div",
3667
+ BlocksWrapperProps: props.blocksWrapperProps || {}
3724
3668
  });
3725
3669
  function contentSetState(newRootState) {
3726
3670
  setBuilderContextSignal((PREVIOUS_VALUE) => ({
@@ -3743,6 +3687,8 @@ function ContentComponent(props) {
3743
3687
  enrich={props.enrich}
3744
3688
  showContent={props.showContent}
3745
3689
  builderContextSignal={builderContextSignal()}
3690
+ contentWrapper={props.contentWrapper}
3691
+ contentWrapperProps={props.contentWrapperProps}
3746
3692
  {...{
3747
3693
  setBuilderContextSignal
3748
3694
  }}
@@ -3821,6 +3767,10 @@ function ContentVariants(props) {
3821
3767
  includeRefs={props.includeRefs}
3822
3768
  enrich={props.enrich}
3823
3769
  isSsrAbTest={shouldRenderVariants()}
3770
+ blocksWrapper={props.blocksWrapper}
3771
+ blocksWrapperProps={props.blocksWrapperProps}
3772
+ contentWrapper={props.contentWrapper}
3773
+ contentWrapperProps={props.contentWrapperProps}
3824
3774
  />;
3825
3775
  }}</For5>
3826
3776
  </Show12>
@@ -3839,6 +3789,10 @@ function ContentVariants(props) {
3839
3789
  includeRefs={props.includeRefs}
3840
3790
  enrich={props.enrich}
3841
3791
  isSsrAbTest={shouldRenderVariants()}
3792
+ blocksWrapper={props.blocksWrapper}
3793
+ blocksWrapperProps={props.blocksWrapperProps}
3794
+ contentWrapper={props.contentWrapper}
3795
+ contentWrapperProps={props.contentWrapperProps}
3842
3796
  />
3843
3797
  </>;
3844
3798
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@builder.io/sdk-solid",
3
- "version": "0.8.0",
3
+ "version": "0.9.0",
4
4
  "description": "",
5
5
  "files": [
6
6
  "dist",