@builder.io/sdk-solid 0.1.14 → 0.1.16

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@builder.io/sdk-solid",
3
- "version": "0.1.14",
3
+ "version": "0.1.16",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "main": "./solid-index.jsx",
@@ -7,9 +7,16 @@ function Button(props) {
7
7
  <Show
8
8
  fallback={
9
9
  <button
10
- class={css({
11
- all: "unset",
12
- })}
10
+ class={
11
+ /**
12
+ * We have to explicitly provide `class` so that Mitosis knows to merge it with `css`.
13
+ */
14
+ props.attributes.class +
15
+ " " +
16
+ css({
17
+ all: "unset",
18
+ })
19
+ }
13
20
  {...props.attributes}
14
21
  >
15
22
  {props.text}
@@ -58,26 +58,26 @@ function Columns(props) {
58
58
  }
59
59
 
60
60
  function columnCssVars(index) {
61
- const width = getColumnCssWidth(index);
62
- const gutter = `${index === 0 ? 0 : gutterSize()}px`;
61
+ const gutter = index === 0 ? 0 : gutterSize();
63
62
  if (TARGET === "reactNative") {
64
63
  return {
65
- width,
66
64
  marginLeft: props.stackColumnsAt === "never" ? gutter : 0,
67
65
  };
68
66
  }
67
+ const width = getColumnCssWidth(index);
68
+ const gutterPixels = `${gutterSize()}px`;
69
69
  const mobileWidth = "100%";
70
70
  const mobileMarginLeft = 0;
71
71
  return {
72
72
  width,
73
- "margin-left": gutter,
73
+ "margin-left": gutterPixels,
74
74
  "--column-width-mobile": getMobileStyle({
75
75
  stackedStyle: mobileWidth,
76
76
  desktopStyle: width,
77
77
  }),
78
78
  "--column-margin-left-mobile": getMobileStyle({
79
79
  stackedStyle: mobileMarginLeft,
80
- desktopStyle: gutter,
80
+ desktopStyle: gutterPixels,
81
81
  }),
82
82
  "--column-width-tablet": getTabletStyle({
83
83
  stackedStyle: mobileWidth,
@@ -85,7 +85,7 @@ function Columns(props) {
85
85
  }),
86
86
  "--column-margin-left-tablet": getTabletStyle({
87
87
  stackedStyle: mobileMarginLeft,
88
- desktopStyle: gutter,
88
+ desktopStyle: gutterPixels,
89
89
  }),
90
90
  };
91
91
  }
@@ -92,9 +92,7 @@ function Image(props) {
92
92
  })
93
93
  }
94
94
  style={{
95
- "padding-top":
96
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
97
- props.aspectRatio * 100 + "%",
95
+ "padding-top": props.aspectRatio * 100 + "%",
98
96
  }}
99
97
  ></div>
100
98
  </Show>
@@ -153,6 +153,7 @@ function RenderBlock(props) {
153
153
  };
154
154
  return {
155
155
  apiKey: props.context.apiKey,
156
+ apiVersion: props.context.apiVersion,
156
157
  state: props.context.state,
157
158
  content: props.context.content,
158
159
  context: props.context.context,
@@ -193,7 +193,7 @@ function RenderContent(props) {
193
193
  setContextState(newState);
194
194
  })
195
195
  .catch((err) => {
196
- console.log("error fetching dynamic data", url, err);
196
+ console.error("error fetching dynamic data", url, err);
197
197
  });
198
198
  }
199
199
 
@@ -42,7 +42,11 @@ import { handleABTesting } from "./ab-testing.js";
42
42
  import { generateContentUrl } from "./generate-content-url.js";
43
43
  function getContent(options) {
44
44
  return __async(this, null, function* () {
45
- return (yield getAllContent(__spreadProps(__spreadValues({}, options), { limit: 1 }))).results[0] || null;
45
+ const allContent = yield getAllContent(__spreadProps(__spreadValues({}, options), { limit: 1 }));
46
+ if ("results" in allContent) {
47
+ return (allContent == null ? void 0 : allContent.results[0]) || null;
48
+ }
49
+ return null;
46
50
  });
47
51
  }
48
52
  function getAllContent(options) {
@@ -50,11 +54,19 @@ function getAllContent(options) {
50
54
  const url = generateContentUrl(options);
51
55
  const res = yield fetch(url.href);
52
56
  const content = yield res.json();
57
+ if ("status" in content && !("results" in content)) {
58
+ console.error("[Builder.io]: Error fetching data. ", content, options);
59
+ return content;
60
+ }
53
61
  const canTrack = options.canTrack !== false;
54
- if (canTrack && Array.isArray(content.results)) {
55
- for (const item of content.results) {
56
- yield handleABTesting({ item, canTrack });
62
+ try {
63
+ if (canTrack && Array.isArray(content.results)) {
64
+ for (const item of content.results) {
65
+ yield handleABTesting({ item, canTrack });
66
+ }
57
67
  }
68
+ } catch (e) {
69
+ console.error("[Builder.io]: Could not setup A/B testing. ", e);
58
70
  }
59
71
  return content;
60
72
  });