@builder.io/sdk-react-native 0.0.11 → 0.0.12

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,7 +1,7 @@
1
1
  {
2
2
  "name": "@builder.io/sdk-react-native",
3
3
  "description": "Builder.io SDK for React Native",
4
- "version": "0.0.11",
4
+ "version": "0.0.12",
5
5
  "main": "src/index.js",
6
6
  "files": [
7
7
  "src"
@@ -12,6 +12,7 @@
12
12
  },
13
13
  "dependencies": {
14
14
  "@react-native-async-storage/async-storage": "^1.17.10",
15
+ "node-fetch": "^2.6.1",
15
16
  "react-native-render-html": "^6.3.4",
16
17
  "react-native-storage": "^1.0.1",
17
18
  "react-native-video": "^5.1.1"
@@ -21,8 +21,9 @@ import BaseText from "../BaseText";
21
21
  import * as React from "react";
22
22
  import { View, StyleSheet } from "react-native";
23
23
  function Button(props) {
24
- return /* @__PURE__ */ React.createElement(React.Fragment, null, props.link ? /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(View, __spreadProps(__spreadValues({}, props.attributes), {
25
- role: "button",
24
+ return /* @__PURE__ */ React.createElement(React.Fragment, null, props.link ? /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(View, __spreadProps(__spreadValues({
25
+ role: "button"
26
+ }, props.attributes), {
26
27
  href: props.link,
27
28
  target: props.openLinkInNewTab ? "_blank" : void 0
28
29
  }), /* @__PURE__ */ React.createElement(BaseText, null, props.text))) : /* @__PURE__ */ React.createElement(View, __spreadProps(__spreadValues({}, props.attributes), {
@@ -1,4 +1,4 @@
1
- import { markSerializable } from "../util.js";
1
+ import { serializeFn } from "../util.js";
2
2
  const componentInfo = {
3
3
  name: "Columns",
4
4
  builtIn: true,
@@ -187,7 +187,7 @@ const componentInfo = {
187
187
  ]
188
188
  }
189
189
  ],
190
- onChange: markSerializable((options) => {
190
+ onChange: serializeFn((options) => {
191
191
  function clearWidths() {
192
192
  columns.forEach((col) => {
193
193
  col.delete("width");
@@ -1,4 +1,4 @@
1
- import { markSerializable } from "../util.js";
1
+ import { serializeFn } from "../util.js";
2
2
  const componentInfo = {
3
3
  name: "Embed",
4
4
  static: true,
@@ -10,7 +10,7 @@ const componentInfo = {
10
10
  required: true,
11
11
  defaultValue: "",
12
12
  helperText: "e.g. enter a youtube url, google map, etc",
13
- onChange: markSerializable((options) => {
13
+ onChange: serializeFn((options) => {
14
14
  const url = options.get("url");
15
15
  if (url) {
16
16
  options.set("content", "Loading...");
@@ -1,6 +1,4 @@
1
1
  var __defProp = Object.defineProperty;
2
- var __defProps = Object.defineProperties;
3
- var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
4
2
  var __getOwnPropSymbols = Object.getOwnPropertySymbols;
5
3
  var __hasOwnProp = Object.prototype.hasOwnProperty;
6
4
  var __propIsEnum = Object.prototype.propertyIsEnumerable;
@@ -16,7 +14,6 @@ var __spreadValues = (a, b) => {
16
14
  }
17
15
  return a;
18
16
  };
19
- var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
20
17
  var __async = (__this, __arguments, generator) => {
21
18
  return new Promise((resolve, reject) => {
22
19
  var fulfilled = (value) => {
@@ -194,14 +191,14 @@ function FormComponent(props) {
194
191
  }
195
192
  }
196
193
  const builderContext = useContext(BuilderContext);
197
- return /* @__PURE__ */ React.createElement(View, __spreadProps(__spreadValues({}, props.attributes), {
194
+ return /* @__PURE__ */ React.createElement(View, __spreadValues({
198
195
  validate: props.validate,
199
196
  ref: formRef,
200
197
  action: !props.sendWithJs && props.action,
201
198
  method: props.method,
202
199
  name: props.name,
203
200
  onSubmit: (event) => onSubmit(event)
204
- }), " ", props.builderBlock && props.builderBlock.children ? /* @__PURE__ */ React.createElement(React.Fragment, null, (_b = (_a = props.builderBlock) == null ? void 0 : _a.children) == null ? void 0 : _b.map((block) => /* @__PURE__ */ React.createElement(RenderBlock, {
201
+ }, props.attributes), " ", props.builderBlock && props.builderBlock.children ? /* @__PURE__ */ React.createElement(React.Fragment, null, (_b = (_a = props.builderBlock) == null ? void 0 : _a.children) == null ? void 0 : _b.map((block) => /* @__PURE__ */ React.createElement(RenderBlock, {
205
202
  block,
206
203
  context: builderContext
207
204
  }))) : null, " ", submissionState() === "error" ? /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(BuilderBlocks, {
@@ -1,4 +1,4 @@
1
- import { markSerializable } from "../util.js";
1
+ import { serializeFn } from "../util.js";
2
2
  const componentInfo = {
3
3
  name: "Image",
4
4
  static: true,
@@ -19,7 +19,7 @@ const componentInfo = {
19
19
  allowedFileTypes: ["jpeg", "jpg", "png", "svg"],
20
20
  required: true,
21
21
  defaultValue: "https://cdn.builder.io/api/v1/image/assets%2Fpwgjf0RoYWbdnJSbpBAjXNRMe9F2%2Ffb27a7c790324294af8be1c35fe30f4d",
22
- onChange: markSerializable((options) => {
22
+ onChange: serializeFn((options) => {
23
23
  const DEFAULT_ASPECT_RATIO = 0.7041;
24
24
  options.delete("srcset");
25
25
  options.delete("noWebp");
@@ -1,6 +1,4 @@
1
1
  var __defProp = Object.defineProperty;
2
- var __defProps = Object.defineProperties;
3
- var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
4
2
  var __getOwnPropSymbols = Object.getOwnPropertySymbols;
5
3
  var __hasOwnProp = Object.prototype.hasOwnProperty;
6
4
  var __propIsEnum = Object.prototype.propertyIsEnumerable;
@@ -16,12 +14,11 @@ var __spreadValues = (a, b) => {
16
14
  }
17
15
  return a;
18
16
  };
19
- var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
20
17
  import * as React from "react";
21
18
  import { View } from "react-native";
22
19
  import { isEditing } from "../../functions/is-editing.js";
23
20
  function ImgComponent(props) {
24
- return /* @__PURE__ */ React.createElement(View, __spreadProps(__spreadValues({}, props.attributes), {
21
+ return /* @__PURE__ */ React.createElement(View, __spreadValues({
25
22
  style: {
26
23
  objectFit: props.backgroundSize || "cover",
27
24
  objectPosition: props.backgroundPosition || "center"
@@ -29,7 +26,7 @@ function ImgComponent(props) {
29
26
  key: isEditing() && props.imgSrc || "default-key",
30
27
  alt: props.altText,
31
28
  src: props.imgSrc || props.image
32
- }));
29
+ }, props.attributes));
33
30
  }
34
31
  export {
35
32
  ImgComponent as default
@@ -1,6 +1,4 @@
1
1
  var __defProp = Object.defineProperty;
2
- var __defProps = Object.defineProperties;
3
- var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
4
2
  var __getOwnPropSymbols = Object.getOwnPropertySymbols;
5
3
  var __hasOwnProp = Object.prototype.hasOwnProperty;
6
4
  var __propIsEnum = Object.prototype.propertyIsEnumerable;
@@ -16,14 +14,13 @@ var __spreadValues = (a, b) => {
16
14
  }
17
15
  return a;
18
16
  };
19
- var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
20
17
  import BaseText from "../BaseText";
21
18
  import * as React from "react";
22
19
  import { View } from "react-native";
23
20
  function SubmitButton(props) {
24
- return /* @__PURE__ */ React.createElement(View, __spreadProps(__spreadValues({}, props.attributes), {
21
+ return /* @__PURE__ */ React.createElement(View, __spreadValues({
25
22
  type: "submit"
26
- }), /* @__PURE__ */ React.createElement(BaseText, null, props.text));
23
+ }, props.attributes), /* @__PURE__ */ React.createElement(BaseText, null, props.text));
27
24
  }
28
25
  export {
29
26
  SubmitButton as default
@@ -1,7 +1,8 @@
1
- function markSerializable(fn) {
2
- fn.__qwik_serializable__ = true;
3
- return fn;
4
- }
1
+ const serializeFn = (fnValue) => {
2
+ const fnStr = fnValue.toString().trim();
3
+ const appendFunction = !fnStr.startsWith("function") && !fnStr.startsWith("(");
4
+ return `return (${appendFunction ? "function " : ""}${fnStr}).apply(this, arguments)`;
5
+ };
5
6
  export {
6
- markSerializable
7
+ serializeFn
7
8
  };
@@ -30,6 +30,7 @@ var __objRest = (source, exclude) => {
30
30
  return target;
31
31
  };
32
32
  import * as React from "react";
33
+ import { View } from "react-native";
33
34
  import { useState } from "react";
34
35
  import { getBlockActions } from "../../functions/get-block-actions.js";
35
36
  import { getBlockComponentOptions } from "../../functions/get-block-component-options.js";
@@ -68,7 +69,7 @@ function RenderBlock(props) {
68
69
  return ref;
69
70
  }
70
71
  }
71
- function tagName() {
72
+ function tag() {
72
73
  return getBlockTag(useBlock());
73
74
  }
74
75
  function useBlock() {
@@ -98,7 +99,7 @@ function RenderBlock(props) {
98
99
  function renderComponentProps() {
99
100
  var _a2;
100
101
  return {
101
- blockChildren: children(),
102
+ blockChildren: useChildren(),
102
103
  componentRef: (_a2 = component == null ? void 0 : component()) == null ? void 0 : _a2.component,
103
104
  componentOptions: __spreadValues(__spreadValues({}, getBlockComponentOptions(useBlock())), shouldWrap() ? {} : {
104
105
  attributes: attributes()
@@ -106,14 +107,14 @@ function RenderBlock(props) {
106
107
  context: childrenContext()
107
108
  };
108
109
  }
109
- function children() {
110
+ function useChildren() {
110
111
  var _a2;
111
112
  return (_a2 = useBlock().children) != null ? _a2 : [];
112
113
  }
113
114
  function childrenWithoutParentComponent() {
114
115
  var _a2;
115
116
  const shouldRenderChildrenOutsideRef = !((_a2 = component == null ? void 0 : component()) == null ? void 0 : _a2.component) && !repeatItemData();
116
- return shouldRenderChildrenOutsideRef ? children() : [];
117
+ return shouldRenderChildrenOutsideRef ? useChildren() : [];
117
118
  }
118
119
  function repeatItemData() {
119
120
  const _a2 = props.block, { repeat } = _a2, blockWithoutRepeat = __objRest(_a2, ["repeat"]);
@@ -174,12 +175,11 @@ function RenderBlock(props) {
174
175
  }
175
176
  const [componentInfo, setComponentInfo] = useState(() => null);
176
177
  const RenderComponentTagRef = renderComponentTag();
177
- const TagNameRef = tagName();
178
- return /* @__PURE__ */ React.createElement(React.Fragment, null, shouldWrap() ? /* @__PURE__ */ React.createElement(React.Fragment, null, isEmptyHtmlElement(tagName()) ? /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(TagNameRef, __spreadValues({}, attributes()))) : null, !isEmptyHtmlElement(tagName()) && repeatItemData() ? /* @__PURE__ */ React.createElement(React.Fragment, null, (_a = repeatItemData()) == null ? void 0 : _a.map((data, index) => /* @__PURE__ */ React.createElement(RenderRepeatedBlock, {
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, {
179
179
  key: index,
180
180
  repeatContext: data.context,
181
181
  block: data.block
182
- }))) : null, !isEmptyHtmlElement(tagName()) && !repeatItemData() ? /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(TagNameRef, __spreadValues({}, attributes()), /* @__PURE__ */ React.createElement(RenderComponentTagRef, __spreadValues({}, renderComponentProps())), (_b = childrenWithoutParentComponent()) == null ? void 0 : _b.map((child) => /* @__PURE__ */ React.createElement(RenderBlock, {
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, {
183
183
  key: "render-block-" + child.id,
184
184
  block: child,
185
185
  context: childrenContext()
@@ -0,0 +1,8 @@
1
+ import * as React from "react";
2
+ import { View } from "react-native";
3
+ function BuilderEditing(props) {
4
+ return /* @__PURE__ */ React.createElement(View, null);
5
+ }
6
+ export {
7
+ BuilderEditing as default
8
+ };
@@ -3,15 +3,14 @@ import { View, Text } from "react-native";
3
3
  import { TARGET } from "../constants/target.js";
4
4
  function RenderInlinedStyles(props) {
5
5
  function injectedStyleScript() {
6
- return `<${tagName()}>${props.styles}</${tagName()}>`;
6
+ return `<${tag()}>${props.styles}</${tag()}>`;
7
7
  }
8
- function tagName() {
8
+ function tag() {
9
9
  return "style";
10
10
  }
11
- const TagNameRef = tagName();
12
11
  return /* @__PURE__ */ React.createElement(React.Fragment, null, TARGET === "svelte" ? /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(View, {
13
12
  dangerouslySetInnerHTML: { __html: injectedStyleScript() }
14
- })) : /* @__PURE__ */ React.createElement(TagNameRef, null, /* @__PURE__ */ React.createElement(Text, null, props.styles)));
13
+ })) : /* @__PURE__ */ React.createElement(View, null, /* @__PURE__ */ React.createElement(Text, null, props.styles)));
15
14
  }
16
15
  export {
17
16
  RenderInlinedStyles as default
@@ -56,9 +56,13 @@ const generateContentUrl = (options) => {
56
56
  query,
57
57
  noTraverse = false,
58
58
  model,
59
- apiKey
59
+ apiKey,
60
+ includeRefs = true
60
61
  } = options;
61
- const url = new URL(`https://cdn.builder.io/api/v2/content/${model}?apiKey=${apiKey}&limit=${limit}&noTraverse=${noTraverse}`);
62
+ if (!apiKey) {
63
+ throw new Error("Missing API key");
64
+ }
65
+ const url = new URL(`https://cdn.builder.io/api/v2/content/${model}?apiKey=${apiKey}&limit=${limit}&noTraverse=${noTraverse}&includeRefs=${includeRefs}`);
62
66
  const queryOptions = __spreadValues(__spreadValues({}, getBuilderSearchParamsFromWindow()), normalizeSearchParams(options.options || {}));
63
67
  const flattened = flatten(queryOptions);
64
68
  for (const key in flattened) {
@@ -29,6 +29,7 @@ var __objRest = (source, exclude) => {
29
29
  }
30
30
  return target;
31
31
  };
32
+ import { serializeFn } from "../blocks/util.js";
32
33
  import { fastClone } from "./fast-clone.js";
33
34
  const components = [];
34
35
  function registerComponent(component, info) {
@@ -48,11 +49,6 @@ const createRegisterComponentMessage = (_a) => {
48
49
  };
49
50
  };
50
51
  const serializeValue = (value) => typeof value === "function" ? serializeFn(value) : fastClone(value);
51
- const serializeFn = (fnValue) => {
52
- const fnStr = fnValue.toString().trim();
53
- const appendFunction = !fnStr.startsWith("function") && !fnStr.startsWith("(");
54
- return `return (${appendFunction ? "function " : ""}${fnStr}).apply(this, arguments)`;
55
- };
56
52
  const prepareComponentInfoToSend = (_c) => {
57
53
  var _d = _c, {
58
54
  inputs
package/src/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import "./index-helpers/top-of-file.js";
1
+ export * from "./index-helpers/top-of-file.js";
2
2
  import "./scripts/init-editing.js";
3
3
  export * from "./index-helpers/blocks-exports.js";
4
4
  export * from "./functions/is-editing.js";
@@ -19,8 +19,13 @@ const registerInsertMenu = () => {
19
19
  ]
20
20
  });
21
21
  };
22
+ let isSetupForEditing = false;
22
23
  const setupBrowserForEditing = () => {
23
24
  var _a;
25
+ if (isSetupForEditing) {
26
+ return;
27
+ }
28
+ isSetupForEditing = true;
24
29
  if (isBrowser()) {
25
30
  (_a = window.parent) == null ? void 0 : _a.postMessage({
26
31
  type: "builder.sdkInfo",