@builder.io/sdk-react-native 0.5.2 → 0.5.4

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/dist/blocks/button/button.js +2 -2
  3. package/dist/blocks/columns/columns.js +8 -4
  4. package/dist/blocks/img/img.js +1 -1
  5. package/dist/blocks/input/input.js +1 -1
  6. package/dist/blocks/section/section.js +1 -1
  7. package/dist/blocks/select/select.js +1 -1
  8. package/dist/blocks/submit-button/submit-button.js +1 -1
  9. package/dist/blocks/symbol/symbol.js +4 -2
  10. package/dist/blocks/textarea/textarea.js +1 -1
  11. package/dist/components/blocks/blocks-wrapper.js +4 -2
  12. package/dist/components/content/components/enable-editor.js +5 -4
  13. package/dist/components/content/content.js +3 -1
  14. package/dist/components/content-variants/content-variants.js +13 -6
  15. package/dist/constants/sdk-version.js +2 -1
  16. package/dist/functions/evaluate/acorn-interpreter.js +3101 -0
  17. package/dist/functions/evaluate/evaluate.js +2 -2
  18. package/dist/functions/evaluate/non-node-runtime/index.js +44 -0
  19. package/dist/functions/evaluate/{non-node-runtime.js → non-node-runtime/non-node-runtime.js} +4 -4
  20. package/package.json +12 -3
  21. package/src/components/content-variants/content-variants.jsx +13 -8
  22. package/src/constants/sdk-version.js +2 -1
  23. package/src/functions/evaluate/acorn-interpreter.js +2876 -0
  24. package/src/functions/evaluate/evaluate.js +1 -1
  25. package/src/functions/evaluate/non-node-runtime/index.js +18 -0
  26. package/src/functions/evaluate/{non-node-runtime.js → non-node-runtime/non-node-runtime.js} +3 -3
  27. package/dist/functions/evaluate/acorn.js +0 -1691
  28. package/dist/functions/evaluate/interpreter.js +0 -2903
  29. package/src/functions/evaluate/acorn.js +0 -1595
  30. package/src/functions/evaluate/interpreter.js +0 -2801
package/README.md CHANGED
@@ -21,3 +21,7 @@ Take a look at [our example repo](/examples/react-native) for how to use this SD
21
21
  ## Fetch
22
22
 
