@builder.io/sdk-react-native 0.0.13 → 0.0.15

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,12 +1,13 @@
1
1
  {
2
2
  "name": "@builder.io/sdk-react-native",
3
3
  "description": "Builder.io SDK for React Native",
4
- "version": "0.0.13",
4
+ "version": "0.0.15",
5
5
  "main": "src/index.js",
6
6
  "files": [
7
7
  "src"
8
8
  ],
9
9
  "scripts": {
10
+ "build": "echo 'no need to build react-native SDK'",
10
11
  "release:patch": "npm version patch --no-git-tag-version && npm publish --access public",
11
12
  "release:dev": "npm version prerelease --no-git-tag-version && npm publish --tag dev --access public"
12
13
  },
@@ -1,6 +1,10 @@
1
1
  import * as React from "react";
2
2
  import { View, StyleSheet } from "react-native";
3
3
  import RenderBlocks from "../../components/render-blocks.js";
4
+ import { getSizesForBreakpoints } from "../../constants/device-sizes";
5
+ import RenderInlinedStyles from "../../components/render-inlined-styles.js";
6
+ import { TARGET } from "../../constants/target.js";
7
+ import { convertStyleMapToCSS } from "../../helpers/css";
4
8
  function Columns(props) {
5
9
  var _a;
6
10
  function getGutterSize() {
@@ -41,9 +45,68 @@ function Columns(props) {
41
45
  "--column-margin-left-tablet": maybeApplyForTablet(marginLeft)
42
46
  };
43
47
  }
48
+ function getWidthForBreakpointSize(size) {
49
+ const breakpointSizes = getSizesForBreakpoints(props.customBreakpoints || {});
50
+ return breakpointSizes[size].max;
51
+ }
52
+ function columnStyleObjects() {
53
+ return {
54
+ columns: {
55
+ small: {
56
+ flexDirection: "var(--flex-dir)",
57
+ alignItems: "stretch"
58
+ },
59
+ medium: {
60
+ flexDirection: "var(--flex-dir-tablet)",
61
+ alignItems: "stretch"
62
+ }
63
+ },
64
+ column: {
65
+ small: {
66
+ width: "var(--column-width) !important",
67
+ marginLeft: "var(--column-margin-left) !important"
68
+ },
69
+ medium: {
70
+ width: "var(--column-width-tablet) !important",
71
+ marginLeft: "var(--column-margin-left-tablet) !important"
72
+ }
73
+ }
74
+ };
75
+ }
76
+ function columnsStyles() {
77
+ return `
78
+ @media (max-width: ${getWidthForBreakpointSize("medium")}px) {
79
+ .${props.builderBlock.id}-breakpoints {
80
+ ${convertStyleMapToCSS(columnStyleObjects().columns.medium)}
81
+ }
82
+
83
+ .${props.builderBlock.id}-breakpoints > .builder-column {
84
+ ${convertStyleMapToCSS(columnStyleObjects().column.medium)}
85
+ }
86
+ }
87
+
88
+ @media (max-width: ${getWidthForBreakpointSize("small")}px) {
89
+ .${props.builderBlock.id}-breakpoints {
90
+ ${convertStyleMapToCSS(columnStyleObjects().columns.small)}
91
+ }
92
+
93
+ .${props.builderBlock.id}-breakpoints > .builder-column {
94
+ ${convertStyleMapToCSS(columnStyleObjects().column.small)}
95
+ }
96
+ },
97
+ `;
98
+ }
99
+ function reactNativeColumnsStyles() {
100
+ return columnStyleObjects.columns.small;
101
+ }
102
+ function reactNativeColumnStyles() {
103
+ return columnStyleObjects.column.small;
104
+ }
44
105
  return /* @__PURE__ */ React.createElement(View, {
45
106
  style: styles.view1
46
- }, (_a = props.columns) == null ? void 0 : _a.map((column, index) => /* @__PURE__ */ React.createElement(View, {
107
+ }, TARGET !== "reactNative" ? /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(RenderInlinedStyles, {
108
+ styles: columnsStyles()
109
+ })) : null, (_a = props.columns) == null ? void 0 : _a.map((column, index) => /* @__PURE__ */ React.createElement(View, {
47
110
  style: styles.view2,
48
111
  key: index
49
112
  }, /* @__PURE__ */ React.createElement(RenderBlocks, {
@@ -56,7 +119,7 @@ function Columns(props) {
56
119
  }))));
57
120
  }
58
121
  const styles = StyleSheet.create({
59
- view1: { display: "flex", alignItems: "stretch" },
122
+ view1: { display: "flex" },
60
123
  view2: { display: "flex", flexDirection: "column", alignItems: "stretch" }
61
124
  });
62
125
  export {
@@ -22,9 +22,18 @@ import * as React from "react";
22
22
  import { View } from "react-native";
23
23
  function SectionComponent(props) {
24
24
  return /* @__PURE__ */ React.createElement(View, __spreadProps(__spreadValues({}, props.attributes), {
25
- style: props.maxWidth && typeof props.maxWidth === "number" ? {
26
- maxWidth: props.maxWidth
27
- } : void 0
25
+ style: {
26
+ width: "100%",
27
+ alignSelf: "stretch",
28
+ flexGrow: "1",
29
+ boxSizing: "border-box",
30
+ maxWidth: `${props.maxWidth && typeof props.maxWidth === "number" ? props.maxWidth : 1200}px`,
31
+ display: "flex",
32
+ flexDirection: "column",
33
+ alignItems: "stretch",
34
+ marginLeft: "auto",
35
+ marginRight: "auto"
36
+ }
28
37
  }), /* @__PURE__ */ React.createElement(BaseText, null, props.children));
29
38
  }
30
39
  export {
@@ -23,9 +23,18 @@ import { useState, useContext, useEffect } from "react";
23
23
  import RenderContent from "../../components/render-content/render-content.js";
24
24
  import BuilderContext from "../../context/builder.context.js";
25
25
  import { getContent } from "../../functions/get-content/index.js";
26
+ import { TARGET } from "../../constants/target";
26
27
  function Symbol(props) {
27
28
  var _a, _b, _c, _d, _e;
28
- const [className, setClassName] = useState(() => "builder-symbol");
29
+ function className() {
30
+ var _a2, _b2;
31
+ return [
32
+ ...TARGET === "vue2" || TARGET === "vue3" ? Object.keys(props.attributes.class) : [props.attributes.class],
33
+ "builder-symbol",
34
+ ((_a2 = props.symbol) == null ? void 0 : _a2.inline) ? "builder-inline-symbol" : void 0,
35
+ ((_b2 = props.symbol) == null ? void 0 : _b2.dynamic) || props.dynamic ? "builder-dynamic-symbol" : void 0
36
+ ].filter(Boolean).join(" ");
37
+ }
29
38
  const [fetchedContent, setFetchedContent] = useState(() => null);
30
39
  function contentToUse() {
31
40
  var _a2;
@@ -48,7 +57,7 @@ function Symbol(props) {
48
57
  }, [props.symbol, fetchedContent]);
49
58
  return /* @__PURE__ */ React.createElement(View, __spreadProps(__spreadValues({}, props.attributes), {
50
59
  dataSet: {
51
- class: className
60
+ class: className()
52
61
  }
53
62
  }), /* @__PURE__ */ React.createElement(RenderContent, {
54
63
  apiKey: builderContext.apiKey,
@@ -80,15 +80,20 @@ function RenderBlock(props) {
80
80
  shouldEvaluateBindings: true
81
81
  });
82
82
  }
83
- function attributes() {
84
- return __spreadValues(__spreadValues(__spreadValues({}, getBlockProperties(useBlock())), getBlockActions({
83
+ function actions() {
84
+ return getBlockActions({
85
85
  block: useBlock(),
86
86
  state: props.context.state,
87
87
  context: props.context.context
88
- })), TARGET === "reactNative" ? {
88
+ });
89
+ }
90
+ function attributes() {
91
+ const blockProperties = getBlockProperties(useBlock());
92
+ return __spreadValues(__spreadValues({}, blockProperties), TARGET === "reactNative" ? {
89
93
  style: getReactNativeBlockStyles({
90
94
  block: useBlock(),
91
- context: props.context
95
+ context: props.context,
96
+ blockStyles: blockProperties.style
92
97
  })
93
98
  } : {});
94
99
  }
@@ -97,12 +102,14 @@ function RenderBlock(props) {
97
102
  return !((_a2 = component == null ? void 0 : component()) == null ? void 0 : _a2.noWrap);
98
103
  }
99
104
  function renderComponentProps() {
100
- var _a2;
105
+ var _a2, _b2, _c2, _d;
101
106
  return {
102
107
  blockChildren: useChildren(),
103
108
  componentRef: (_a2 = component == null ? void 0 : component()) == null ? void 0 : _a2.component,
104
- componentOptions: __spreadValues(__spreadValues({}, getBlockComponentOptions(useBlock())), shouldWrap() ? {} : {
105
- attributes: attributes()
109
+ componentOptions: __spreadProps(__spreadValues(__spreadValues({}, getBlockComponentOptions(useBlock())), shouldWrap() ? {} : {
110
+ attributes: __spreadValues(__spreadValues({}, attributes()), actions())
111
+ }), {
112
+ customBreakpoints: (_d = (_c2 = (_b2 = childrenContext == null ? void 0 : childrenContext()) == null ? void 0 : _b2.content) == null ? void 0 : _c2.meta) == null ? void 0 : _d.breakpoints
106
113
  }),
107
114
  context: childrenContext()
108
115
  };
@@ -150,7 +157,8 @@ function RenderBlock(props) {
150
157
  }
151
158
  const styles = getReactNativeBlockStyles({
152
159
  block: useBlock(),
153
- context: props.context
160
+ context: props.context,
161
+ blockStyles: attributes().style
154
162
  });
155
163
  return extractTextStyles(styles);
156
164
  }
@@ -175,11 +183,11 @@ function RenderBlock(props) {
175
183
  }
176
184
  const [componentInfo, setComponentInfo] = useState(() => null);
177
185
  const RenderComponentTagRef = renderComponentTag();
178
- return /* @__PURE__ */ React.createElement(React.Fragment, null, shouldWrap() ? /* @__PURE__ */ React.createElement(React.Fragment, null, isEmptyHtmlElement(tag()) ? /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(View, __spreadValues({}, attributes()))) : null, !isEmptyHtmlElement(tag()) && repeatItemData() ? /* @__PURE__ */ React.createElement(React.Fragment, null, (_a = repeatItemData()) == null ? void 0 : _a.map((data, index) => /* @__PURE__ */ React.createElement(RenderRepeatedBlock, {
186
+ return /* @__PURE__ */ React.createElement(React.Fragment, null, shouldWrap() ? /* @__PURE__ */ React.createElement(React.Fragment, null, isEmptyHtmlElement(tag()) ? /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(View, __spreadValues(__spreadValues({}, attributes()), actions()))) : null, !isEmptyHtmlElement(tag()) && repeatItemData() ? /* @__PURE__ */ React.createElement(React.Fragment, null, (_a = repeatItemData()) == null ? void 0 : _a.map((data, index) => /* @__PURE__ */ React.createElement(RenderRepeatedBlock, {
179
187
  key: index,
180
188
  repeatContext: data.context,
181
189
  block: data.block
182
- }))) : null, !isEmptyHtmlElement(tag()) && !repeatItemData() ? /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(View, __spreadValues({}, attributes()), /* @__PURE__ */ React.createElement(RenderComponentTagRef, __spreadValues({}, renderComponentProps())), (_b = childrenWithoutParentComponent()) == null ? void 0 : _b.map((child) => /* @__PURE__ */ React.createElement(RenderBlock, {
190
+ }))) : null, !isEmptyHtmlElement(tag()) && !repeatItemData() ? /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(View, __spreadValues(__spreadValues({}, attributes()), actions()), /* @__PURE__ */ React.createElement(RenderComponentTagRef, __spreadValues({}, renderComponentProps())), (_b = childrenWithoutParentComponent()) == null ? void 0 : _b.map((child) => /* @__PURE__ */ React.createElement(RenderBlock, {
183
191
  key: "render-block-" + child.id,
184
192
  block: child,
185
193
  context: childrenContext()
@@ -22,7 +22,6 @@ import { View } from "react-native";
22
22
  import { useState, useRef, useEffect } from "react";
23
23
  import { getDefaultRegisteredComponents } from "../../constants/builder-registered-components.js";
24
24
  import { TARGET } from "../../constants/target.js";
25
- import BuilderContext from "../../context/builder.context.js";
26
25
  import { evaluate } from "../../functions/evaluate.js";
27
26
  import { getContent } from "../../functions/get-content/index.js";
28
27
  import { getFetch } from "../../functions/get-fetch.js";
@@ -36,6 +35,7 @@ import {
36
35
  import { _track } from "../../functions/track.js";
37
36
  import RenderBlocks from "../render-blocks.js";
38
37
  import RenderContentStyles from "./components/render-styles.js";
38
+ import BuilderContext from "../../context/builder.context.js";
39
39
  import {
40
40
  registerInsertMenu,
41
41
  setupBrowserForEditing
@@ -44,25 +44,31 @@ function RenderContent(props) {
44
44
  var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
45
45
  const elementRef = useRef(null);
46
46
  const [forceReRenderCount, setForceReRenderCount] = useState(() => 0);
47
+ const [overrideContent, setOverrideContent] = useState(() => null);
47
48
  function useContent() {
48
- var _a2;
49
+ var _a2, _b2, _c2, _d2, _e2;
49
50
  if (!props.content && !overrideContent) {
50
51
  return void 0;
51
52
  }
52
53
  const mergedContent = __spreadProps(__spreadValues(__spreadValues({}, props.content), overrideContent), {
53
- data: __spreadValues(__spreadValues(__spreadValues({}, (_a2 = props.content) == null ? void 0 : _a2.data), props.data), overrideContent == null ? void 0 : overrideContent.data)
54
+ data: __spreadValues(__spreadValues(__spreadValues({}, (_a2 = props.content) == null ? void 0 : _a2.data), props.data), overrideContent == null ? void 0 : overrideContent.data),
55
+ meta: __spreadProps(__spreadValues(__spreadValues({}, (_b2 = props.content) == null ? void 0 : _b2.meta), overrideContent == null ? void 0 : overrideContent.meta), {
56
+ 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)
57
+ })
54
58
  });
55
59
  return mergedContent;
56
60
  }
57
- const [overrideContent, setOverrideContent] = useState(() => null);
58
61
  const [update, setUpdate] = useState(() => 0);
62
+ const [useBreakpoints, setUseBreakpoints] = useState(() => null);
59
63
  function canTrackToUse() {
60
64
  return props.canTrack || true;
61
65
  }
62
66
  const [overrideState, setOverrideState] = useState(() => ({}));
63
67
  function contentState() {
64
68
  var _a2, _b2;
65
- return __spreadValues(__spreadValues(__spreadValues({}, (_b2 = (_a2 = props.content) == null ? void 0 : _a2.data) == null ? void 0 : _b2.state), props.data), overrideState);
69
+ return __spreadValues(__spreadValues(__spreadValues(__spreadValues({}, (_b2 = (_a2 = props.content) == null ? void 0 : _a2.data) == null ? void 0 : _b2.state), props.data), props.locale ? {
70
+ locale: props.locale
71
+ } : {}), overrideState);
66
72
  }
67
73
  function contextContext() {
68
74
  return props.context || {};
@@ -79,9 +85,20 @@ function RenderContent(props) {
79
85
  return allComponents;
80
86
  }
81
87
  function processMessage(event) {
88
+ var _a2;
82
89
  const { data } = event;
83
90
  if (data) {
84
91
  switch (data.type) {
92
+ case "builder.configureSdk": {
93
+ const messageContent = data.data;
94
+ const { breakpoints, contentId } = messageContent;
95
+ if (!contentId || contentId !== ((_a2 = useContent == null ? void 0 : useContent()) == null ? void 0 : _a2.id)) {
96
+ return;
97
+ }
98
+ setUseBreakpoints(breakpoints);
99
+ setForceReRenderCount(forceReRenderCount + 1);
100
+ break;
101
+ }
85
102
  case "builder.contentUpdate": {
86
103
  const messageContent = data.data;
87
104
  const key = messageContent.key || messageContent.alias || messageContent.entry || messageContent.modelName;
@@ -174,11 +191,18 @@ function RenderContent(props) {
174
191
  }
175
192
  useEffect(() => {
176
193
  var _a2, _b2;
194
+ if (!props.apiKey) {
195
+ console.error("[Builder.io]: No API key provided to `RenderContent` component. This can cause issues. Please provide an API key using the `apiKey` prop.");
196
+ }
177
197
  if (isBrowser()) {
178
198
  if (isEditing()) {
179
199
  setForceReRenderCount(forceReRenderCount + 1);
180
200
  registerInsertMenu();
181
- setupBrowserForEditing();
201
+ setupBrowserForEditing(__spreadValues(__spreadValues({}, props.locale ? {
202
+ locale: props.locale
203
+ } : {}), props.includeRefs ? {
204
+ includeRefs: props.includeRefs
205
+ } : {}));
182
206
  Object.values(allRegisteredComponents()).forEach((registeredComponent) => {
183
207
  var _a3;
184
208
  const message = createRegisterComponentMessage(registeredComponent);
@@ -221,7 +245,7 @@ function RenderContent(props) {
221
245
  }, []);
222
246
  useEffect(() => {
223
247
  evaluateJsCode();
224
- }, [(_b = (_a = useContent == null ? void 0 : useContent()) == null ? void 0 : _a.data) == null ? void 0 : _b.jsCode]);
248
+ }, [(_b = (_a = useContent == null ? void 0 : useContent()) == null ? void 0 : _a.data) == null ? void 0 : _b.jsCode, contentState()]);
225
249
  useEffect(() => {
226
250
  runHttpRequests();
227
251
  }, [(_d = (_c = useContent == null ? void 0 : useContent()) == null ? void 0 : _c.data) == null ? void 0 : _d.httpRequests]);
@@ -4,7 +4,8 @@ function evaluate({
4
4
  code,
5
5
  context,
6
6
  state,
7
- event
7
+ event,
8
+ isExpression = true
8
9
  }) {
9
10
  if (code === "") {
10
11
  console.warn("Skipping evaluation of empty code block.");
@@ -15,12 +16,12 @@ function evaluate({
15
16
  isBrowser: isBrowser(),
16
17
  isServer: !isBrowser()
17
18
  };
18
- const useReturn = !(code.includes(";") || code.includes(" return ") || code.trim().startsWith("return "));
19
+ const useReturn = isExpression && !(code.includes(";") || code.includes(" return ") || code.trim().startsWith("return "));
19
20
  const useCode = useReturn ? `return (${code});` : code;
20
21
  try {
21
22
  return new Function("builder", "Builder", "state", "context", "event", useCode)(builder, builder, state, context, event);
22
23
  } catch (e) {
23
- console.warn("Builder custom code error: \n While Evaluating: \n ", useCode, "\n", e.message || e);
24
+ console.warn("Builder custom code error: \n While Evaluating: \n ", useCode, "\n", e);
24
25
  }
25
26
  }
26
27
  export {
@@ -1,12 +1,11 @@
1
1
  import { evaluate } from "./evaluate.js";
2
- function crateEventHandler(value, options) {
3
- return (event) => evaluate({
4
- code: value,
5
- context: options.context,
6
- state: options.state,
7
- event
8
- });
9
- }
2
+ const createEventHandler = (value, options) => (event) => evaluate({
3
+ code: value,
4
+ context: options.context,
5
+ state: options.state,
6
+ event,
7
+ isExpression: false
8
+ });
10
9
  export {
11
- crateEventHandler
10
+ createEventHandler
12
11
  };
@@ -1,5 +1,5 @@
1
1
  import { getEventHandlerName } from "./event-handler-name.js";
2
- import { crateEventHandler } from "./get-block-actions-handler.js";
2
+ import { createEventHandler } from "./get-block-actions-handler.js";
3
3
  function getBlockActions(options) {
4
4
  var _a;
5
5
  const obj = {};
@@ -9,7 +9,7 @@ function getBlockActions(options) {
9
9
  continue;
10
10
  }
11
11
  const value = optionActions[key];
12
- obj[getEventHandlerName(key)] = crateEventHandler(value, options);
12
+ obj[getEventHandlerName(key)] = createEventHandler(value, options);
13
13
  }
14
14
  return obj;
15
15
  }
@@ -17,24 +17,33 @@ var __spreadValues = (a, b) => {
17
17
  return a;
18
18
  };
19
19
  var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
20
- import { isEditing } from "./is-editing.js";
21
- import { findDOMNode } from "react-dom";
20
+ import { TARGET } from "../constants/target.js";
21
+ import { convertStyleMapToCSSArray } from "../helpers/css.js";
22
+ import { transformBlockProperties } from "./transform-block-properties.js";
22
23
  function getBlockProperties(block) {
23
- return __spreadProps(__spreadValues({}, block.properties), {
24
- ref: (ref) => {
25
- if (isEditing()) {
26
- const el = findDOMNode(ref);
27
- if (el) {
28
- el.setAttribute("builder-id", block.id);
29
- el.classList.add(block.id);
30
- }
31
- }
32
- },
33
- dataSet: {
34
- "builder-id": block.id,
35
- class: [block.id, "builder-block", block.class].filter(Boolean).join(" ")
36
- }
24
+ var _a;
25
+ const properties = __spreadProps(__spreadValues({}, block.properties), {
26
+ "builder-id": block.id,
27
+ style: getStyleAttribute(block.style),
28
+ class: [block.id, "builder-block", block.class, (_a = block.properties) == null ? void 0 : _a.class].filter(Boolean).join(" ")
37
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
+ }
38
47
  }
39
48
  export {
40
49
  getBlockProperties
@@ -1,5 +1,6 @@
1
1
  import { isBrowser } from "../is-browser.js";
2
2
  const BUILDER_SEARCHPARAMS_PREFIX = "builder.";
3
+ const BUILDER_OPTIONS_PREFIX = "options.";
3
4
  const convertSearchParamsToQueryObject = (searchParams) => {
4
5
  const options = {};
5
6
  searchParams.forEach((value, key) => {
@@ -15,7 +16,7 @@ const getBuilderSearchParams = (_options) => {
15
16
  const newOptions = {};
16
17
  Object.keys(options).forEach((key) => {
17
18
  if (key.startsWith(BUILDER_SEARCHPARAMS_PREFIX)) {
18
- const trimmedKey = key.replace(BUILDER_SEARCHPARAMS_PREFIX, "");
19
+ const trimmedKey = key.replace(BUILDER_SEARCHPARAMS_PREFIX, "").replace(BUILDER_OPTIONS_PREFIX, "");
19
20
  newOptions[trimmedKey] = options[key];
20
21
  }
21
22
  });
@@ -57,12 +57,13 @@ const generateContentUrl = (options) => {
57
57
  noTraverse = false,
58
58
  model,
59
59
  apiKey,
60
- includeRefs = true
60
+ includeRefs = true,
61
+ locale
61
62
  } = options;
62
63
  if (!apiKey) {
63
64
  throw new Error("Missing API key");
64
65
  }
65
- const url = new URL(`https://cdn.builder.io/api/v2/content/${model}?apiKey=${apiKey}&limit=${limit}&noTraverse=${noTraverse}&includeRefs=${includeRefs}`);
66
+ const url = new URL(`https://cdn.builder.io/api/v2/content/${model}?apiKey=${apiKey}&limit=${limit}&noTraverse=${noTraverse}&includeRefs=${includeRefs}${locale ? `&locale=${locale}` : ""}`);
66
67
  const queryOptions = __spreadValues(__spreadValues({}, getBuilderSearchParamsFromWindow()), normalizeSearchParams(options.options || {}));
67
68
  const flattened = flatten(queryOptions);
68
69
  for (const key in flattened) {
@@ -85,7 +86,7 @@ function getAllContent(options) {
85
86
  const fetch = yield getFetch();
86
87
  const content = yield fetch(url.href).then((res) => res.json());
87
88
  const canTrack = options.canTrack !== false;
88
- if (canTrack) {
89
+ if (canTrack && Array.isArray(content.results)) {
89
90
  for (const item of content.results) {
90
91
  yield handleABTesting({ item, canTrack });
91
92
  }
@@ -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
  }
@@ -90,6 +90,10 @@ const createEvent = (_a) => __async(void 0, null, function* () {
90
90
  });
91
91
  function _track(eventProps) {
92
92
  return __async(this, null, function* () {
93
+ if (!eventProps.apiKey) {
94
+ console.error("[Builder.io]: Missing API key for track call. Please provide your API key.");
95
+ return;
96
+ }
93
97
  if (!eventProps.canTrack) {
94
98
  return;
95
99
  }
@@ -0,0 +1,17 @@
1
+ import { isEditing } from "./is-editing.js";
2
+ import { findDOMNode } from "react-dom";
3
+ function transformBlockProperties(block) {
4
+ block.ref = (ref) => {
5
+ if (isEditing()) {
6
+ const el = findDOMNode(ref);
7
+ if (el) {
8
+ el.setAttribute("builder-id", block.id);
9
+ el.classList.add(block.id);
10
+ }
11
+ }
12
+ };
13
+ return block;
14
+ }
15
+ export {
16
+ transformBlockProperties
17
+ };
@@ -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
  };
@@ -20,8 +20,8 @@ const registerInsertMenu = () => {
20
20
  });
21
21
  };
22
22
  let isSetupForEditing = false;
23
- const setupBrowserForEditing = () => {
24
- var _a;
23
+ const setupBrowserForEditing = (options = {}) => {
24
+ var _a, _b;
25
25
  if (isSetupForEditing) {
26
26
  return;
27
27
  }
@@ -36,8 +36,14 @@ const setupBrowserForEditing = () => {
36
36
  supportsCustomBreakpoints: true
37
37
  }
38
38
  }, "*");
39
+ (_b = window.parent) == null ? void 0 : _b.postMessage({
40
+ type: "builder.updateContent",
41
+ data: {
42
+ options
43
+ }
44
+ }, "*");
39
45
  window.addEventListener("message", ({ data }) => {
40
- var _a2, _b;
46
+ var _a2, _b2;
41
47
  if (!(data == null ? void 0 : data.type)) {
42
48
  return;
43
49
  }
@@ -69,7 +75,7 @@ const setupBrowserForEditing = () => {
69
75
  }, "*");
70
76
  }).catch(console.error);
71
77
  } else {
72
- (_b = window.parent) == null ? void 0 : _b.postMessage({
78
+ (_b2 = window.parent) == null ? void 0 : _b2.postMessage({
73
79
  type: "builder.evaluateResult",
74
80
  data: { result, id }
75
81
  }, "*");
@@ -1,10 +0,0 @@
1
- function markMutable(value) {
2
- return value;
3
- }
4
- function markPropsMutable(props) {
5
- return props;
6
- }
7
- export {
8
- markMutable,
9
- markPropsMutable
10
- };