@builder.io/sdk-react-native 0.0.1-5 → 0.0.1-50
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/CHANGELOG.md +14 -0
- package/README.md +15 -0
- package/package.json +6 -4
- package/src/blocks/button.js +5 -6
- package/src/blocks/button.lite.tsx +7 -11
- package/src/blocks/columns.js +32 -16
- package/src/blocks/columns.lite.tsx +39 -16
- package/src/blocks/custom-code.js +1 -2
- package/src/blocks/custom-code.lite.tsx +2 -10
- package/src/blocks/embed.js +1 -2
- package/src/blocks/embed.lite.tsx +2 -6
- package/src/blocks/form.js +11 -15
- package/src/blocks/form.lite.tsx +18 -22
- package/src/blocks/fragment.js +13 -0
- package/src/blocks/fragment.lite.tsx +10 -0
- package/src/blocks/image.js +27 -7
- package/src/blocks/image.lite.tsx +42 -10
- package/src/blocks/img.js +3 -3
- package/src/blocks/img.lite.tsx +2 -3
- package/src/blocks/input.js +3 -3
- package/src/blocks/input.lite.tsx +2 -5
- package/src/blocks/raw-text.js +1 -3
- package/src/blocks/raw-text.lite.tsx +1 -7
- package/src/blocks/section.js +3 -3
- package/src/blocks/section.lite.tsx +1 -2
- package/src/blocks/select.js +7 -6
- package/src/blocks/select.lite.tsx +6 -7
- package/src/blocks/submit-button.js +3 -3
- package/src/blocks/submit-button.lite.tsx +1 -2
- package/src/blocks/symbol.js +65 -12
- package/src/blocks/symbol.lite.tsx +44 -4
- package/src/blocks/text.js +57 -1
- package/src/blocks/text.lite.tsx +1 -7
- package/src/blocks/textarea.js +1 -1
- package/src/blocks/textarea.lite.tsx +0 -1
- package/src/blocks/video.js +90 -44
- package/src/blocks/video.lite.tsx +0 -1
- package/src/components/block-styles.js +7 -0
- package/src/components/block-styles.lite.tsx +6 -0
- package/src/components/error-boundary.js +25 -0
- package/src/components/error-boundary.lite.tsx +6 -0
- package/src/components/render-block.js +43 -19
- package/src/components/render-block.lite.tsx +69 -34
- package/src/components/render-blocks.js +12 -5
- package/src/components/render-blocks.lite.tsx +16 -7
- package/src/components/render-content.js +224 -24
- package/src/components/render-content.lite.tsx +247 -34
- package/src/context/builder.context.js +6 -1
- package/src/functions/evaluate.js +15 -6
- package/src/functions/event-handler-name.js +8 -0
- package/src/functions/get-block-actions.js +13 -12
- package/src/functions/get-block-component-options.js +17 -1
- package/src/functions/get-block-properties.js +7 -4
- package/src/functions/get-block-styles.js +31 -1
- package/src/functions/get-builder-search-params/fn.test.js +14 -0
- package/src/functions/get-builder-search-params/index.js +23 -0
- package/src/functions/get-content/fn.test.js +32 -0
- package/src/functions/get-content/index.js +138 -0
- package/src/functions/get-fetch.js +13 -0
- package/src/functions/get-global-this.js +19 -0
- package/src/functions/get-processed-block.js +3 -1
- package/src/functions/get-processed-block.test.js +12 -7
- package/src/functions/get-target.js +1 -1
- package/src/functions/is-browser.js +1 -2
- package/src/functions/is-previewing.js +15 -0
- package/src/functions/is-react-native.js +1 -1
- package/src/functions/on-change.test.js +0 -1
- package/src/functions/previewing-model-name.js +12 -0
- package/src/functions/register-component.js +1 -0
- package/src/functions/register.js +30 -0
- package/src/functions/set-editor-settings.js +16 -0
- package/src/functions/set.test.js +0 -1
- package/src/functions/track.js +5 -1
- package/src/functions/transform-block.js +38 -0
- package/src/index-helpers/blocks-exports.js +19 -0
- package/src/index-helpers/top-of-file.js +2 -0
- package/src/index.js +8 -18
- package/src/scripts/init-editing.js +18 -2
- package/src/types/deep-partial.js +1 -0
- package/src/types/typescript.js +1 -0
- package/index.js +0 -11
- package/src/functions/get-content.js +0 -103
- package/src/package.json +0 -18
|
@@ -1,12 +1,28 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
var _a;
|
|
3
|
-
import { getTarget } from "../functions/get-target";
|
|
4
3
|
import { isBrowser } from "../functions/is-browser";
|
|
4
|
+
import { register } from "../functions/register";
|
|
5
|
+
register("insertMenu", {
|
|
6
|
+
name: "_default",
|
|
7
|
+
default: true,
|
|
8
|
+
items: [
|
|
9
|
+
{ name: "Box" },
|
|
10
|
+
{ name: "Text" },
|
|
11
|
+
{ name: "Image" },
|
|
12
|
+
{ name: "Columns" },
|
|
13
|
+
...true ? [] : [
|
|
14
|
+
{ name: "Core:Section" },
|
|
15
|
+
{ name: "Core:Button" },
|
|
16
|
+
{ name: "Embed" },
|
|
17
|
+
{ name: "Custom Code" }
|
|
18
|
+
]
|
|
19
|
+
]
|
|
20
|
+
});
|
|
5
21
|
if (isBrowser()) {
|
|
6
22
|
(_a = window.parent) == null ? void 0 : _a.postMessage({
|
|
7
23
|
type: "builder.sdkInfo",
|
|
8
24
|
data: {
|
|
9
|
-
target:
|
|
25
|
+
target: "reactNative",
|
|
10
26
|
supportsPatchUpdates: false
|
|
11
27
|
}
|
|
12
28
|
}, "*");
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import * as React from 'react';
|
package/index.js
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { isEditing } from './src/functions/is-editing';
|
|
2
|
-
|
|
3
|
-
if (isEditing()) {
|
|
4
|
-
import('./src/scripts/init-editing');
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
// TODO: lazy option
|
|
8
|
-
export { default as Columns } from './src/blocks/columns';
|
|
9
|
-
export { default as Image } from './src/blocks/image';
|
|
10
|
-
export { default as Text } from './src/blocks/text';
|
|
11
|
-
export { default as RenderContent } from './src/components/render-content';
|
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __defProps = Object.defineProperties;
|
|
4
|
-
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
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
|
-
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
21
|
-
var __async = (__this, __arguments, generator) => {
|
|
22
|
-
return new Promise((resolve, reject) => {
|
|
23
|
-
var fulfilled = (value) => {
|
|
24
|
-
try {
|
|
25
|
-
step(generator.next(value));
|
|
26
|
-
} catch (e) {
|
|
27
|
-
reject(e);
|
|
28
|
-
}
|
|
29
|
-
};
|
|
30
|
-
var rejected = (value) => {
|
|
31
|
-
try {
|
|
32
|
-
step(generator.throw(value));
|
|
33
|
-
} catch (e) {
|
|
34
|
-
reject(e);
|
|
35
|
-
}
|
|
36
|
-
};
|
|
37
|
-
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
38
|
-
step((generator = generator.apply(__this, __arguments)).next());
|
|
39
|
-
});
|
|
40
|
-
};
|
|
41
|
-
import { isBrowser } from "./is-browser";
|
|
42
|
-
import { isReactNative } from "./is-react-native";
|
|
43
|
-
if (!(isBrowser() || isReactNative())) {
|
|
44
|
-
import("node-fetch");
|
|
45
|
-
}
|
|
46
|
-
function getContent(options) {
|
|
47
|
-
return __async(this, null, function* () {
|
|
48
|
-
return (yield getAllContent(__spreadProps(__spreadValues({}, options), { limit: 1 }))).results[0] || null;
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
function getAllContent(options) {
|
|
52
|
-
return __async(this, null, function* () {
|
|
53
|
-
const { model, apiKey } = options;
|
|
54
|
-
const { limit, testGroups, userAttributes } = __spreadValues({
|
|
55
|
-
limit: 1,
|
|
56
|
-
userAttributes: null,
|
|
57
|
-
testGroups: null
|
|
58
|
-
}, options);
|
|
59
|
-
const content = yield fetch(`https://cdn.builder.io/api/v2/content/${model}?apiKey=${apiKey}&limit=${limit}&userAttributes=${JSON.stringify(userAttributes)}`).then((res) => res.json());
|
|
60
|
-
if (testGroups) {
|
|
61
|
-
for (const item of content) {
|
|
62
|
-
if (item.variations && Object.keys(item.variations).length) {
|
|
63
|
-
const testGroup = testGroups[item.id];
|
|
64
|
-
const variationValue = item.variations[testGroup];
|
|
65
|
-
if (testGroup && variationValue) {
|
|
66
|
-
item.data = variationValue.data;
|
|
67
|
-
item.testVariationId = variationValue.id;
|
|
68
|
-
item.testVariationName = variationValue.name;
|
|
69
|
-
} else {
|
|
70
|
-
let n = 0;
|
|
71
|
-
const random = Math.random();
|
|
72
|
-
let set = false;
|
|
73
|
-
for (const id in item.variations) {
|
|
74
|
-
const variation = item.variations[id];
|
|
75
|
-
const testRatio = variation.testRatio;
|
|
76
|
-
n += testRatio;
|
|
77
|
-
if (random < n) {
|
|
78
|
-
const variationName = variation.name || (variation.id === item.id ? "Default variation" : "");
|
|
79
|
-
set = true;
|
|
80
|
-
Object.assign(item, {
|
|
81
|
-
data: variation.data,
|
|
82
|
-
testVariationId: variation.id,
|
|
83
|
-
testVariationName: variationName
|
|
84
|
-
});
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
if (!set) {
|
|
88
|
-
Object.assign(item, {
|
|
89
|
-
testVariationId: item.id,
|
|
90
|
-
testVariationName: "Default"
|
|
91
|
-
});
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
return content;
|
|
98
|
-
});
|
|
99
|
-
}
|
|
100
|
-
export {
|
|
101
|
-
getAllContent,
|
|
102
|
-
getContent
|
|
103
|
-
};
|
package/src/package.json
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@builder.io/sdk-react-native",
|
|
3
|
-
"description": "Builder.io SDK for React Native",
|
|
4
|
-
"version": "0.0.1-1",
|
|
5
|
-
"main": "src/index.js",
|
|
6
|
-
"scripts": {
|
|
7
|
-
"release:dev": "npm version prerelease --no-git-tag-version && npm publish --tag dev --access public"
|
|
8
|
-
},
|
|
9
|
-
"dependencies": {
|
|
10
|
-
"react-native-render-html": "^5.1.1"
|
|
11
|
-
},
|
|
12
|
-
"peerDependencies": {
|
|
13
|
-
"react-native": "^0.64.2"
|
|
14
|
-
},
|
|
15
|
-
"devDependencies": {
|
|
16
|
-
"react-native": "^0.64.2"
|
|
17
|
-
}
|
|
18
|
-
}
|