23
23
  This Package uses fetch. See [these docs](https://github.com/BuilderIO/this-package-uses-fetch/blob/main/README.md) for more information.
24
+
25
+ ## Non-Node.js Runtimes (Edge, Serverless)
26
+
27
+ If planning to deploy your app to a non-Node.js runtime (like Edge or Serverless functions), make sure to read the [Non-Node.js Runtimes](../../README.md#non-nodejs-runtimes-edge-serverless) section of the main README.
@@ -33,9 +33,9 @@ const react_native_1 = require("react-native");
33
33
  const helpers_js_1 = require("../helpers.js");
34
34
  function Button(props) {
35
35
  return (React.createElement(React.Fragment, null, props.link ? (React.createElement(React.Fragment, null,
36
- React.createElement(react_native_1.View, { role: "button", ...props.attributes, href: props.link, target: props.openLinkInNewTab ? "_blank" : undefined },
36
+ React.createElement(react_native_1.View, { role: "button", ...{}, ...props.attributes, href: props.link, target: props.openLinkInNewTab ? "_blank" : undefined },
37
37
  React.createElement(BaseText_1.default, null, props.text)))) : (React.createElement(React.Fragment, null,
38
- React.createElement(react_native_1.View, { ...props.attributes, style: {
38
+ React.createElement(react_native_1.View, { ...{}, ...props.attributes, style: {
39
39
  ...styles.view1,
40
40
  ...props.attributes.style,
41
41
  } },
@@ -131,16 +131,20 @@ function Columns(props) {
131
131
  return (React.createElement(react_native_1.View, { style: {
132
132
  ...styles.view1,
133
133
  ...columnsCssVars(),
134
- }, dataSet: {
135
- "builder-block-name": "builder-columns",
134
+ }, ...{
135
+ dataSet: {
136
+ "builder-block-name": "builder-columns",
137
+ },
136
138
  } },
137
139
  target_js_1.TARGET !== "reactNative" ? (React.createElement(React.Fragment, null,
138
140
  React.createElement(inlined_styles_1.default, { styles: columnsStyles() }))) : null, (_a = props.columns) === null || _a === void 0 ? void 0 :
139
141
  _a.map((column, index) => (React.createElement(react_native_1.View, { style: {
140
142
  ...styles.view2,
141
143
  ...columnCssVars(index),
142
- }, dataSet: {
143
- "builder-block-name": "builder-column",
144
+ }, ...{
145
+ dataSet: {
146
+ "builder-block-name": "builder-column",
147
+ },
144
148
  }, key: index },
145
149
  React.createElement(blocks_1.default, { blocks: column.blocks, path: `component.options.columns.${index}.blocks`, parent: props.builderBlock.id, styleProp: {
146
150
  flexGrow: "1",
@@ -32,6 +32,6 @@ function ImgComponent(props) {
32
32
  return (React.createElement(react_native_1.View, { style: {
33
33
  objectFit: props.backgroundSize || "cover",
34
34
  objectPosition: props.backgroundPosition || "center",
35
- }, key: ((0, is_editing_js_1.isEditing)() && props.imgSrc) || "default-key", alt: props.altText, src: props.imgSrc || props.image, ...props.attributes }));
35
+ }, key: ((0, is_editing_js_1.isEditing)() && props.imgSrc) || "default-key", alt: props.altText, src: props.imgSrc || props.image, ...{}, ...props.attributes }));
36
36
  }
37
37
  exports.default = ImgComponent;
@@ -29,6 +29,6 @@ const react_native_1 = require("react-native");
29
29
  const is_editing_js_1 = require("../../functions/is-editing.js");
30
30
  const helpers_js_1 = require("../helpers.js");
31
31
  function FormInputComponent(props) {
32
- return (React.createElement(react_native_1.View, { ...props.attributes, key: (0, is_editing_js_1.isEditing)() && props.defaultValue ? props.defaultValue : "default-key", placeholder: props.placeholder, type: props.type, name: props.name, value: props.value, defaultValue: props.defaultValue, required: props.required }));
32
+ return (React.createElement(react_native_1.View, { ...{}, ...props.attributes, key: (0, is_editing_js_1.isEditing)() && props.defaultValue ? props.defaultValue : "default-key", placeholder: props.placeholder, type: props.type, name: props.name, value: props.value, defaultValue: props.defaultValue, required: props.required }));
33
33
  }
34
34
  exports.default = FormInputComponent;
@@ -28,7 +28,7 @@ const React = __importStar(require("react"));
28
28
  const react_native_1 = require("react-native");
29
29
  const helpers_js_1 = require("../helpers.js");
30
30
  function SectionComponent(props) {
31
- return (React.createElement(react_native_1.View, { ...props.attributes, style: {
31
+ return (React.createElement(react_native_1.View, { ...{}, ...props.attributes, style: {
32
32
  width: "100%",
33
33
  alignSelf: "stretch",
34
34
  flexGrow: 1,
@@ -34,7 +34,7 @@ const is_editing_js_1 = require("../../functions/is-editing.js");
34
34
  const helpers_js_1 = require("../helpers.js");
35
35
  function SelectComponent(props) {
36
36
  var _a;
37
- return (React.createElement(react_native_1.View, { ...props.attributes, value: props.value, key: (0, is_editing_js_1.isEditing)() && props.defaultValue ? props.defaultValue : "default-key", defaultValue: props.defaultValue, name: props.name }, (_a = props.options) === null || _a === void 0 ? void 0 : _a.map((option) => (React.createElement(react_native_1.View, { value: option.value },
37
+ return (React.createElement(react_native_1.View, { ...{}, ...props.attributes, value: props.value, key: (0, is_editing_js_1.isEditing)() && props.defaultValue ? props.defaultValue : "default-key", defaultValue: props.defaultValue, name: props.name }, (_a = props.options) === null || _a === void 0 ? void 0 : _a.map((option) => (React.createElement(react_native_1.View, { value: option.value },
38
38
  React.createElement(BaseText_1.default, null, option.name || option.value))))));
39
39
  }
40
40
  exports.default = SelectComponent;
@@ -32,7 +32,7 @@ const React = __importStar(require("react"));
32
32
  const react_native_1 = require("react-native");
33
33
  const helpers_js_1 = require("../helpers.js");
34
34
  function SubmitButton(props) {
35
- return (React.createElement(react_native_1.View, { type: "submit", ...props.attributes },
35
+ return (React.createElement(react_native_1.View, { type: "submit", ...{}, ...props.attributes },
36
36
  React.createElement(BaseText_1.default, null, props.text)));
37
37
  }
38
38
  exports.default = SubmitButton;
@@ -67,8 +67,10 @@ function Symbol(props) {
67
67
  (0, react_1.useEffect)(() => {
68
68
  setContent();
69
69
  }, [props.symbol]);
70
- return (React.createElement(react_native_1.View, { ...props.attributes, dataSet: {
71
- class: className(),
70
+ return (React.createElement(react_native_1.View, { ...{}, ...props.attributes, ...{
71
+ dataSet: {
72
+ class: className(),
73
+ },
72
74
  } },
73
75
  React.createElement(content_variants_1.default, { __isNestedRender: true, apiVersion: props.builderContext.apiVersion, apiKey: props.builderContext.apiKey, context: props.builderContext.context, customComponents: Object.values(props.builderComponents), data: {
74
76
  ...(_a = props.symbol) === null || _a === void 0 ? void 0 : _a.data,
@@ -28,6 +28,6 @@ const React = __importStar(require("react"));
28
28
  const react_native_1 = require("react-native");
29
29
  const helpers_js_1 = require("../helpers.js");
30
30
  function Textarea(props) {
31
- return (React.createElement(react_native_1.View, { ...props.attributes, placeholder: props.placeholder, name: props.name, value: props.value, defaultValue: props.defaultValue }));
31
+ return (React.createElement(react_native_1.View, { ...{}, ...props.attributes, placeholder: props.placeholder, name: props.name, value: props.value, defaultValue: props.defaultValue }));
32
32
  }
33
33
  exports.default = Textarea;
@@ -56,8 +56,10 @@ function BlocksWrapper(props) {
56
56
  }, "*");
57
57
  }
58
58
  }
59
- return (React.createElement(react_native_1.View, { "builder-path": props.path, "builder-parent-id": props.parent, dataSet: {
60
- class: className(),
59
+ return (React.createElement(react_native_1.View, { "builder-path": props.path, "builder-parent-id": props.parent, ...{
60
+ dataSet: {
61
+ class: className(),
62
+ },
61
63
  }, style: {
62
64
  ...styles.view1,
63
65
  ...props.styleProp,
@@ -296,10 +296,11 @@ function EnableEditor(props) {
296
296
  };
297
297
  }, []);
298
298
  return (React.createElement(builder_context_1.default.Provider, { value: props.builderContextSignal }, props.builderContextSignal.content ? (React.createElement(React.Fragment, null,
299
- React.createElement(react_native_1.View, { key: forceReRenderCount, ref: elementRef, onClick: (event) => onClick(event), "builder-content-id": (_e = props.builderContextSignal.content) === null || _e === void 0 ? void 0 : _e.id, "builder-model": props.model,
300
- // currently, we can't set the actual ID here. // we don't need it right now, we just need to identify content divs for testing.
301
- dataSet: {
302
- "builder-content-id": "",
299
+ React.createElement(react_native_1.View, { key: forceReRenderCount, ref: elementRef, onClick: (event) => onClick(event), "builder-content-id": (_e = props.builderContextSignal.content) === null || _e === void 0 ? void 0 : _e.id, "builder-model": props.model, ...{
300
+ // currently, we can't set the actual ID here. // we don't need it right now, we just need to identify content divs for testing.
301
+ dataSet: {
302
+ "builder-content-id": "",
303
+ },
303
304
  }, ...(props.showContent
304
305
  ? {}
305
306
  : {
@@ -104,7 +104,9 @@ function ContentComponent(props) {
104
104
  return (React.createElement(components_context_1.default.Provider, { value: {
105
105
  registeredComponents: registeredComponents,
106
106
  } },
107
- React.createElement(enable_editor_1.default, { content: props.content, model: props.model, context: props.context, apiKey: props.apiKey, canTrack: props.canTrack, locale: props.locale, includeRefs: props.includeRefs, enrich: props.enrich, classNameProp: props.classNameProp, showContent: props.showContent, builderContextSignal: builderContextSignal, setBuilderContextSignal: setBuilderContextSignal },
107
+ React.createElement(enable_editor_1.default, { content: props.content, model: props.model, context: props.context, apiKey: props.apiKey, canTrack: props.canTrack, locale: props.locale, includeRefs: props.includeRefs, enrich: props.enrich, classNameProp: props.classNameProp, showContent: props.showContent, builderContextSignal: builderContextSignal, ...{
108
+ setBuilderContextSignal: setBuilderContextSignal,
109
+ } },
108
110
  props.isSsrAbTest ? (React.createElement(React.Fragment, null,
109
111
  React.createElement(inlined_script_1.default, { scriptStr: scriptStr }))) : null,
110
112
  target_js_1.TARGET !== "reactNative" ? (React.createElement(React.Fragment, null,
@@ -55,6 +55,18 @@ function ContentVariants(props) {
55
55
  .map((value) => `.variant-${value.testVariationId} { display: none; } `)
56
56
  .join("");
57
57
  }
58
+ function defaultContent() {
59
+ var _a;
60
+ return shouldRenderVariants
61
+ ? {
62
+ ...props.content,
63
+ testVariationId: (_a = props.content) === null || _a === void 0 ? void 0 : _a.id,
64
+ }
65
+ : (0, ab_tests_js_1.handleABTestingSync)({
66
+ item: props.content,
67
+ canTrack: (0, canTrack_js_1.getDefaultCanTrack)(props.canTrack),
68
+ });
69
+ }
58
70
  (0, react_1.useEffect)(() => {
59
71
  /**
60
72
  * We unmount the non-winning variants post-hydration in Vue.
@@ -67,11 +79,6 @@ function ContentVariants(props) {
67
79
  React.createElement(inlined_styles_1.default, { id: `variants-styles-${(_a = props.content) === null || _a === void 0 ? void 0 : _a.id}`, styles: hideVariantsStyleString() }),
68
80
  React.createElement(inlined_script_1.default, { scriptStr: variantScriptStr() }), (_b = (0, helpers_js_1.getVariants)(props.content)) === null || _b === void 0 ? void 0 :
69
81
  _b.map((variant) => (React.createElement(content_1.default, { key: variant.testVariationId, content: variant, showContent: false, classNameProp: undefined, model: props.model, data: props.data, context: props.context, apiKey: props.apiKey, apiVersion: props.apiVersion, customComponents: props.customComponents, canTrack: props.canTrack, locale: props.locale, includeRefs: props.includeRefs, enrich: props.enrich, isSsrAbTest: shouldRenderVariants }))))) : null,
70
- React.createElement(content_1.default, { content: shouldRenderVariants
71
- ? props.content
72
- : (0, ab_tests_js_1.handleABTestingSync)({
73
- item: props.content,
74
- canTrack: (0, canTrack_js_1.getDefaultCanTrack)(props.canTrack),
75
- }), classNameProp: `variant-${(_c = props.content) === null || _c === void 0 ? void 0 : _c.id}`, showContent: true, model: props.model, data: props.data, context: props.context, apiKey: props.apiKey, apiVersion: props.apiVersion, customComponents: props.customComponents, canTrack: props.canTrack, locale: props.locale, includeRefs: props.includeRefs, enrich: props.enrich, isSsrAbTest: shouldRenderVariants })));
82
+ React.createElement(content_1.default, { ...{}, content: defaultContent(), classNameProp: `variant-${(_c = props.content) === null || _c === void 0 ? void 0 : _c.id}`, showContent: true, model: props.model, data: props.data, context: props.context, apiKey: props.apiKey, apiVersion: props.apiVersion, customComponents: props.customComponents, canTrack: props.canTrack, locale: props.locale, includeRefs: props.includeRefs, enrich: props.enrich, isSsrAbTest: shouldRenderVariants })));
76
83
  }
77
84
  exports.default = ContentVariants;
@@ -1,4 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.SDK_VERSION = void 0;
4
- exports.SDK_VERSION = "0.5.2";
4
+ const SDK_VERSION = "UNKNOWN_VERSION";
5
+ exports.SDK_VERSION = SDK_VERSION;