@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.
- 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/acorn-interpreter.js +3101 -0
- package/dist/functions/evaluate/evaluate.js +2 -2
- package/dist/functions/evaluate/non-node-runtime/index.js +44 -0
- package/dist/functions/evaluate/{non-node-runtime.js → non-node-runtime/non-node-runtime.js} +4 -4
- package/package.json +12 -3
- package/src/components/content-variants/content-variants.jsx +13 -8
- package/src/constants/sdk-version.js +2 -1
- package/src/functions/evaluate/acorn-interpreter.js +2876 -0
- package/src/functions/evaluate/evaluate.js +1 -1
- package/src/functions/evaluate/non-node-runtime/index.js +18 -0
- package/src/functions/evaluate/{non-node-runtime.js → non-node-runtime/non-node-runtime.js} +3 -3
- package/dist/functions/evaluate/acorn.js +0 -1691
- package/dist/functions/evaluate/interpreter.js +0 -2903
- package/src/functions/evaluate/acorn.js +0 -1595
- package/src/functions/evaluate/interpreter.js +0 -2801
|
@@ -5,7 +5,7 @@ const logger_js_1 = require("../../helpers/logger.js");
|
|
|
5
5
|
const is_browser_js_1 = require("../is-browser.js");
|
|
6
6
|
const is_editing_js_1 = require("../is-editing.js");
|
|
7
7
|
const is_non_node_server_js_1 = require("../is-non-node-server.js");
|
|
8
|
-
const
|
|
8
|
+
const index_js_1 = require("./non-node-runtime/index.js");
|
|
9
9
|
function evaluate({ code, context, localState, rootState, rootSetState, event, isExpression = true }) {
|
|
10
10
|
if (code === "") {
|
|
11
11
|
logger_js_1.logger.warn("Skipping evaluation of empty code block.");
|
|
@@ -30,7 +30,7 @@ function evaluate({ code, context, localState, rootState, rootSetState, event, i
|
|
|
30
30
|
if ((0, is_browser_js_1.isBrowser)())
|
|
31
31
|
return runInBrowser(args);
|
|
32
32
|
if ((0, is_non_node_server_js_1.isNonNodeServer)())
|
|
33
|
-
return (0,
|
|
33
|
+
return (0, index_js_1.runInNonNode)(args);
|
|
34
34
|
return runInNode(args);
|
|
35
35
|
}
|
|
36
36
|
exports.evaluate = evaluate;
|
|
@@ -0,0 +1,44 @@
|
|
|
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
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.runInNonNode = void 0;
|
|
27
|
+
const logger_js_1 = require("../../../helpers/logger.js");
|
|
28
|
+
const is_non_node_server_js_1 = require("../../is-non-node-server.js");
|
|
29
|
+
let runInNonNode;
|
|
30
|
+
exports.runInNonNode = runInNonNode;
|
|
31
|
+
if ((0, is_non_node_server_js_1.isNonNodeServer)()) {
|
|
32
|
+
Promise.resolve().then(() => __importStar(require("./non-node-runtime.js"))).then(m => {
|
|
33
|
+
exports.runInNonNode = runInNonNode = m.runInNonNode;
|
|
34
|
+
}).catch(err => {
|
|
35
|
+
const ERROR_MESSAGE = `Error importing JS interpreter for non-Node.js runtimes. Make sure \`js-interpreter\` is installed.
|
|
36
|
+
Read more here: https://github.com/BuilderIO/builder/tree/main/packages/sdks/README.md#non-nodejs-runtimes-edge-serverless
|
|
37
|
+
`;
|
|
38
|
+
logger_js_1.logger.error(ERROR_MESSAGE, err);
|
|
39
|
+
exports.runInNonNode = runInNonNode = (..._args) => {
|
|
40
|
+
logger_js_1.logger.error(ERROR_MESSAGE);
|
|
41
|
+
return void 0;
|
|
42
|
+
};
|
|
43
|
+
});
|
|
44
|
+
}
|
package/dist/functions/evaluate/{non-node-runtime.js → non-node-runtime/non-node-runtime.js}
RENAMED
|
@@ -25,9 +25,9 @@ var __spreadValues = (a, b) => {
|
|
|
25
25
|
}
|
|
26
26
|
return a;
|
|
27
27
|
};
|
|
28
|
-
const logger_1 = require("
|
|
29
|
-
const set_1 = require("
|
|
30
|
-
const
|
|
28
|
+
const logger_1 = require("../../../helpers/logger");
|
|
29
|
+
const set_1 = require("../../set");
|
|
30
|
+
const acorn_interpreter_js_1 = __importDefault(require("../acorn-interpreter.js"));
|
|
31
31
|
const processCode = code => {
|
|
32
32
|
return code.split("\n").map(line => {
|
|
33
33
|
const trimmed = line.trim();
|
|
@@ -82,7 +82,7 @@ theFunction();
|
|
|
82
82
|
interpreter.setProperty(globalObject, "setRootState", interpreter.createNativeFunction(setRootState));
|
|
83
83
|
};
|
|
84
84
|
try {
|
|
85
|
-
const myInterpreter = new
|
|
85
|
+
const myInterpreter = new acorn_interpreter_js_1.default(transformed, initFunc);
|
|
86
86
|
myInterpreter.run();
|
|
87
87
|
const output = myInterpreter.pseudoToNative(myInterpreter.value);
|
|
88
88
|
return output;
|
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.4",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
7
7
|
"module": "./dist/index.js",
|
|
@@ -23,14 +23,23 @@
|
|
|
23
23
|
"react-native-video": "^5.1.1"
|
|
24
24
|
},
|
|
25
25
|
"peerDependencies": {
|
|
26
|
-
"react
|
|
26
|
+
"react": "^18.0.0",
|
|
27
|
+
"react-dom": "^18.0.0",
|
|
28
|
+
"react-native": ">=0.64.3",
|
|
27
29
|
"react-native-url-polyfill": "^1.3.0"
|
|
28
30
|
},
|
|
29
31
|
"devDependencies": {
|
|
30
32
|
"@tsconfig/react-native": "^2.0.3",
|
|
31
33
|
"@types/react-native-video": "^5.0.9",
|
|
34
|
+
"nx": "^16.6.0",
|
|
35
|
+
"nx-cloud": "^16.2.0",
|
|
32
36
|
"react-native-url-polyfill": "^1.3.0",
|
|
33
37
|
"rimraf": "^3.0.2",
|
|
34
|
-
"typescript": "^
|
|
38
|
+
"typescript": "^4.9.4"
|
|
39
|
+
},
|
|
40
|
+
"nx": {
|
|
41
|
+
"implicitDependencies": [
|
|
42
|
+
"@builder.io/sdks"
|
|
43
|
+
]
|
|
35
44
|
}
|
|
36
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 }
|