@builder.io/sdk-react 0.0.4 → 0.0.6-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.
Files changed (30) hide show
  1. package/README.md +4 -0
  2. package/package.json +1 -4
  3. package/packages/_rsc/src/blocks/columns/columns.js +73 -16
  4. package/packages/_rsc/src/blocks/section/section.js +12 -3
  5. package/packages/_rsc/src/blocks/symbol/symbol.js +10 -1
  6. package/packages/_rsc/src/components/render-block/render-block.js +10 -5
  7. package/packages/_rsc/src/components/render-content/render-content.js +20 -5
  8. package/packages/_rsc/src/functions/get-block-properties.js +22 -1
  9. package/packages/_rsc/src/functions/get-content/generate-content-url.js +55 -0
  10. package/packages/_rsc/src/functions/get-content/{fn.test.js → generate-content-url.test.js} +1 -1
  11. package/packages/_rsc/src/functions/get-content/index.js +4 -40
  12. package/packages/_rsc/src/functions/get-fetch.js +9 -29
  13. package/packages/_rsc/src/functions/get-global-this.js +1 -1
  14. package/packages/_rsc/src/functions/get-react-native-block-styles.js +3 -2
  15. package/packages/_rsc/src/functions/transform-block-properties.js +6 -0
  16. package/packages/_rsc/src/helpers/css.js +9 -3
  17. package/src/blocks/columns/columns.jsx +72 -16
  18. package/src/blocks/section/section.jsx +12 -3
  19. package/src/blocks/symbol/symbol.jsx +12 -3
  20. package/src/components/render-block/render-block.jsx +10 -5
  21. package/src/components/render-content/render-content.jsx +20 -5
  22. package/src/functions/get-block-properties.js +22 -1
  23. package/src/functions/get-content/generate-content-url.js +55 -0
  24. package/src/functions/get-content/{fn.test.js → generate-content-url.test.js} +1 -1
  25. package/src/functions/get-content/index.js +4 -40
  26. package/src/functions/get-fetch.js +9 -29
  27. package/src/functions/get-global-this.js +1 -1
  28. package/src/functions/get-react-native-block-styles.js +3 -2
  29. package/src/functions/transform-block-properties.js +6 -0
  30. package/src/helpers/css.js +9 -3
