@builder.io/sdk-react-native 0.2.3 → 0.4.0
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/dist/blocks/button/button.js +1 -0
- package/dist/blocks/columns/columns.js +2 -1
- package/dist/blocks/custom-code/custom-code.js +1 -0
- package/dist/blocks/embed/embed.js +1 -0
- package/dist/blocks/form/form.js +1 -0
- package/dist/blocks/fragment/fragment.js +1 -0
- package/dist/blocks/img/img.js +1 -0
- package/dist/blocks/input/input.js +1 -0
- package/dist/blocks/raw-text/raw-text.js +1 -0
- package/dist/blocks/section/section.js +1 -0
- package/dist/blocks/select/select.js +1 -0
- package/dist/blocks/submit-button/submit-button.js +1 -0
- package/dist/blocks/symbol/symbol.js +2 -1
- package/dist/blocks/textarea/textarea.js +1 -0
- package/dist/components/render-block/block-styles.js +4 -1
- package/dist/components/render-block/render-block.helpers.js +8 -20
- package/dist/components/render-block/render-block.js +28 -21
- package/dist/components/render-block/render-component.js +4 -3
- package/dist/components/render-block/render-repeated-block.js +4 -2
- package/dist/components/render-blocks.js +1 -0
- package/dist/components/render-content/builder-editing.js +1 -0
- package/dist/components/render-content/components/render-styles.js +2 -1
- package/dist/components/render-content/render-content.js +48 -10
- package/dist/components/render-content/wrap-component-ref.js +5 -0
- package/dist/components/render-content-variants/helpers.js +137 -0
- package/dist/components/render-content-variants/render-content-variants.js +73 -0
- package/dist/components/render-inlined-styles.js +2 -12
- package/dist/constants/sdk-version.js +4 -0
- package/dist/context/builder.context.js +3 -2
- package/dist/functions/evaluate.js +25 -3
- package/dist/functions/evaluate.test.js +19 -0
- package/dist/functions/get-block-actions-handler.js +3 -1
- package/dist/functions/get-content/generate-content-url.js +2 -2
- package/dist/functions/get-content/generate-content-url.test.js +15 -0
- package/dist/functions/get-content/index.js +36 -19
- package/dist/functions/get-processed-block.js +16 -4
- package/dist/functions/get-processed-block.test.js +3 -1
- package/dist/helpers/ab-tests.js +123 -6
- package/dist/helpers/canTrack.js +6 -0
- package/dist/helpers/cookie.js +9 -2
- package/dist/helpers/logger.js +2 -1
- package/dist/index.js +17 -10
- package/dist/scripts/init-editing.js +2 -0
- package/package.json +2 -5
- package/src/blocks/button/button.jsx +1 -0
- package/src/blocks/columns/columns.jsx +2 -1
- package/src/blocks/custom-code/custom-code.jsx +1 -0
- package/src/blocks/embed/embed.jsx +1 -0
- package/src/blocks/form/form.jsx +1 -0
- package/src/blocks/fragment/fragment.jsx +1 -0
- package/src/blocks/img/img.jsx +1 -0
- package/src/blocks/input/input.jsx +1 -0
- package/src/blocks/raw-text/raw-text.jsx +1 -0
- package/src/blocks/section/section.jsx +1 -0
- package/src/blocks/select/select.jsx +1 -0
- package/src/blocks/submit-button/submit-button.jsx +1 -0
- package/src/blocks/symbol/symbol.jsx +2 -1
- package/src/blocks/textarea/textarea.jsx +1 -0
- package/src/components/render-block/block-styles.jsx +4 -1
- package/src/components/render-block/render-block.helpers.js +7 -19
- package/src/components/render-block/render-block.jsx +24 -23
- package/src/components/render-block/render-component.jsx +5 -5
- package/src/components/render-block/render-repeated-block.jsx +4 -2
- package/src/components/render-blocks.jsx +1 -0
- package/src/components/render-content/builder-editing.jsx +1 -0
- package/src/components/render-content/components/render-styles.jsx +4 -3
- package/src/components/render-content/render-content.jsx +54 -9
- package/src/components/render-content/wrap-component-ref.js +4 -0
- package/src/components/render-content-variants/helpers.js +139 -0
- package/src/components/render-content-variants/render-content-variants.jsx +101 -0
- package/src/components/render-inlined-styles.jsx +2 -22
- package/src/constants/sdk-version.js +1 -0
- package/src/context/builder.context.js +3 -2
- package/src/functions/evaluate.js +27 -3
- package/src/functions/evaluate.test.js +17 -0
- package/src/functions/get-block-actions-handler.js +3 -1
- package/src/functions/get-content/generate-content-url.js +2 -1
- package/src/functions/get-content/generate-content-url.test.js +15 -0
- package/src/functions/get-content/index.js +35 -18
- package/src/functions/get-processed-block.js +20 -4
- package/src/functions/get-processed-block.test.js +3 -1
- package/src/helpers/ab-tests.js +132 -10
- package/src/helpers/canTrack.js +5 -0
- package/src/helpers/cookie.js +9 -2
- package/src/helpers/logger.js +2 -1
- package/src/index.js +18 -7
- package/src/scripts/init-editing.js +2 -0
- package/src/functions/get-content/ab-testing.js +0 -99
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
var __async = (__this, __arguments, generator) => {
|
|
2
|
-
return new Promise((resolve, reject) => {
|
|
3
|
-
var fulfilled = (value) => {
|
|
4
|
-
try {
|
|
5
|
-
step(generator.next(value));
|
|
6
|
-
} catch (e) {
|
|
7
|
-
reject(e);
|
|
8
|
-
}
|
|
9
|
-
};
|
|
10
|
-
var rejected = (value) => {
|
|
11
|
-
try {
|
|
12
|
-
step(generator.throw(value));
|
|
13
|
-
} catch (e) {
|
|
14
|
-
reject(e);
|
|
15
|
-
}
|
|
16
|
-
};
|
|
17
|
-
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
18
|
-
step((generator = generator.apply(__this, __arguments)).next());
|
|
19
|
-
});
|
|
20
|
-
};
|
|
21
|
-
import {
|
|
22
|
-
getContentVariationCookie,
|
|
23
|
-
setContentVariationCookie
|
|
24
|
-
} from "../../helpers/ab-tests.js";
|
|
25
|
-
import { checkIsDefined } from "../../helpers/nullable.js";
|
|
26
|
-
const checkIsBuilderContentWithVariations = (item) => checkIsDefined(item.id) && checkIsDefined(item.variations) && Object.keys(item.variations).length > 0;
|
|
27
|
-
const getRandomVariationId = ({
|
|
28
|
-
id,
|
|
29
|
-
variations
|
|
30
|
-
}) => {
|
|
31
|
-
var _a;
|
|
32
|
-
let n = 0;
|
|
33
|
-
const random = Math.random();
|
|
34
|
-
for (const id2 in variations) {
|
|
35
|
-
const testRatio = (_a = variations[id2]) == null ? void 0 : _a.testRatio;
|
|
36
|
-
n += testRatio;
|
|
37
|
-
if (random < n) {
|
|
38
|
-
return id2;
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
return id;
|
|
42
|
-
};
|
|
43
|
-
const getTestFields = ({
|
|
44
|
-
item,
|
|
45
|
-
testGroupId
|
|
46
|
-
}) => {
|
|
47
|
-
const variationValue = item.variations[testGroupId];
|
|
48
|
-
if (testGroupId === item.id || !variationValue) {
|
|
49
|
-
return {
|
|
50
|
-
testVariationId: item.id,
|
|
51
|
-
testVariationName: "Default"
|
|
52
|
-
};
|
|
53
|
-
} else {
|
|
54
|
-
return {
|
|
55
|
-
data: variationValue.data,
|
|
56
|
-
testVariationId: variationValue.id,
|
|
57
|
-
testVariationName: variationValue.name || (variationValue.id === item.id ? "Default" : "")
|
|
58
|
-
};
|
|
59
|
-
}
|
|
60
|
-
};
|
|
61
|
-
const getContentVariation = (_0) => __async(void 0, [_0], function* ({
|
|
62
|
-
item,
|
|
63
|
-
canTrack
|
|
64
|
-
}) {
|
|
65
|
-
const testGroupId = yield getContentVariationCookie({
|
|
66
|
-
canTrack,
|
|
67
|
-
contentId: item.id
|
|
68
|
-
});
|
|
69
|
-
const testFields = testGroupId ? getTestFields({ item, testGroupId }) : void 0;
|
|
70
|
-
if (testFields) {
|
|
71
|
-
return testFields;
|
|
72
|
-
} else {
|
|
73
|
-
const randomVariationId = getRandomVariationId({
|
|
74
|
-
variations: item.variations,
|
|
75
|
-
id: item.id
|
|
76
|
-
});
|
|
77
|
-
setContentVariationCookie({
|
|
78
|
-
contentId: item.id,
|
|
79
|
-
value: randomVariationId,
|
|
80
|
-
canTrack
|
|
81
|
-
}).catch((err) => {
|
|
82
|
-
console.error("could not store A/B test variation: ", err);
|
|
83
|
-
});
|
|
84
|
-
return getTestFields({ item, testGroupId: randomVariationId });
|
|
85
|
-
}
|
|
86
|
-
});
|
|
87
|
-
const handleABTesting = (_0) => __async(void 0, [_0], function* ({
|
|
88
|
-
item,
|
|
89
|
-
canTrack
|
|
90
|
-
}) {
|
|
91
|
-
if (!checkIsBuilderContentWithVariations(item)) {
|
|
92
|
-
return;
|
|
93
|
-
}
|
|
94
|
-
const variationValue = yield getContentVariation({ item, canTrack });
|
|
95
|
-
Object.assign(item, variationValue);
|
|
96
|
-
});
|
|
97
|
-
export {
|
|
98
|
-
handleABTesting
|
|
99
|
-
};
|