@builder.io/sdk-react-native 0.5.1 → 0.5.3
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/README.md +4 -0
- package/dist/blocks/button/button.js +2 -2
- package/dist/blocks/columns/columns.js +8 -4
- package/dist/blocks/img/img.js +1 -1
- package/dist/blocks/input/input.js +1 -1
- package/dist/blocks/section/section.js +1 -1
- package/dist/blocks/select/select.js +1 -1
- package/dist/blocks/submit-button/submit-button.js +1 -1
- package/dist/blocks/symbol/symbol.js +4 -2
- package/dist/blocks/textarea/textarea.js +1 -1
- package/dist/components/blocks/blocks-wrapper.js +4 -2
- package/dist/components/content/components/enable-editor.js +5 -4
- package/dist/components/content/content.js +3 -1
- package/dist/components/content-variants/content-variants.js +13 -6
- package/dist/constants/sdk-version.js +2 -1
- package/dist/functions/evaluate/evaluate.js +39 -2
- package/dist/functions/evaluate/interpreter.js +1 -1
- package/package.json +15 -4
- package/src/components/content-variants/content-variants.jsx +13 -8
- package/src/constants/sdk-version.js +2 -1
- package/src/functions/evaluate/evaluate.js +15 -1
- package/src/functions/evaluate/interpreter.js +1 -1
- package/dist/blocks/util.js +0 -9
- package/dist/components/block/components/block-wrapper/block-wrapper.js +0 -41
- package/dist/components/block/components/component-ref.js +0 -81
- package/dist/components/block/components/component.js +0 -41
- package/dist/components/block/components/interactive-element/interactive-element.helpers.js +0 -35
- package/dist/components/block/components/interactive-element/interactive-element.js +0 -36
- package/dist/components/content/builder-editing.js +0 -32
- package/dist/components/content/components/content-styles.helpers.js +0 -55
- package/dist/components/content/components/content-styles.js +0 -61
- package/dist/components/render-block/block-styles.js +0 -96
- package/dist/components/render-block/render-block.helpers.js +0 -113
- package/dist/components/render-block/render-block.js +0 -162
- package/dist/components/render-block/render-component.js +0 -52
- package/dist/components/render-block/render-repeated-block.js +0 -40
- package/dist/components/render-block/types.js +0 -1
- package/dist/components/render-blocks.js +0 -81
- package/dist/components/render-content/builder-editing.js +0 -32
- package/dist/components/render-content/components/render-styles.helpers.js +0 -55
- package/dist/components/render-content/components/render-styles.js +0 -61
- package/dist/components/render-content/index.js +0 -8
- package/dist/components/render-content/render-content.helpers.js +0 -42
- package/dist/components/render-content/render-content.js +0 -375
- package/dist/components/render-content/render-content.types.js +0 -1
- package/dist/components/render-content/wrap-component-ref.js +0 -5
- package/dist/components/render-content-variants/helpers.js +0 -168
- package/dist/components/render-content-variants/render-content-variants.js +0 -78
- package/dist/components/render-content-variants/render-content-variants.types.js +0 -1
- package/dist/functions/apply-patch-with-mutation.test.js +0 -55
- package/dist/functions/evaluate.js +0 -47
- package/dist/functions/evaluate.test.js +0 -25
- package/dist/functions/get-builder-search-params/fn.test.js +0 -15
- package/dist/functions/get-content/generate-content-url.test.js +0 -113
- package/dist/functions/get-content/processCookies.js +0 -7
- package/dist/functions/get-processed-block.test.js +0 -38
- package/dist/functions/on-change.test.js +0 -31
- package/dist/functions/set.test.js +0 -24
- package/dist/helpers/url.test.js +0 -23
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
|
-
},
|
|
135
|
-
|
|
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
|
-
},
|
|
143
|
-
|
|
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",
|
package/dist/blocks/img/img.js
CHANGED
|
@@ -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,
|
|
71
|
-
|
|
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,
|
|
60
|
-
|
|
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
|
-
|
|
301
|
-
|
|
302
|
-
|
|
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,
|
|
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,11 +1,48 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
2
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
26
|
exports.runInNode = exports.runInBrowser = exports.flattenState = exports.evaluate = void 0;
|
|
4
27
|
const logger_js_1 = require("../../helpers/logger.js");
|
|
5
28
|
const is_browser_js_1 = require("../is-browser.js");
|
|
6
29
|
const is_editing_js_1 = require("../is-editing.js");
|
|
7
30
|
const is_non_node_server_js_1 = require("../is-non-node-server.js");
|
|
8
|
-
|
|
31
|
+
let runInNonNode;
|
|
32
|
+
if ((0, is_non_node_server_js_1.isNonNodeServer)()) {
|
|
33
|
+
Promise.resolve().then(() => __importStar(require("./non-node-runtime.js"))).then(m => {
|
|
34
|
+
runInNonNode = m.runInNonNode;
|
|
35
|
+
}).catch(err => {
|
|
36
|
+
const ERROR_MESSAGE = `Error importing JS interpreter for non-Node.js runtimes. Make sure \`js-interpreter\` is installed.
|
|
37
|
+
Read more here: https://github.com/BuilderIO/builder/tree/main/packages/sdks/README.md#non-nodejs-runtimes-edge-serverless
|
|
38
|
+
`;
|
|
39
|
+
logger_js_1.logger.error(ERROR_MESSAGE, err);
|
|
40
|
+
runInNonNode = (..._args) => {
|
|
41
|
+
logger_js_1.logger.error(ERROR_MESSAGE);
|
|
42
|
+
return void 0;
|
|
43
|
+
};
|
|
44
|
+
});
|
|
45
|
+
}
|
|
9
46
|
function evaluate({ code, context, localState, rootState, rootSetState, event, isExpression = true }) {
|
|
10
47
|
if (code === "") {
|
|
11
48
|
logger_js_1.logger.warn("Skipping evaluation of empty code block.");
|
|
@@ -30,7 +67,7 @@ function evaluate({ code, context, localState, rootState, rootSetState, event, i
|
|
|
30
67
|
if ((0, is_browser_js_1.isBrowser)())
|
|
31
68
|
return runInBrowser(args);
|
|
32
69
|
if ((0, is_non_node_server_js_1.isNonNodeServer)())
|
|
33
|
-
return
|
|
70
|
+
return runInNonNode(args);
|
|
34
71
|
return runInNode(args);
|
|
35
72
|
}
|
|
36
73
|
exports.evaluate = evaluate;
|
|
@@ -2897,7 +2897,7 @@ Interpreter.prototype["getGlobalScope"] = Interpreter.prototype.getGlobalScope;
|
|
|
2897
2897
|
Interpreter.prototype["getStateStack"] = Interpreter.prototype.getStateStack;
|
|
2898
2898
|
Interpreter.prototype["setStateStack"] = Interpreter.prototype.setStateStack;
|
|
2899
2899
|
Interpreter["VALUE_IN_DESCRIPTOR"] = Interpreter.VALUE_IN_DESCRIPTOR;
|
|
2900
|
-
const acorn_1 = require("acorn");
|
|
2900
|
+
const acorn_1 = require("./acorn");
|
|
2901
2901
|
Interpreter.nativeGlobal.acornParse = acorn_1.parse;
|
|
2902
2902
|
var stdin_default = Interpreter;
|
|
2903
2903
|
exports.default = stdin_default;
|
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.5.
|
|
4
|
+
"version": "0.5.3",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
7
7
|
"module": "./dist/index.js",
|
|
@@ -13,7 +13,8 @@
|
|
|
13
13
|
"dist"
|
|
14
14
|
],
|
|
15
15
|
"scripts": {
|
|
16
|
-
"
|
|
16
|
+
"clean": "rimraf dist",
|
|
17
|
+
"build": "yarn clean && tsc"
|
|
17
18
|
},
|
|
18
19
|
"dependencies": {
|
|
19
20
|
"@react-native-async-storage/async-storage": "^1.17.10",
|
|
@@ -22,13 +23,23 @@
|
|
|
22
23
|
"react-native-video": "^5.1.1"
|
|
23
24
|
},
|
|
24
25
|
"peerDependencies": {
|
|
25
|
-
"react
|
|
26
|
+
"react": "^18.0.0",
|
|
27
|
+
"react-dom": "^18.0.0",
|
|
28
|
+
"react-native": ">=0.64.3",
|
|
26
29
|
"react-native-url-polyfill": "^1.3.0"
|
|
27
30
|
},
|
|
28
31
|
"devDependencies": {
|
|
29
32
|
"@tsconfig/react-native": "^2.0.3",
|
|
30
33
|
"@types/react-native-video": "^5.0.9",
|
|
34
|
+
"nx": "^16.6.0",
|
|
35
|
+
"nx-cloud": "^16.2.0",
|
|
31
36
|
"react-native-url-polyfill": "^1.3.0",
|
|
32
|
-
"
|
|
37
|
+
"rimraf": "^3.0.2",
|
|
38
|
+
"typescript": "^4.9.4"
|
|
39
|
+
},
|
|
40
|
+
"nx": {
|
|
41
|
+
"implicitDependencies": [
|
|
42
|
+
"@builder.io/sdks"
|
|
43
|
+
]
|
|
33
44
|
}
|
|
34
45
|
}
|
|
@@ -46,6 +46,18 @@ function ContentVariants(props) {
|
|
|
46
46
|
.join("");
|
|
47
47
|
}
|
|
48
48
|
|
|
49
|
+
function defaultContent() {
|
|
50
|
+
return shouldRenderVariants
|
|
51
|
+
? {
|
|
52
|
+
...props.content,
|
|
53
|
+
testVariationId: props.content?.id,
|
|
54
|
+
}
|
|
55
|
+
: handleABTestingSync({
|
|
56
|
+
item: props.content,
|
|
57
|
+
canTrack: getDefaultCanTrack(props.canTrack),
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
|
|
49
61
|
useEffect(() => {
|
|
50
62
|
/**
|
|
51
63
|
* We unmount the non-winning variants post-hydration in Vue.
|
|
@@ -91,14 +103,7 @@ function ContentVariants(props) {
|
|
|
91
103
|
|
|
92
104
|
<ContentComponent
|
|
93
105
|
{...{}}
|
|
94
|
-
content={
|
|
95
|
-
shouldRenderVariants
|
|
96
|
-
? props.content
|
|
97
|
-
: handleABTestingSync({
|
|
98
|
-
item: props.content,
|
|
99
|
-
canTrack: getDefaultCanTrack(props.canTrack),
|
|
100
|
-
})
|
|
101
|
-
}
|
|
106
|
+
content={defaultContent()}
|
|
102
107
|
classNameProp={`variant-${props.content?.id}`}
|
|
103
108
|
showContent={true}
|
|
104
109
|
model={props.model}
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
const SDK_VERSION = "UNKNOWN_VERSION";
|
|
2
|
+
export { SDK_VERSION }
|
|
@@ -2,7 +2,21 @@ import { logger } from "../../helpers/logger.js";
|
|
|
2
2
|
import { isBrowser } from "../is-browser.js";
|
|
3
3
|
import { isEditing } from "../is-editing.js";
|
|
4
4
|
import { isNonNodeServer } from "../is-non-node-server.js";
|
|
5
|
-
|
|
5
|
+
let runInNonNode;
|
|
6
|
+
if (isNonNodeServer()) {
|
|
7
|
+
import("./non-node-runtime.js").then(m => {
|
|
8
|
+
runInNonNode = m.runInNonNode;
|
|
9
|
+
}).catch(err => {
|
|
10
|
+
const ERROR_MESSAGE = `Error importing JS interpreter for non-Node.js runtimes. Make sure \`js-interpreter\` is installed.
|
|
11
|
+
Read more here: https://github.com/BuilderIO/builder/tree/main/packages/sdks/README.md#non-nodejs-runtimes-edge-serverless
|
|
12
|
+
`;
|
|
13
|
+
logger.error(ERROR_MESSAGE, err);
|
|
14
|
+
runInNonNode = (..._args) => {
|
|
15
|
+
logger.error(ERROR_MESSAGE);
|
|
16
|
+
return void 0;
|
|
17
|
+
};
|
|
18
|
+
});
|
|
19
|
+
}
|
|
6
20
|
function evaluate({
|
|
7
21
|
code,
|
|
8
22
|
context,
|
|
@@ -2795,7 +2795,7 @@ Interpreter.prototype["getGlobalScope"] = Interpreter.prototype.getGlobalScope;
|
|
|
2795
2795
|
Interpreter.prototype["getStateStack"] = Interpreter.prototype.getStateStack;
|
|
2796
2796
|
Interpreter.prototype["setStateStack"] = Interpreter.prototype.setStateStack;
|
|
2797
2797
|
Interpreter["VALUE_IN_DESCRIPTOR"] = Interpreter.VALUE_IN_DESCRIPTOR;
|
|
2798
|
-
import { parse } from "acorn";
|
|
2798
|
+
import { parse } from "./acorn";
|
|
2799
2799
|
Interpreter.nativeGlobal.acornParse = parse;
|
|
2800
2800
|
var stdin_default = Interpreter;
|
|
2801
2801
|
export { stdin_default as default }
|
package/dist/blocks/util.js
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.serializeFn = void 0;
|
|
4
|
-
const serializeFn = (fnValue) => {
|
|
5
|
-
const fnStr = fnValue.toString().trim();
|
|
6
|
-
const appendFunction = !fnStr.startsWith("function") && !fnStr.startsWith("(");
|
|
7
|
-
return `return (${appendFunction ? "function " : ""}${fnStr}).apply(this, arguments)`;
|
|
8
|
-
};
|
|
9
|
-
exports.serializeFn = serializeFn;
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
'use client';
|
|
3
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
4
|
-
if (k2 === undefined) k2 = k;
|
|
5
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
6
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
7
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
8
|
-
}
|
|
9
|
-
Object.defineProperty(o, k2, desc);
|
|
10
|
-
}) : (function(o, m, k, k2) {
|
|
11
|
-
if (k2 === undefined) k2 = k;
|
|
12
|
-
o[k2] = m[k];
|
|
13
|
-
}));
|
|
14
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
15
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
16
|
-
}) : function(o, v) {
|
|
17
|
-
o["default"] = v;
|
|
18
|
-
});
|
|
19
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
20
|
-
if (mod && mod.__esModule) return mod;
|
|
21
|
-
var result = {};
|
|
22
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
23
|
-
__setModuleDefault(result, mod);
|
|
24
|
-
return result;
|
|
25
|
-
};
|
|
26
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
27
|
-
const React = __importStar(require("react"));
|
|
28
|
-
const react_native_1 = require("react-native");
|
|
29
|
-
const interactive_element_helpers_js_1 = require("../interactive-element/interactive-element.helpers.js");
|
|
30
|
-
function BlockWrapper(props) {
|
|
31
|
-
return (React.createElement(React.Fragment, null, props.hasChildren ? (React.createElement(React.Fragment, null,
|
|
32
|
-
React.createElement(props.Wrapper, { ...(0, interactive_element_helpers_js_1.getBlockProps)({
|
|
33
|
-
block: props.block,
|
|
34
|
-
contextValue: props.context,
|
|
35
|
-
}) }, props.children))) : (React.createElement(React.Fragment, null,
|
|
36
|
-
React.createElement(props.Wrapper, { ...(0, interactive_element_helpers_js_1.getBlockProps)({
|
|
37
|
-
block: props.block,
|
|
38
|
-
contextValue: props.context,
|
|
39
|
-
}) })))));
|
|
40
|
-
}
|
|
41
|
-
exports.default = BlockWrapper;
|
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
'use client';
|
|
3
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
4
|
-
if (k2 === undefined) k2 = k;
|
|
5
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
6
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
7
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
8
|
-
}
|
|
9
|
-
Object.defineProperty(o, k2, desc);
|
|
10
|
-
}) : (function(o, m, k, k2) {
|
|
11
|
-
if (k2 === undefined) k2 = k;
|
|
12
|
-
o[k2] = m[k];
|
|
13
|
-
}));
|
|
14
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
15
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
16
|
-
}) : function(o, v) {
|
|
17
|
-
o["default"] = v;
|
|
18
|
-
});
|
|
19
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
20
|
-
if (mod && mod.__esModule) return mod;
|
|
21
|
-
var result = {};
|
|
22
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
23
|
-
__setModuleDefault(result, mod);
|
|
24
|
-
return result;
|
|
25
|
-
};
|
|
26
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
27
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
28
|
-
};
|
|
29
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
30
|
-
const React = __importStar(require("react"));
|
|
31
|
-
const react_native_1 = require("react-native");
|
|
32
|
-
const react_1 = require("react");
|
|
33
|
-
const block_styles_1 = __importDefault(require("./block-styles"));
|
|
34
|
-
const block_1 = __importDefault(require("../block"));
|
|
35
|
-
const get_block_properties_js_1 = require("../../../functions/get-block-properties.js");
|
|
36
|
-
const block_wrapper_1 = __importDefault(require("./block-wrapper"));
|
|
37
|
-
const builder_context_js_1 = __importDefault(require("../../../context/builder.context.js"));
|
|
38
|
-
function ComponentRef(props) {
|
|
39
|
-
var _a, _b;
|
|
40
|
-
const [Wrapper, setWrapper] = (0, react_1.useState)(() => props.isRSC ? props.componentRef : block_wrapper_1.default);
|
|
41
|
-
function wrapperProps() {
|
|
42
|
-
const blockWrapperProps = {
|
|
43
|
-
Wrapper: props.componentRef,
|
|
44
|
-
block: props.builderBlock,
|
|
45
|
-
context: props.context,
|
|
46
|
-
wrapperProps: props.componentOptions,
|
|
47
|
-
shouldNestAttributes: true,
|
|
48
|
-
};
|
|
49
|
-
return props.isRSC
|
|
50
|
-
? {
|
|
51
|
-
...props.componentOptions,
|
|
52
|
-
/**
|
|
53
|
-
* If `noWrap` is set to `true`, then the block's props/attributes are provided to the * component itself directly. Otherwise, they are provided to the wrapper element. */ ...(props.includeBlockProps
|
|
54
|
-
? {
|
|
55
|
-
attributes: (0, get_block_properties_js_1.getBlockProperties)({
|
|
56
|
-
block: props.builderBlock,
|
|
57
|
-
context: props.context,
|
|
58
|
-
}),
|
|
59
|
-
}
|
|
60
|
-
: {}),
|
|
61
|
-
}
|
|
62
|
-
: blockWrapperProps;
|
|
63
|
-
}
|
|
64
|
-
return (React.createElement(builder_context_js_1.default.Provider, { value: {
|
|
65
|
-
content: props.context.content,
|
|
66
|
-
rootState: props.context.rootState,
|
|
67
|
-
localState: props.context.localState,
|
|
68
|
-
context: props.context.context,
|
|
69
|
-
apiKey: props.context.apiKey,
|
|
70
|
-
componentInfos: props.context.componentInfos,
|
|
71
|
-
inheritedStyles: props.context.inheritedStyles,
|
|
72
|
-
apiVersion: props.context.apiVersion,
|
|
73
|
-
} },
|
|
74
|
-
React.createElement(Wrapper, { ...wrapperProps() },
|
|
75
|
-
" ", (_a = props.blockChildren) === null || _a === void 0 ? void 0 :
|
|
76
|
-
_a.map((child) => (React.createElement(block_1.default, { key: "block-" + child.id, block: child, context: props.context, registeredComponents: props.registeredComponents }))),
|
|
77
|
-
" ", (_b = props.blockChildren) === null || _b === void 0 ? void 0 :
|
|
78
|
-
_b.map((child) => (React.createElement(block_styles_1.default, { key: "block-style-" + child.id, block: child, context: props.context }))),
|
|
79
|
-
" ")));
|
|
80
|
-
}
|
|
81
|
-
exports.default = ComponentRef;
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
'use client';
|
|
3
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
4
|
-
if (k2 === undefined) k2 = k;
|
|
5
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
6
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
7
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
8
|
-
}
|
|
9
|
-
Object.defineProperty(o, k2, desc);
|
|
10
|
-
}) : (function(o, m, k, k2) {
|
|
11
|
-
if (k2 === undefined) k2 = k;
|
|
12
|
-
o[k2] = m[k];
|
|
13
|
-
}));
|
|
14
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
15
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
16
|
-
}) : function(o, v) {
|
|
17
|
-
o["default"] = v;
|
|
18
|
-
});
|
|
19
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
20
|
-
if (mod && mod.__esModule) return mod;
|
|
21
|
-
var result = {};
|
|
22
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
23
|
-
__setModuleDefault(result, mod);
|
|
24
|
-
return result;
|
|
25
|
-
};
|
|
26
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
27
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
28
|
-
};
|
|
29
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
30
|
-
const React = __importStar(require("react"));
|
|
31
|
-
const react_native_1 = require("react-native");
|
|
32
|
-
const block_styles_1 = __importDefault(require("./block-styles"));
|
|
33
|
-
const block_1 = __importDefault(require("../block"));
|
|
34
|
-
function Component(props) {
|
|
35
|
-
var _a, _b;
|
|
36
|
-
return (React.createElement(React.Fragment, null, props.componentRef ? (React.createElement(React.Fragment, null,
|
|
37
|
-
React.createElement(props.componentRef, { ...props.componentOptions }, (_a = props.blockChildren) === null || _a === void 0 ? void 0 :
|
|
38
|
-
_a.map((child) => (React.createElement(block_1.default, { key: "render-block-" + child.id, block: child, context: props.context, components: props.components }))), (_b = props.blockChildren) === null || _b === void 0 ? void 0 :
|
|
39
|
-
_b.map((child) => (React.createElement(block_styles_1.default, { key: "block-style-" + child.id, block: child, context: props.context })))))) : null));
|
|
40
|
-
}
|
|
41
|
-
exports.default = Component;
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getBlockProps = void 0;
|
|
4
|
-
var __defProp = Object.defineProperty;
|
|
5
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
6
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
8
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
9
|
-
var __spreadValues = (a, b) => {
|
|
10
|
-
for (var prop in b || (b = {}))
|
|
11
|
-
if (__hasOwnProp.call(b, prop))
|
|
12
|
-
__defNormalProp(a, prop, b[prop]);
|
|
13
|
-
if (__getOwnPropSymbols)
|
|
14
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
15
|
-
if (__propIsEnum.call(b, prop))
|
|
16
|
-
__defNormalProp(a, prop, b[prop]);
|
|
17
|
-
}
|
|
18
|
-
return a;
|
|
19
|
-
};
|
|
20
|
-
const get_block_actions_1 = require("../../../../functions/get-block-actions");
|
|
21
|
-
const get_block_properties_1 = require("../../../../functions/get-block-properties");
|
|
22
|
-
const getBlockProps = ({ block, contextValue }) => {
|
|
23
|
-
const blockProps = __spreadValues(__spreadValues({}, (0, get_block_properties_1.getBlockProperties)({
|
|
24
|
-
block,
|
|
25
|
-
context: contextValue
|
|
26
|
-
})), (0, get_block_actions_1.getBlockActions)({
|
|
27
|
-
block,
|
|
28
|
-
rootState: contextValue.rootState,
|
|
29
|
-
rootSetState: contextValue.rootSetState,
|
|
30
|
-
localState: contextValue.localState,
|
|
31
|
-
context: contextValue.context
|
|
32
|
-
}));
|
|
33
|
-
return blockProps;
|
|
34
|
-
};
|
|
35
|
-
exports.getBlockProps = getBlockProps;
|