package/README.md CHANGED
@@ -17,3 +17,7 @@ npm install @builder.io/sdk-react@dev
17
17
  ```
18
18
 
19
19
  Take a look at [our example repo](/examples/react-v2) for how to use this SDK.
20
+
21
+ ## Fetch
22
+
23
+ This Package uses fetch. See [these docs](https://github.com/BuilderIO/this-package-uses-fetch/blob/main/README.md) for more information.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@builder.io/sdk-react",
3
3
  "description": "Builder.io SDK for React",
4
- "version": "0.0.4",
4
+ "version": "0.0.6-0",
5
5
  "main": "src/index.js",
6
6
  "type": "module",
7
7
  "exports": {
@@ -24,8 +24,5 @@
24
24
  },
25
25
  "devDependencies": {
26
26
  "react": "^18.2.0"
27
- },
28
- "dependencies": {
29
- "node-fetch": "^2.6.1"
30
27
  }
31
28
  }
@@ -16,6 +16,10 @@ var __spreadValues = (a, b) => {
16
16
  };
17
17
  import * as React from "react";
18
18
  import RenderBlocks from "../../components/render-blocks.js";
19
+ import { getSizesForBreakpoints } from "../../constants/device-sizes";
20
+ import RenderInlinedStyles from "../../components/render-inlined-styles.js";
21
+ import { TARGET } from "../../constants/target.js";
22
+ import { convertStyleMapToCSS } from "../../helpers/css";
19
23
  function Columns(props) {
20
24
  var _a;
21
25
  const _context = __spreadValues({}, props["_context"]);
@@ -57,17 +61,77 @@ function Columns(props) {
57
61
  "--column-width-tablet": state.maybeApplyForTablet(width),
58
62
  "--column-margin-left-tablet": state.maybeApplyForTablet(marginLeft)
59
63
  };
64
+ },
65
+ getWidthForBreakpointSize(size) {
66
+ const breakpointSizes = getSizesForBreakpoints(props.customBreakpoints || {});
67
+ return breakpointSizes[size].max;
68
+ },
69
+ get columnStyleObjects() {
70
+ return {
71
+ columns: {
72
+ small: {
73
+ flexDirection: "var(--flex-dir)",
74
+ alignItems: "stretch"
75
+ },
76
+ medium: {
77
+ flexDirection: "var(--flex-dir-tablet)",
78
+ alignItems: "stretch"
79
+ }
80
+ },
81
+ column: {
82
+ small: {
83
+ width: "var(--column-width) !important",
84
+ marginLeft: "var(--column-margin-left) !important"
85
+ },
86
+ medium: {
87
+ width: "var(--column-width-tablet) !important",
88
+ marginLeft: "var(--column-margin-left-tablet) !important"
89
+ }
90
+ }
91
+ };
92
+ },
93
+ get columnsStyles() {
94
+ return `
95
+ @media (max-width: ${state.getWidthForBreakpointSize("medium")}px) {
96
+ .${props.builderBlock.id}-breakpoints {
97
+ ${convertStyleMapToCSS(state.columnStyleObjects.columns.medium)}
98
+ }
99
+
100
+ .${props.builderBlock.id}-breakpoints > .builder-column {
101
+ ${convertStyleMapToCSS(state.columnStyleObjects.column.medium)}
102
+ }
103
+ }
104
+
105
+ @media (max-width: ${state.getWidthForBreakpointSize("small")}px) {
106
+ .${props.builderBlock.id}-breakpoints {
107
+ ${convertStyleMapToCSS(state.columnStyleObjects.columns.small)}
108
+ }
109
+
110
+ .${props.builderBlock.id}-breakpoints > .builder-column {
111
+ ${convertStyleMapToCSS(state.columnStyleObjects.column.small)}
112
+ }
113
+ },
114
+ `;
115
+ },
116
+ get reactNativeColumnsStyles() {
117
+ return this.columnStyleObjects.columns.small;
118
+ },
119
+ get reactNativeColumnStyles() {
120
+ return this.columnStyleObjects.column.small;
60
121
  }
61
122
  };
62
123
  return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("div", {
63
- className: "builder-columns div-6bcd11d2",
64
- style: state.columnsCssVars
65
- }, (_a = props.columns) == null ? void 0 : _a.map((column, index) => /* @__PURE__ */ React.createElement("div", {
66
- className: "builder-column div-6bcd11d2-2",
67
- style: __spreadValues({
124
+ className: `builder-columns ${props.builderBlock.id}-breakpoints div-540739f0`,
125
+ style: __spreadValues(__spreadValues({}, TARGET === "reactNative" ? state.reactNativeColumnsStyles : {}), state.columnsCssVars)
126
+ }, TARGET !== "reactNative" ? /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(RenderInlinedStyles, {
127
+ styles: state.columnsStyles,
128
+ _context
129
+ })) : null, (_a = props.columns) == null ? void 0 : _a.map((column, index) => /* @__PURE__ */ React.createElement("div", {
130
+ className: "builder-column div-540739f0-2",
131
+ style: __spreadValues(__spreadValues({
68
132
  width: state.getColumnCssWidth(index),
69
133
  marginLeft: `${index === 0 ? 0 : state.getGutterSize()}px`
70
- }, state.columnCssVars),
134
+ }, TARGET === "reactNative" ? state.reactNativeColumnStyles : {}), state.columnCssVars),
71
135
  key: index
72
136
  }, /* @__PURE__ */ React.createElement(RenderBlocks, {
73
137
  blocks: column.blocks,
@@ -77,19 +141,12 @@ function Columns(props) {
77
141
  flexGrow: "1"
78
142
  },
79
143
  _context
80
- })))), /* @__PURE__ */ React.createElement("style", null, `.div-6bcd11d2 {
144
+ })))), /* @__PURE__ */ React.createElement("style", null, `.div-540739f0 {
81
145
  display: flex;
82
- align-items: stretch;
83
- line-height: normal; }@media (max-width: 991px) { .div-6bcd11d2 {
84
- flex-direction: var(--flex-dir-tablet); } }@media (max-width: 639px) { .div-6bcd11d2 {
85
- flex-direction: var(--flex-dir); } }.div-6bcd11d2-2 {
146
+ line-height: normal; }.div-540739f0-2 {
86
147
  display: flex;
87
148
  flex-direction: column;
88
- align-items: stretch; }@media (max-width: 991px) { .div-6bcd11d2-2 {
89
- width: var(--column-width-tablet) !important;
90
- margin-left: var(--column-margin-left-tablet) !important; } }@media (max-width: 639px) { .div-6bcd11d2-2 {
91
- width: var(--column-width) !important;
92
- margin-left: var(--column-margin-left) !important; } }`));
149
+ align-items: stretch; }`));
93
150
  }
94
151
  export {
95
152
  Columns as default
@@ -21,9 +21,18 @@ import * as React from "react";
21
21
  function SectionComponent(props) {
22
22
  const _context = __spreadValues({}, props["_context"]);
23
23
  return /* @__PURE__ */ React.createElement("section", __spreadProps(__spreadValues({}, props.attributes), {
24
- style: props.maxWidth && typeof props.maxWidth === "number" ? {
25
- maxWidth: props.maxWidth
26
- } : void 0
24
+ style: {
25
+ width: "100%",
26
+ alignSelf: "stretch",
27
+ flexGrow: "1",
28
+ boxSizing: "border-box",
29
+ maxWidth: `${props.maxWidth && typeof props.maxWidth === "number" ? props.maxWidth : 1200}px`,
30
+ display: "flex",
31
+ flexDirection: "column",
32
+ alignItems: "stretch",
33
+ marginLeft: "auto",
34
+ marginRight: "auto"
35
+ }
27
36
  }), props.children);
28
37
  }
29
38
  export {
@@ -19,11 +19,20 @@ var __spreadValues = (a, b) => {
19
19
  var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
20
20
  import * as React from "react";
21
21
  import RenderContent from "../../components/render-content/render-content.js";
22
+ import { TARGET } from "../../constants/target";
22
23
  function Symbol(props) {
23
24
  var _a, _b, _c, _d, _e;
24
25
  const _context = __spreadValues({}, props["_context"]);
25
26
  const state = {
26
- className: "builder-symbol",
27
+ get className() {
28
+ var _a2, _b2;
29
+ return [
30
+ ...TARGET === "vue2" || TARGET === "vue3" ? Object.keys(props.attributes.class) : [props.attributes.class],
31
+ "builder-symbol",
32
+ ((_a2 = props.symbol) == null ? void 0 : _a2.inline) ? "builder-inline-symbol" : void 0,
33
+ ((_b2 = props.symbol) == null ? void 0 : _b2.dynamic) || props.dynamic ? "builder-dynamic-symbol" : void 0
34
+ ].filter(Boolean).join(" ");
35
+ },
27
36
  fetchedContent: null,
28
37
  get contentToUse() {
29
38
  var _a2;
@@ -88,10 +88,12 @@ function RenderBlock(props) {
88
88
  });
89
89
  },
90
90
  get attributes() {
91
- return __spreadValues(__spreadValues({}, getBlockProperties(state.useBlock)), TARGET === "reactNative" ? {
91
+ const blockProperties = getBlockProperties(state.useBlock);
92
+ return __spreadValues(__spreadValues({}, blockProperties), TARGET === "reactNative" ? {
92
93
  style: getReactNativeBlockStyles({
93
94
  block: state.useBlock,
94
- context: props.context
95
+ context: props.context,
96
+ blockStyles: blockProperties.style
95
97
  })
96
98
  } : {});
97
99
  },
@@ -100,12 +102,14 @@ function RenderBlock(props) {
100
102
  return !((_a2 = state.component) == null ? void 0 : _a2.noWrap);
101
103
  },
102
104
  get renderComponentProps() {
103
- var _a2;
105
+ var _a2, _b2, _c2, _d;
104
106
  return {
105
107
  blockChildren: state.useChildren,
106
108
  componentRef: (_a2 = state.component) == null ? void 0 : _a2.component,
107
- componentOptions: __spreadValues(__spreadValues({}, getBlockComponentOptions(state.useBlock)), state.shouldWrap ? {} : {
109
+ componentOptions: __spreadProps(__spreadValues(__spreadValues({}, getBlockComponentOptions(state.useBlock)), state.shouldWrap ? {} : {
108
110
  attributes: __spreadValues(__spreadValues({}, state.attributes), state.actions)
111
+ }), {
112
+ customBreakpoints: (_d = (_c2 = (_b2 = state.childrenContext) == null ? void 0 : _b2.content) == null ? void 0 : _c2.meta) == null ? void 0 : _d.breakpoints
109
113
  }),
110
114
  context: state.childrenContext
111
115
  };
@@ -153,7 +157,8 @@ function RenderBlock(props) {
153
157
  }
154
158
  const styles = getReactNativeBlockStyles({
155
159
  block: state.useBlock,
156
- context: props.context
160
+ context: props.context,
161
+ blockStyles: state.attributes.style
157
162
  });
158
163
  return extractTextStyles(styles);
159
164
  },
@@ -21,7 +21,7 @@ import * as React from "react";
21
21
  import { getDefaultRegisteredComponents } from "../../constants/builder-registered-components.js";
22
22
  import { TARGET } from "../../constants/target.js";
23
23
  import { evaluate } from "../../functions/evaluate.js";
24
- import { getFetch } from "../../functions/get-fetch.js";
24
+ import { fetch } from "../../functions/get-fetch.js";
25
25
  import { isEditing } from "../../functions/is-editing.js";
26
26
  import {
27
27
  components
@@ -34,18 +34,22 @@ function RenderContent(props) {
34
34
  const _context = __spreadValues({}, props["_context"]);
35
35
  const state = {
36
36
  forceReRenderCount: 0,
37
+ overrideContent: null,
37
38
  get useContent() {
38
- var _a2, _b2;
39
+ var _a2, _b2, _c2, _d2, _e2, _f2, _g2, _h;
39
40
  if (!props.content && !state.overrideContent) {
40
41
  return void 0;
41
42
  }
42
43
  const mergedContent = __spreadProps(__spreadValues(__spreadValues({}, props.content), state.overrideContent), {
43
- data: __spreadValues(__spreadValues(__spreadValues({}, (_a2 = props.content) == null ? void 0 : _a2.data), props.data), (_b2 = state.overrideContent) == null ? void 0 : _b2.data)
44
+ data: __spreadValues(__spreadValues(__spreadValues({}, (_a2 = props.content) == null ? void 0 : _a2.data), props.data), (_b2 = state.overrideContent) == null ? void 0 : _b2.data),
45
+ meta: __spreadProps(__spreadValues(__spreadValues({}, (_c2 = props.content) == null ? void 0 : _c2.meta), (_d2 = state.overrideContent) == null ? void 0 : _d2.meta), {
46
+ breakpoints: state.useBreakpoints || ((_f2 = (_e2 = state.overrideContent) == null ? void 0 : _e2.meta) == null ? void 0 : _f2.breakpoints) || ((_h = (_g2 = props.content) == null ? void 0 : _g2.meta) == null ? void 0 : _h.breakpoints)
47
+ })
44
48
  });
45
49
  return mergedContent;
46
50
  },
47
- overrideContent: null,
48
51
  update: 0,
52
+ useBreakpoints: null,
49
53
  get canTrackToUse() {
50
54
  return props.canTrack || true;
51
55
  },
@@ -71,9 +75,20 @@ function RenderContent(props) {
71
75
  return allComponents;
72
76
  },
73
77
  processMessage(event) {
78
+ var _a2;
74
79
  const { data } = event;
75
80
  if (data) {
76
81
  switch (data.type) {
82
+ case "builder.configureSdk": {
83
+ const messageContent = data.data;
84
+ const { breakpoints, contentId } = messageContent;
85
+ if (!contentId || contentId !== ((_a2 = state.useContent) == null ? void 0 : _a2.id)) {
86
+ return;
87
+ }
88
+ state.useBreakpoints = breakpoints;
89
+ state.forceReRenderCount = state.forceReRenderCount + 1;
90
+ break;
91
+ }
77
92
  case "builder.contentUpdate": {
78
93
  const messageContent = data.data;
79
94
  const key = messageContent.key || messageContent.alias || messageContent.entry || messageContent.modelName;
@@ -126,7 +141,7 @@ function RenderContent(props) {
126
141
  }));
127
142
  },
128
143
  handleRequest({ url, key }) {
129
- getFetch().then((fetch) => fetch(url)).then((response) => response.json()).then((json) => {
144
+ fetch(url).then((response) => response.json()).then((json) => {
130
145
  const newOverrideState = __spreadProps(__spreadValues({}, state.overrideState), {
131
146
  [key]: json
132
147
  });
@@ -17,12 +17,33 @@ var __spreadValues = (a, b) => {
17
17
  return a;
18
18
  };
19
19
  var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
20
+ import { TARGET } from "../constants/target.js";
21
+ import { convertStyleMapToCSSArray } from "../helpers/css.js";
22
+ import { transformBlockProperties } from "./transform-block-properties.js";
20
23
  function getBlockProperties(block) {
21
24
  var _a;
22
- return __spreadProps(__spreadValues({}, block.properties), {
25
+ const properties = __spreadProps(__spreadValues({}, block.properties), {
23
26
  "builder-id": block.id,
27
+ style: getStyleAttribute(block.style),
24
28
  class: [block.id, "builder-block", block.class, (_a = block.properties) == null ? void 0 : _a.class].filter(Boolean).join(" ")
25
29
  });
30
+ return transformBlockProperties(properties);
31
+ }
32
+ function getStyleAttribute(style) {
33
+ if (!style) {
34
+ return void 0;
35
+ }
36
+ switch (TARGET) {
37
+ case "svelte":
38
+ case "vue2":
39
+ case "vue3":
40
+ case "solid":
41
+ return convertStyleMapToCSSArray(style).join(" ");
42
+ case "qwik":
43
+ case "reactNative":
44
+ case "react":
45
+ return style;
46
+ }
26
47
  }
27
48
  export {
28
49
  getBlockProperties
@@ -0,0 +1,55 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
3
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
4
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
5
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
6
+ var __spreadValues = (a, b) => {
7
+ for (var prop in b || (b = {}))
8
+ if (__hasOwnProp.call(b, prop))
9
+ __defNormalProp(a, prop, b[prop]);
10
+ if (__getOwnPropSymbols)
11
+ for (var prop of __getOwnPropSymbols(b)) {
12
+ if (__propIsEnum.call(b, prop))
13
+ __defNormalProp(a, prop, b[prop]);
14
+ }
15
+ return a;
16
+ };
17
+ import { flatten } from "../../helpers/flatten.js";
18
+ import {
19
+ getBuilderSearchParamsFromWindow,
20
+ normalizeSearchParams
21
+ } from "../get-builder-search-params/index.js";
22
+ const generateContentUrl = (options) => {
23
+ const {
24
+ limit = 30,
25
+ userAttributes,
26
+ query,
27
+ noTraverse = false,
28
+ model,
29
+ apiKey,
30
+ includeRefs = true,
31
+ locale
32
+ } = options;
33
+ if (!apiKey) {
34
+ throw new Error("Missing API key");
35
+ }
36
+ const url = new URL(`https://cdn.builder.io/api/v2/content/${model}?apiKey=${apiKey}&limit=${limit}&noTraverse=${noTraverse}&includeRefs=${includeRefs}${locale ? `&locale=${locale}` : ""}`);
37
+ const queryOptions = __spreadValues(__spreadValues({}, getBuilderSearchParamsFromWindow()), normalizeSearchParams(options.options || {}));
38
+ const flattened = flatten(queryOptions);
39
+ for (const key in flattened) {
40
+ url.searchParams.set(key, String(flattened[key]));
41
+ }
42
+ if (userAttributes) {
43
+ url.searchParams.set("userAttributes", JSON.stringify(userAttributes));
44
+ }
45
+ if (query) {
46
+ const flattened2 = flatten({ query });
47
+ for (const key in flattened2) {
48
+ url.searchParams.set(key, JSON.stringify(flattened2[key]));
49
+ }
50
+ }
51
+ return url;
52
+ };
53
+ export {
54
+ generateContentUrl
55
+ };
@@ -1,4 +1,4 @@
1
- import { generateContentUrl } from ".";
1
+ import { generateContentUrl } from "./generate-content-url";
2
2
  const testKey = "YJIGb4i01jvw0SRdL5Bt";
3
3
  const testModel = "page";
4
4
  const testId = "c1b81bab59704599b997574eb0736def";
@@ -37,54 +37,19 @@ var __async = (__this, __arguments, generator) => {
37
37
  step((generator = generator.apply(__this, __arguments)).next());
38
38
  });
39
39
  };
40
- import { flatten } from "../../helpers/flatten.js";
41
- import {
42
- getBuilderSearchParamsFromWindow,
43
- normalizeSearchParams
44
- } from "../get-builder-search-params/index.js";
45
- import { getFetch } from "../get-fetch.js";
40
+ import { fetch } from "../get-fetch.js";
46
41
  import { handleABTesting } from "./ab-testing.js";
42
+ import { generateContentUrl } from "./generate-content-url.js";
47
43
  function getContent(options) {
48
44
  return __async(this, null, function* () {
49
45
  return (yield getAllContent(__spreadProps(__spreadValues({}, options), { limit: 1 }))).results[0] || null;
50
46
  });
51
47
  }
52
- const generateContentUrl = (options) => {
53
- const {
54
- limit = 30,
55
- userAttributes,
56
- query,
57
- noTraverse = false,
58
- model,
59
- apiKey,
60
- includeRefs = true,
61
- locale
62
- } = options;
63
- if (!apiKey) {
64
- throw new Error("Missing API key");
65
- }
66
- const url = new URL(`https://cdn.builder.io/api/v2/content/${model}?apiKey=${apiKey}&limit=${limit}&noTraverse=${noTraverse}&includeRefs=${includeRefs}${locale ? `&locale=${locale}` : ""}`);
67
- const queryOptions = __spreadValues(__spreadValues({}, getBuilderSearchParamsFromWindow()), normalizeSearchParams(options.options || {}));
68
- const flattened = flatten(queryOptions);
69
- for (const key in flattened) {
70
- url.searchParams.set(key, String(flattened[key]));
71
- }
72
- if (userAttributes) {
73
- url.searchParams.set("userAttributes", JSON.stringify(userAttributes));
74
- }
75
- if (query) {
76
- const flattened2 = flatten({ query });
77
- for (const key in flattened2) {
78
- url.searchParams.set(key, JSON.stringify(flattened2[key]));
79
- }
80
- }
81
- return url;
82
- };
83
48
  function getAllContent(options) {
84
49
  return __async(this, null, function* () {
85
50
  const url = generateContentUrl(options);
86
- const fetch = yield getFetch();
87
- const content = yield fetch(url.href).then((res) => res.json());
51
+ const res = yield fetch(url.href);
52
+ const content = yield res.json();
88
53
  const canTrack = options.canTrack !== false;
89
54
  if (canTrack && Array.isArray(content.results)) {
90
55
  for (const item of content.results) {
@@ -95,7 +60,6 @@ function getAllContent(options) {
95
60
  });
96
61
  }
97
62
  export {
98
- generateContentUrl,
99
63
  getAllContent,
100
64
  getContent
101
65
  };
@@ -1,34 +1,14 @@
1
- var __async = (__this, __arguments, generator) => {
2
- return new Promise((resolve, reject) => {
3
- var fulfilled = (value) => {
4
- try {
5
- step(generator.next(value));
6
- } catch (e) {
7
- reject(e);
8
- }
9
- };
10
- var rejected = (value) => {
11
- try {
12
- step(generator.throw(value));
13
- } catch (e) {
14
- reject(e);
15
- }
16
- };
17
- var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
18
- step((generator = generator.apply(__this, __arguments)).next());
19
- });
20
- };
21
1
  import { getGlobalThis } from "./get-global-this.js";
22
2
  function getFetch() {
23
- return __async(this, null, function* () {
24
- const globalFetch = getGlobalThis().fetch;
25
- if (typeof globalFetch === "undefined" && typeof global !== "undefined") {
26
- const nodeFetch = import("node-fetch").then((d) => d.default);
27
- return nodeFetch.default || nodeFetch;
28
- }
29
- return globalFetch.default || globalFetch;
30
- });
3
+ const globalFetch = getGlobalThis().fetch;
4
+ if (typeof globalFetch === "undefined") {
5
+ console.warn(`Builder SDK could not find a global fetch function. Make sure you have a polyfill for fetch in your project.
6
+ For more information, read https://github.com/BuilderIO/this-package-uses-fetch`);
7
+ throw new Error("Builder SDK could not find a global `fetch` function");
8
+ }
9
+ return globalFetch;
31
10
  }
11
+ const fetch = getFetch();
32
12
  export {
33
- getFetch
13
+ fetch
34
14
  };
@@ -11,7 +11,7 @@ function getGlobalThis() {
11
11
  if (typeof self !== "undefined") {
12
12
  return self;
13
13
  }
14
- return null;
14
+ return globalThis;
15
15
  }
16
16
  export {
17
17
  getGlobalThis
@@ -17,13 +17,14 @@ var __spreadValues = (a, b) => {
17
17
  import { sanitizeReactNativeBlockStyles } from "./sanitize-react-native-block-styles.js";
18
18
  function getReactNativeBlockStyles({
19
19
  block,
20
- context
20
+ context,
21
+ blockStyles
21
22
  }) {
22
23
  const responsiveStyles = block.responsiveStyles;
23
24
  if (!responsiveStyles) {
24
25
  return {};
25
26
  }
26
- const styles = __spreadValues(__spreadValues(__spreadValues(__spreadValues({}, context.inheritedStyles), responsiveStyles.large || {}), responsiveStyles.medium || {}), responsiveStyles.small || {});
27
+ const styles = __spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues({}, context.inheritedStyles), responsiveStyles.large || {}), responsiveStyles.medium || {}), responsiveStyles.small || {}), blockStyles);
27
28
  const newStyles = sanitizeReactNativeBlockStyles(styles);
28
29
  return newStyles;
29
30
  }
@@ -0,0 +1,6 @@
1
+ function transformBlockProperties(properties) {
2
+ return properties;
3
+ }
4
+ export {
5
+ transformBlockProperties
6
+ };
@@ -1,19 +1,23 @@
1
1
  import { camelToKebabCase } from "../functions/camel-to-kebab-case.js";
2
- const convertStyleMaptoCSS = (style) => {
2
+ import { checkIsDefined } from "./nullable.js";
3
+ const convertStyleMapToCSSArray = (style) => {
3
4
  const cssProps = Object.entries(style).map(([key, value]) => {
4
5
  if (typeof value === "string") {
5
6
  return `${camelToKebabCase(key)}: ${value};`;
7
+ } else {
8
+ return void 0;
6
9
  }
7
10
  });
8
- return cssProps.join("\n");
11
+ return cssProps.filter(checkIsDefined);
9
12
  };
13
+ const convertStyleMapToCSS = (style) => convertStyleMapToCSSArray(style).join("\n");
10
14
  const createCssClass = ({
11
15
  mediaQuery,
12
16
  className,
13
17
  styles
14
18
  }) => {
15
19
  const cssClass = `.${className} {
16
- ${convertStyleMaptoCSS(styles)}
20
+ ${convertStyleMapToCSS(styles)}
17
21
  }`;
18
22
  if (mediaQuery) {
19
23
  return `${mediaQuery} {
@@ -24,5 +28,7 @@ const createCssClass = ({
24
28
  }
25
29
  };
26
30
  export {
31
+ convertStyleMapToCSS,
32
+ convertStyleMapToCSSArray,
27
33
  createCssClass
28
34
  };
@@ -16,6 +16,10 @@ var __spreadValues = (a, b) => {
16
16
  };
17
17
  import * as React from "react";
18
18
  import RenderBlocks from "../../components/render-blocks.jsx";
19
+ import { getSizesForBreakpoints } from "../../constants/device-sizes";
20
+ import RenderInlinedStyles from "../../components/render-inlined-styles.jsx";
21
+ import { TARGET } from "../../constants/target.js";
22
+ import { convertStyleMapToCSS } from "../../helpers/css";
19
23
  function Columns(props) {
20
24
  var _a;
21
25
  function getGutterSize() {
@@ -56,15 +60,74 @@ function Columns(props) {
56
60
  "--column-margin-left-tablet": maybeApplyForTablet(marginLeft)
57
61
  };
58
62
  }
63
+ function getWidthForBreakpointSize(size) {
64
+ const breakpointSizes = getSizesForBreakpoints(props.customBreakpoints || {});
65
+ return breakpointSizes[size].max;
66
+ }
67
+ function columnStyleObjects() {
68
+ return {
69
+ columns: {
70
+ small: {
71
+ flexDirection: "var(--flex-dir)",
72
+ alignItems: "stretch"
73
+ },
74
+ medium: {
75
+ flexDirection: "var(--flex-dir-tablet)",
76
+ alignItems: "stretch"
77
+ }
78
+ },
79
+ column: {
80
+ small: {
81
+ width: "var(--column-width) !important",
82
+ marginLeft: "var(--column-margin-left) !important"
83
+ },
84
+ medium: {
85
+ width: "var(--column-width-tablet) !important",
86
+ marginLeft: "var(--column-margin-left-tablet) !important"
87
+ }
88
+ }
89
+ };
90
+ }
91
+ function columnsStyles() {
92
+ return `
93
+ @media (max-width: ${getWidthForBreakpointSize("medium")}px) {
94
+ .${props.builderBlock.id}-breakpoints {
95
+ ${convertStyleMapToCSS(columnStyleObjects().columns.medium)}
96
+ }
97
+
98
+ .${props.builderBlock.id}-breakpoints > .builder-column {
99
+ ${convertStyleMapToCSS(columnStyleObjects().column.medium)}
100
+ }
101
+ }
102
+
103
+ @media (max-width: ${getWidthForBreakpointSize("small")}px) {
104
+ .${props.builderBlock.id}-breakpoints {
105
+ ${convertStyleMapToCSS(columnStyleObjects().columns.small)}
106
+ }
107
+
108
+ .${props.builderBlock.id}-breakpoints > .builder-column {
109
+ ${convertStyleMapToCSS(columnStyleObjects().column.small)}
110
+ }
111
+ },
112
+ `;
113
+ }
114
+ function reactNativeColumnsStyles() {
115
+ return columnStyleObjects.columns.small;
116
+ }
117
+ function reactNativeColumnStyles() {
118
+ return columnStyleObjects.column.small;
119
+ }
59
120
  return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("div", {
60
- className: "builder-columns div-48253552",
61
- style: columnsCssVars()
62
- }, (_a = props.columns) == null ? void 0 : _a.map((column, index) => /* @__PURE__ */ React.createElement("div", {
63
- className: "builder-column div-48253552-2",
64
- style: __spreadValues({
121
+ className: `builder-columns ${props.builderBlock.id}-breakpoints div-bda7d4e0`,
122
+ style: __spreadValues(__spreadValues({}, TARGET === "reactNative" ? reactNativeColumnsStyles() : {}), columnsCssVars())
123
+ }, TARGET !== "reactNative" ? /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(RenderInlinedStyles, {
124
+ styles: columnsStyles()
125
+ })) : null, (_a = props.columns) == null ? void 0 : _a.map((column, index) => /* @__PURE__ */ React.createElement("div", {
126
+ className: "builder-column div-bda7d4e0-2",
127
+ style: __spreadValues(__spreadValues({
65
128
  width: getColumnCssWidth(index),
66
129
  marginLeft: `${index === 0 ? 0 : getGutterSize()}px`
67
- }, columnCssVars()),
130
+ }, TARGET === "reactNative" ? reactNativeColumnStyles() : {}), columnCssVars()),
68
131
  key: index
69
132
  }, /* @__PURE__ */ React.createElement(RenderBlocks, {
70
133
  blocks: column.blocks,
@@ -73,19 +136,12 @@ function Columns(props) {
73
136
  styleProp: {
74
137
  flexGrow: "1"
75
138
  }
76
- })))), /* @__PURE__ */ React.createElement("style", null, `.div-48253552 {
139
+ })))), /* @__PURE__ */ React.createElement("style", null, `.div-bda7d4e0 {
77
140
  display: flex;
78
- align-items: stretch;
79
- line-height: normal; }@media (max-width: 991px) { .div-48253552 {
80
- flex-direction: var(--flex-dir-tablet); } }@media (max-width: 639px) { .div-48253552 {
81
- flex-direction: var(--flex-dir); } }.div-48253552-2 {
141
+ line-height: normal; }.div-bda7d4e0-2 {
82
142
  display: flex;
83
143
  flex-direction: column;
84
- align-items: stretch; }@media (max-width: 991px) { .div-48253552-2 {
85
- width: var(--column-width-tablet) !important;
86
- margin-left: var(--column-margin-left-tablet) !important; } }@media (max-width: 639px) { .div-48253552-2 {
87
- width: var(--column-width) !important;
88
- margin-left: var(--column-margin-left) !important; } }`));
144
+ align-items: stretch; }`));
89
145
  }
90
146
  export {
91
147
  Columns as default
@@ -20,9 +20,18 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
20
20
  import * as React from "react";
21
21
  function SectionComponent(props) {
22
22
  return /* @__PURE__ */ React.createElement("section", __spreadProps(__spreadValues({}, props.attributes), {
23
- style: props.maxWidth && typeof props.maxWidth === "number" ? {
24
- maxWidth: props.maxWidth
25
- } : void 0
23
+ style: {
24
+ width: "100%",
25
+ alignSelf: "stretch",
26
+ flexGrow: "1",
27
+ boxSizing: "border-box",
28
+ maxWidth: `${props.maxWidth && typeof props.maxWidth === "number" ? props.maxWidth : 1200}px`,
29
+ display: "flex",
30
+ flexDirection: "column",
31
+ alignItems: "stretch",
32
+ marginLeft: "auto",
33
+ marginRight: "auto"
34
+ }
26
35
  }), props.children);
27
36
  }
28
37
  export {
@@ -22,9 +22,18 @@ import { useState, useContext, useEffect } from "react";
22
22
  import RenderContent from "../../components/render-content/render-content.jsx";
23
23
  import BuilderContext from "../../context/builder.context.js";
24
24
  import { getContent } from "../../functions/get-content/index.js";
25
+ import { TARGET } from "../../constants/target";
25
26
  function Symbol(props) {
26
27
  var _a, _b, _c, _d, _e;
27
- const [className, setClassName] = useState(() => "builder-symbol");
28
+ function className() {
29
+ var _a2, _b2;
30
+ return [
31
+ ...TARGET === "vue2" || TARGET === "vue3" ? Object.keys(props.attributes.class) : [props.attributes.class],
32
+ "builder-symbol",
33
+ ((_a2 = props.symbol) == null ? void 0 : _a2.inline) ? "builder-inline-symbol" : void 0,
34
+ ((_b2 = props.symbol) == null ? void 0 : _b2.dynamic) || props.dynamic ? "builder-dynamic-symbol" : void 0
35
+ ].filter(Boolean).join(" ");
36
+ }
28
37
  const [fetchedContent, setFetchedContent] = useState(() => null);
29
38
  function contentToUse() {
30
39
  var _a2;
@@ -47,9 +56,9 @@ function Symbol(props) {
47
56
  }, [props.symbol, fetchedContent]);
48
57
  return /* @__PURE__ */ React.createElement("div", __spreadProps(__spreadValues({}, props.attributes), {
49
58
  dataSet: {
50
- class: className
59
+ class: className()
51
60
  },
52
- className
61
+ className: className()
53
62
  }), /* @__PURE__ */ React.createElement(RenderContent, {
54
63
  apiKey: builderContext.apiKey,
55
64
  context: builderContext.context,
@@ -87,10 +87,12 @@ function RenderBlock(props) {
87
87
  });
88
88
  }
89
89
  function attributes() {
90
- return __spreadValues(__spreadValues({}, getBlockProperties(useBlock())), TARGET === "reactNative" ? {
90
+ const blockProperties = getBlockProperties(useBlock());
91
+ return __spreadValues(__spreadValues({}, blockProperties), TARGET === "reactNative" ? {
91
92
  style: getReactNativeBlockStyles({
92
93
  block: useBlock(),
93
- context: props.context
94
+ context: props.context,
95
+ blockStyles: blockProperties.style
94
96
  })
95
97
  } : {});
96
98
  }
@@ -99,12 +101,14 @@ function RenderBlock(props) {
99
101
  return !((_a2 = component == null ? void 0 : component()) == null ? void 0 : _a2.noWrap);
100
102
  }
101
103
  function renderComponentProps() {
102
- var _a2;
104
+ var _a2, _b2, _c2, _d;
103
105
  return {
104
106
  blockChildren: useChildren(),
105
107
  componentRef: (_a2 = component == null ? void 0 : component()) == null ? void 0 : _a2.component,
106
- componentOptions: __spreadValues(__spreadValues({}, getBlockComponentOptions(useBlock())), shouldWrap() ? {} : {
108
+ componentOptions: __spreadProps(__spreadValues(__spreadValues({}, getBlockComponentOptions(useBlock())), shouldWrap() ? {} : {
107
109
  attributes: __spreadValues(__spreadValues({}, attributes()), actions())
110
+ }), {
111
+ customBreakpoints: (_d = (_c2 = (_b2 = childrenContext == null ? void 0 : childrenContext()) == null ? void 0 : _b2.content) == null ? void 0 : _c2.meta) == null ? void 0 : _d.breakpoints
108
112
  }),
109
113
  context: childrenContext()
110
114
  };
@@ -152,7 +156,8 @@ function RenderBlock(props) {
152
156
  }
153
157
  const styles = getReactNativeBlockStyles({
154
158
  block: useBlock(),
155
- context: props.context
159
+ context: props.context,
160
+ blockStyles: attributes().style
156
161
  });
157
162
  return extractTextStyles(styles);
158
163
  }
@@ -23,7 +23,7 @@ import { getDefaultRegisteredComponents } from "../../constants/builder-register
23
23
  import { TARGET } from "../../constants/target.js";
24
24
  import { evaluate } from "../../functions/evaluate.js";
25
25
  import { getContent } from "../../functions/get-content/index.js";
26
- import { getFetch } from "../../functions/get-fetch.js";
26
+ import { fetch } from "../../functions/get-fetch.js";
27
27
  import { isBrowser } from "../../functions/is-browser.js";
28
28
  import { isEditing } from "../../functions/is-editing.js";
29
29
  import { isPreviewing } from "../../functions/is-previewing.js";
@@ -43,18 +43,22 @@ function RenderContent(props) {
43
43
  var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
44
44
  const elementRef = useRef(null);
45
45
  const [forceReRenderCount, setForceReRenderCount] = useState(() => 0);
46
+ const [overrideContent, setOverrideContent] = useState(() => null);
46
47
  function useContent() {
47
- var _a2;
48
+ var _a2, _b2, _c2, _d2, _e2;
48
49
  if (!props.content && !overrideContent) {
49
50
  return void 0;
50
51
  }
51
52
  const mergedContent = __spreadProps(__spreadValues(__spreadValues({}, props.content), overrideContent), {
52
- data: __spreadValues(__spreadValues(__spreadValues({}, (_a2 = props.content) == null ? void 0 : _a2.data), props.data), overrideContent == null ? void 0 : overrideContent.data)
53
+ data: __spreadValues(__spreadValues(__spreadValues({}, (_a2 = props.content) == null ? void 0 : _a2.data), props.data), overrideContent == null ? void 0 : overrideContent.data),
54
+ meta: __spreadProps(__spreadValues(__spreadValues({}, (_b2 = props.content) == null ? void 0 : _b2.meta), overrideContent == null ? void 0 : overrideContent.meta), {
55
+ breakpoints: useBreakpoints || ((_c2 = overrideContent == null ? void 0 : overrideContent.meta) == null ? void 0 : _c2.breakpoints) || ((_e2 = (_d2 = props.content) == null ? void 0 : _d2.meta) == null ? void 0 : _e2.breakpoints)
56
+ })
53
57
  });
54
58
  return mergedContent;
55
59
  }
56
- const [overrideContent, setOverrideContent] = useState(() => null);
57
60
  const [update, setUpdate] = useState(() => 0);
61
+ const [useBreakpoints, setUseBreakpoints] = useState(() => null);
58
62
  function canTrackToUse() {
59
63
  return props.canTrack || true;
60
64
  }
@@ -80,9 +84,20 @@ function RenderContent(props) {
80
84
  return allComponents;
81
85
  }
82
86
  function processMessage(event) {
87
+ var _a2;
83
88
  const { data } = event;
84
89
  if (data) {
85
90
  switch (data.type) {
91
+ case "builder.configureSdk": {
92
+ const messageContent = data.data;
93
+ const { breakpoints, contentId } = messageContent;
94
+ if (!contentId || contentId !== ((_a2 = useContent == null ? void 0 : useContent()) == null ? void 0 : _a2.id)) {
95
+ return;
96
+ }
97
+ setUseBreakpoints(breakpoints);
98
+ setForceReRenderCount(forceReRenderCount + 1);
99
+ break;
100
+ }
86
101
  case "builder.contentUpdate": {
87
102
  const messageContent = data.data;
88
103
  const key = messageContent.key || messageContent.alias || messageContent.entry || messageContent.modelName;
@@ -135,7 +150,7 @@ function RenderContent(props) {
135
150
  }));
136
151
  }
137
152
  function handleRequest({ url, key }) {
138
- getFetch().then((fetch) => fetch(url)).then((response) => response.json()).then((json) => {
153
+ fetch(url).then((response) => response.json()).then((json) => {
139
154
  const newOverrideState = __spreadProps(__spreadValues({}, overrideState), {
140
155
  [key]: json
141
156
  });
@@ -17,12 +17,33 @@ var __spreadValues = (a, b) => {
17
17
  return a;
18
18
  };
19
19
  var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
20
+ import { TARGET } from "../constants/target.js";
21
+ import { convertStyleMapToCSSArray } from "../helpers/css.js";
22
+ import { transformBlockProperties } from "./transform-block-properties.js";
20
23
  function getBlockProperties(block) {
21
24
  var _a;
22
- return __spreadProps(__spreadValues({}, block.properties), {
25
+ const properties = __spreadProps(__spreadValues({}, block.properties), {
23
26
  "builder-id": block.id,
27
+ style: getStyleAttribute(block.style),
24
28
  class: [block.id, "builder-block", block.class, (_a = block.properties) == null ? void 0 : _a.class].filter(Boolean).join(" ")
25
29
  });
30
+ return transformBlockProperties(properties);
31
+ }
32
+ function getStyleAttribute(style) {
33
+ if (!style) {
34
+ return void 0;
35
+ }
36
+ switch (TARGET) {
37
+ case "svelte":
38
+ case "vue2":
39
+ case "vue3":
40
+ case "solid":
41
+ return convertStyleMapToCSSArray(style).join(" ");
42
+ case "qwik":
43
+ case "reactNative":
44
+ case "react":
45
+ return style;
46
+ }
26
47
  }
27
48
  export {
28
49
  getBlockProperties
@@ -0,0 +1,55 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
3
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
4
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
5
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
6
+ var __spreadValues = (a, b) => {
7
+ for (var prop in b || (b = {}))
8
+ if (__hasOwnProp.call(b, prop))
9
+ __defNormalProp(a, prop, b[prop]);
10
+ if (__getOwnPropSymbols)
11
+ for (var prop of __getOwnPropSymbols(b)) {
12
+ if (__propIsEnum.call(b, prop))
13
+ __defNormalProp(a, prop, b[prop]);
14
+ }
15
+ return a;
16
+ };
17
+ import { flatten } from "../../helpers/flatten.js";
18
+ import {
19
+ getBuilderSearchParamsFromWindow,
20
+ normalizeSearchParams
21
+ } from "../get-builder-search-params/index.js";
22
+ const generateContentUrl = (options) => {
23
+ const {
24
+ limit = 30,
25
+ userAttributes,
26
+ query,
27
+ noTraverse = false,
28
+ model,
29
+ apiKey,
30
+ includeRefs = true,
31
+ locale
32
+ } = options;
33
+ if (!apiKey) {
34
+ throw new Error("Missing API key");
35
+ }
36
+ const url = new URL(`https://cdn.builder.io/api/v2/content/${model}?apiKey=${apiKey}&limit=${limit}&noTraverse=${noTraverse}&includeRefs=${includeRefs}${locale ? `&locale=${locale}` : ""}`);
37
+ const queryOptions = __spreadValues(__spreadValues({}, getBuilderSearchParamsFromWindow()), normalizeSearchParams(options.options || {}));
38
+ const flattened = flatten(queryOptions);
39
+ for (const key in flattened) {
40
+ url.searchParams.set(key, String(flattened[key]));
41
+ }
42
+ if (userAttributes) {
43
+ url.searchParams.set("userAttributes", JSON.stringify(userAttributes));
44
+ }
45
+ if (query) {
46
+ const flattened2 = flatten({ query });
47
+ for (const key in flattened2) {
48
+ url.searchParams.set(key, JSON.stringify(flattened2[key]));
49
+ }
50
+ }
51
+ return url;
52
+ };
53
+ export {
54
+ generateContentUrl
55
+ };
@@ -1,4 +1,4 @@
1
- import { generateContentUrl } from ".";
1
+ import { generateContentUrl } from "./generate-content-url";
2
2
  const testKey = "YJIGb4i01jvw0SRdL5Bt";
3
3
  const testModel = "page";
4
4
  const testId = "c1b81bab59704599b997574eb0736def";
@@ -37,54 +37,19 @@ var __async = (__this, __arguments, generator) => {
37
37
  step((generator = generator.apply(__this, __arguments)).next());
38
38
  });
39
39
  };
40
- import { flatten } from "../../helpers/flatten.js";
41
- import {
42
- getBuilderSearchParamsFromWindow,
43
- normalizeSearchParams
44
- } from "../get-builder-search-params/index.js";
45
- import { getFetch } from "../get-fetch.js";
40
+ import { fetch } from "../get-fetch.js";
46
41
  import { handleABTesting } from "./ab-testing.js";
42
+ import { generateContentUrl } from "./generate-content-url.js";
47
43
  function getContent(options) {
48
44
  return __async(this, null, function* () {
49
45
  return (yield getAllContent(__spreadProps(__spreadValues({}, options), { limit: 1 }))).results[0] || null;
50
46
  });
51
47
  }
52
- const generateContentUrl = (options) => {
53
- const {
54
- limit = 30,
55
- userAttributes,
56
- query,
57
- noTraverse = false,
58
- model,
59
- apiKey,
60
- includeRefs = true,
61
- locale
62
- } = options;
63
- if (!apiKey) {
64
- throw new Error("Missing API key");
65
- }
66
- const url = new URL(`https://cdn.builder.io/api/v2/content/${model}?apiKey=${apiKey}&limit=${limit}&noTraverse=${noTraverse}&includeRefs=${includeRefs}${locale ? `&locale=${locale}` : ""}`);
67
- const queryOptions = __spreadValues(__spreadValues({}, getBuilderSearchParamsFromWindow()), normalizeSearchParams(options.options || {}));
68
- const flattened = flatten(queryOptions);
69
- for (const key in flattened) {
70
- url.searchParams.set(key, String(flattened[key]));
71
- }
72
- if (userAttributes) {
73
- url.searchParams.set("userAttributes", JSON.stringify(userAttributes));
74
- }
75
- if (query) {
76
- const flattened2 = flatten({ query });
77
- for (const key in flattened2) {
78
- url.searchParams.set(key, JSON.stringify(flattened2[key]));
79
- }
80
- }
81
- return url;
82
- };
83
48
  function getAllContent(options) {
84
49
  return __async(this, null, function* () {
85
50
  const url = generateContentUrl(options);
86
- const fetch = yield getFetch();
87
- const content = yield fetch(url.href).then((res) => res.json());
51
+ const res = yield fetch(url.href);
52
+ const content = yield res.json();
88
53
  const canTrack = options.canTrack !== false;
89
54
  if (canTrack && Array.isArray(content.results)) {
90
55
  for (const item of content.results) {
@@ -95,7 +60,6 @@ function getAllContent(options) {
95
60
  });
96
61
  }
97
62
  export {
98
- generateContentUrl,
99
63
  getAllContent,
100
64
  getContent
101
65
  };
@@ -1,34 +1,14 @@
1
- var __async = (__this, __arguments, generator) => {
2
- return new Promise((resolve, reject) => {
3
- var fulfilled = (value) => {
4
- try {
5
- step(generator.next(value));
6
- } catch (e) {
7
- reject(e);
8
- }
9
- };
10
- var rejected = (value) => {
11
- try {
12
- step(generator.throw(value));
13
- } catch (e) {
14
- reject(e);
15
- }
16
- };
17
- var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
18
- step((generator = generator.apply(__this, __arguments)).next());
19
- });
20
- };
21
1
  import { getGlobalThis } from "./get-global-this.js";
22
2
  function getFetch() {
23
- return __async(this, null, function* () {
24
- const globalFetch = getGlobalThis().fetch;
25
- if (typeof globalFetch === "undefined" && typeof global !== "undefined") {
26
- const nodeFetch = import("node-fetch").then((d) => d.default);
27
- return nodeFetch.default || nodeFetch;
28
- }
29
- return globalFetch.default || globalFetch;
30
- });
3
+ const globalFetch = getGlobalThis().fetch;
4
+ if (typeof globalFetch === "undefined") {
5
+ console.warn(`Builder SDK could not find a global fetch function. Make sure you have a polyfill for fetch in your project.
6
+ For more information, read https://github.com/BuilderIO/this-package-uses-fetch`);
7
+ throw new Error("Builder SDK could not find a global `fetch` function");
8
+ }
9
+ return globalFetch;
31
10
  }
11
+ const fetch = getFetch();
32
12
  export {
33
- getFetch
13
+ fetch
34
14
  };
@@ -11,7 +11,7 @@ function getGlobalThis() {
11
11
  if (typeof self !== "undefined") {
12
12
  return self;
13
13
  }
14
- return null;
14
+ return globalThis;
15
15
  }
16
16
  export {
17
17
  getGlobalThis
@@ -17,13 +17,14 @@ var __spreadValues = (a, b) => {
17
17
  import { sanitizeReactNativeBlockStyles } from "./sanitize-react-native-block-styles.js";
18
18
  function getReactNativeBlockStyles({
19
19
  block,
20
- context
20
+ context,
21
+ blockStyles
21
22
  }) {
22
23
  const responsiveStyles = block.responsiveStyles;
23
24
  if (!responsiveStyles) {
24
25
  return {};
25
26
  }
26
- const styles = __spreadValues(__spreadValues(__spreadValues(__spreadValues({}, context.inheritedStyles), responsiveStyles.large || {}), responsiveStyles.medium || {}), responsiveStyles.small || {});
27
+ const styles = __spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues({}, context.inheritedStyles), responsiveStyles.large || {}), responsiveStyles.medium || {}), responsiveStyles.small || {}), blockStyles);
27
28
  const newStyles = sanitizeReactNativeBlockStyles(styles);
28
29
  return newStyles;
29
30
  }
@@ -0,0 +1,6 @@
1
+ function transformBlockProperties(properties) {
2
+ return properties;
3
+ }
4
+ export {
5
+ transformBlockProperties
6
+ };
@@ -1,19 +1,23 @@
1
1
  import { camelToKebabCase } from "../functions/camel-to-kebab-case.js";
2
- const convertStyleMaptoCSS = (style) => {
2
+ import { checkIsDefined } from "./nullable.js";
3
+ const convertStyleMapToCSSArray = (style) => {
3
4
  const cssProps = Object.entries(style).map(([key, value]) => {
4
5
  if (typeof value === "string") {
5
6
  return `${camelToKebabCase(key)}: ${value};`;
7
+ } else {
8
+ return void 0;
6
9
  }
7
10
  });
8
- return cssProps.join("\n");
11
+ return cssProps.filter(checkIsDefined);
9
12
  };
13
+ const convertStyleMapToCSS = (style) => convertStyleMapToCSSArray(style).join("\n");
10
14
  const createCssClass = ({
11
15
  mediaQuery,
12
16
  className,
13
17
  styles
14
18
  }) => {
15
19
  const cssClass = `.${className} {
16
- ${convertStyleMaptoCSS(styles)}
20
+ ${convertStyleMapToCSS(styles)}
17
21
  }`;
18
22
  if (mediaQuery) {
19
23
  return `${mediaQuery} {
@@ -24,5 +28,7 @@ const createCssClass = ({
24
28
  }
25
29
  };
26
30
  export {
31
+ convertStyleMapToCSS,
32
+ convertStyleMapToCSSArray,
27
33
  createCssClass
28
34
  };