@builder.io/sdk-react-native 0.3.1 → 0.4.1

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 (72) hide show
  1. package/dist/blocks/button/button.js +1 -0
  2. package/dist/blocks/columns/columns.js +1 -0
  3. package/dist/blocks/custom-code/custom-code.js +1 -0
  4. package/dist/blocks/embed/embed.js +1 -0
  5. package/dist/blocks/form/form.js +1 -0
  6. package/dist/blocks/fragment/fragment.js +1 -0
  7. package/dist/blocks/img/img.js +1 -0
  8. package/dist/blocks/input/input.js +1 -0
  9. package/dist/blocks/raw-text/raw-text.js +1 -0
  10. package/dist/blocks/section/section.js +1 -0
  11. package/dist/blocks/select/select.js +1 -0
  12. package/dist/blocks/submit-button/submit-button.js +1 -0
  13. package/dist/blocks/symbol/symbol.js +1 -0
  14. package/dist/blocks/textarea/textarea.js +1 -0
  15. package/dist/components/render-block/block-styles.js +1 -0
  16. package/dist/components/render-block/render-block.js +7 -6
  17. package/dist/components/render-block/render-component.js +2 -2
  18. package/dist/components/render-block/render-repeated-block.js +1 -0
  19. package/dist/components/render-blocks.js +1 -0
  20. package/dist/components/render-content/builder-editing.js +1 -0
  21. package/dist/components/render-content/components/render-styles.js +2 -1
  22. package/dist/components/render-content/render-content.js +36 -3
  23. package/dist/components/render-content/wrap-component-ref.js +5 -0
  24. package/dist/components/render-content-variants/helpers.js +137 -0
  25. package/dist/components/render-content-variants/render-content-variants.js +73 -0
  26. package/dist/components/render-inlined-styles.js +2 -12
  27. package/dist/constants/sdk-version.js +1 -1
  28. package/dist/functions/get-content/generate-content-url.js +2 -2
  29. package/dist/functions/get-content/generate-content-url.test.js +15 -0
  30. package/dist/functions/get-content/index.js +36 -19
  31. package/dist/helpers/ab-tests.js +123 -6
  32. package/dist/helpers/canTrack.js +6 -0
  33. package/dist/helpers/cookie.js +9 -2
  34. package/dist/helpers/logger.js +2 -1
  35. package/dist/index.js +19 -10
  36. package/package.json +1 -1
  37. package/src/blocks/button/button.jsx +1 -0
  38. package/src/blocks/columns/columns.jsx +1 -0
  39. package/src/blocks/custom-code/custom-code.jsx +1 -0
  40. package/src/blocks/embed/embed.jsx +1 -0
  41. package/src/blocks/form/form.jsx +1 -0
  42. package/src/blocks/fragment/fragment.jsx +1 -0
  43. package/src/blocks/img/img.jsx +1 -0
  44. package/src/blocks/input/input.jsx +1 -0
  45. package/src/blocks/raw-text/raw-text.jsx +1 -0
  46. package/src/blocks/section/section.jsx +1 -0
  47. package/src/blocks/select/select.jsx +1 -0
  48. package/src/blocks/submit-button/submit-button.jsx +1 -0
  49. package/src/blocks/symbol/symbol.jsx +1 -0
  50. package/src/blocks/textarea/textarea.jsx +1 -0
  51. package/src/components/render-block/block-styles.jsx +1 -0
  52. package/src/components/render-block/render-block.jsx +8 -7
  53. package/src/components/render-block/render-component.jsx +3 -4
  54. package/src/components/render-block/render-repeated-block.jsx +1 -0
  55. package/src/components/render-blocks.jsx +1 -0
  56. package/src/components/render-content/builder-editing.jsx +1 -0
  57. package/src/components/render-content/components/render-styles.jsx +4 -3
  58. package/src/components/render-content/render-content.jsx +42 -2
  59. package/src/components/render-content/wrap-component-ref.js +4 -0
  60. package/src/components/render-content-variants/helpers.js +139 -0
  61. package/src/components/render-content-variants/render-content-variants.jsx +101 -0
  62. package/src/components/render-inlined-styles.jsx +2 -22
  63. package/src/constants/sdk-version.js +1 -1
  64. package/src/functions/get-content/generate-content-url.js +2 -1
  65. package/src/functions/get-content/generate-content-url.test.js +15 -0
  66. package/src/functions/get-content/index.js +35 -18
  67. package/src/helpers/ab-tests.js +132 -10
  68. package/src/helpers/canTrack.js +5 -0
  69. package/src/helpers/cookie.js +9 -2
  70. package/src/helpers/logger.js +2 -1
  71. package/src/index.js +20 -7
  72. package/src/functions/get-content/ab-testing.js +0 -99
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getContent = exports.getAllContent = void 0;
3
+ exports.processContentResult = exports.getContent = exports.getAllContent = void 0;
4
4
  var __defProp = Object.defineProperty;
5
5
  var __defProps = Object.defineProperties;
6
6
  var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
@@ -42,42 +42,59 @@ var __async = (__this, __arguments, generator) => {
42
42
  step((generator = generator.apply(__this, __arguments)).next());
43
43
  });
44
44
  };
45
+ const target_js_1 = require("../../constants/target.js");
46
+ const ab_tests_js_1 = require("../../helpers/ab-tests.js");
47
+ const canTrack_js_1 = require("../../helpers/canTrack.js");
45
48
  const logger_js_1 = require("../../helpers/logger.js");
46
49
  const get_fetch_js_1 = require("../get-fetch.js");
47
- const ab_testing_js_1 = require("./ab-testing.js");
50
+ const is_browser_js_1 = require("../is-browser.js");
48
51
  const generate_content_url_js_1 = require("./generate-content-url.js");
52
+ const checkContentHasResults = (content) => "results" in content;
49
53
  function getContent(options) {
50
54
  return __async(this, null, function* () {
51
55
  const allContent = yield getAllContent(__spreadProps(__spreadValues({}, options), { limit: 1 }));
52
- if (allContent && "results" in allContent) {
53
- return (allContent == null ? void 0 : allContent.results[0]) || null;
56
+ if (allContent && checkContentHasResults(allContent)) {
57
+ return allContent.results[0] || null;
54
58
  }
55
59
  return null;
56
60
  });
57
61
  }
58
62
  exports.getContent = getContent;
63
+ const fetchContent = (options) => __async(void 0, null, function* () {
64
+ const url = (0, generate_content_url_js_1.generateContentUrl)(options);
65
+ const res = yield (0, get_fetch_js_1.fetch)(url.href);
66
+ const content = yield res.json();
67
+ return content;
68
+ });
69
+ const processContentResult = (options, content) => __async(void 0, null, function* () {
70
+ const canTrack = (0, canTrack_js_1.getDefaultCanTrack)(options.canTrack);
71
+ if (!canTrack)
72
+ return content;
73
+ if (!((0, is_browser_js_1.isBrowser)() || target_js_1.TARGET === "reactNative"))
74
+ return content;
75
+ try {
76
+ const newResults = [];
77
+ for (const item of content.results) {
78
+ newResults.push(yield (0, ab_tests_js_1.handleABTesting)({ item, canTrack }));
79
+ }
80
+ content.results = newResults;
81
+ }
82
+ catch (e) {
83
+ logger_js_1.logger.error("Could not process A/B tests. ", e);
84
+ }
85
+ return content;
86
+ });
87
+ exports.processContentResult = processContentResult;
59
88
  function getAllContent(options) {
60
89
  return __async(this, null, function* () {
61
90
  try {
62
91
  const url = (0, generate_content_url_js_1.generateContentUrl)(options);
63
- const res = yield (0, get_fetch_js_1.fetch)(url.href);
64
- const content = yield res.json();
65
- if ("status" in content && !("results" in content)) {
92
+ const content = yield fetchContent(options);
93
+ if (!checkContentHasResults(content)) {
66
94
  logger_js_1.logger.error("Error fetching data. ", { url, content, options });
67
95
  return content;
68
96
  }
69
- const canTrack = options.canTrack !== false;
70
- try {
71
- if (canTrack && Array.isArray(content.results)) {
72
- for (const item of content.results) {
73
- yield (0, ab_testing_js_1.handleABTesting)({ item, canTrack });
74
- }
75
- }
76
- }
77
- catch (e) {
78
- logger_js_1.logger.error("Could not setup A/B testing. ", e);
79
- }
80
- return content;
97
+ return processContentResult(options, content);
81
98
  }
82
99
  catch (error) {
83
100
  logger_js_1.logger.error("Error fetching data. ", error);
@@ -1,10 +1,127 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.setContentVariationCookie = exports.getContentVariationCookie = void 0;
3
+ exports.handleABTestingSync = exports.handleABTesting = 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
+ var __async = (__this, __arguments, generator) => {
21
+ return new Promise((resolve, reject) => {
22
+ var fulfilled = (value) => {
23
+ try {
24
+ step(generator.next(value));
25
+ }
26
+ catch (e) {
27
+ reject(e);
28
+ }
29
+ };
30
+ var rejected = (value) => {
31
+ try {
32
+ step(generator.throw(value));
33
+ }
34
+ catch (e) {
35
+ reject(e);
36
+ }
37
+ };
38
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
39
+ step((generator = generator.apply(__this, __arguments)).next());
40
+ });
41
+ };
4
42
  const cookie_js_1 = require("./cookie.js");
5
- const BUILDER_STORE_PREFIX = "builderio.variations";
43
+ const nullable_js_1 = require("../helpers/nullable.js");
44
+ const logger_js_1 = require("./logger.js");
45
+ const BUILDER_STORE_PREFIX = "builder.tests";
6
46
  const getContentTestKey = (id) => `${BUILDER_STORE_PREFIX}.${id}`;
7
- const getContentVariationCookie = ({ contentId, canTrack }) => (0, cookie_js_1.getCookie)({ name: getContentTestKey(contentId), canTrack });
8
- exports.getContentVariationCookie = getContentVariationCookie;
9
- const setContentVariationCookie = ({ contentId, canTrack, value }) => (0, cookie_js_1.setCookie)({ name: getContentTestKey(contentId), value, canTrack });
10
- exports.setContentVariationCookie = setContentVariationCookie;
47
+ const getContentVariationCookie = ({ contentId }) => (0, cookie_js_1.getCookie)({ name: getContentTestKey(contentId), canTrack: true });
48
+ const getContentVariationCookieSync = ({ contentId }) => (0, cookie_js_1.getCookieSync)({ name: getContentTestKey(contentId), canTrack: true });
49
+ const setContentVariationCookie = ({ contentId, value }) => (0, cookie_js_1.setCookie)({ name: getContentTestKey(contentId), value, canTrack: true });
50
+ const checkIsBuilderContentWithVariations = (item) => (0, nullable_js_1.checkIsDefined)(item.id) && (0, nullable_js_1.checkIsDefined)(item.variations) && Object.keys(item.variations).length > 0;
51
+ const getRandomVariationId = ({ id, variations }) => {
52
+ var _a;
53
+ let n = 0;
54
+ const random = Math.random();
55
+ for (const id2 in variations) {
56
+ const testRatio = (_a = variations[id2]) == null ? void 0 : _a.testRatio;
57
+ n += testRatio;
58
+ if (random < n) {
59
+ return id2;
60
+ }
61
+ }
62
+ return id;
63
+ };
64
+ const getAndSetVariantId = (args) => {
65
+ const randomVariationId = getRandomVariationId(args);
66
+ setContentVariationCookie({
67
+ contentId: args.id,
68
+ value: randomVariationId
69
+ }).catch((err) => {
70
+ logger_js_1.logger.error("could not store A/B test variation: ", err);
71
+ });
72
+ return randomVariationId;
73
+ };
74
+ const getTestFields = ({ item, testGroupId }) => {
75
+ const variationValue = item.variations[testGroupId];
76
+ if (testGroupId === item.id || !variationValue) {
77
+ return {
78
+ testVariationId: item.id,
79
+ testVariationName: "Default"
80
+ };
81
+ }
82
+ else {
83
+ return {
84
+ data: variationValue.data,
85
+ testVariationId: variationValue.id,
86
+ testVariationName: variationValue.name || (variationValue.id === item.id ? "Default" : "")
87
+ };
88
+ }
89
+ };
90
+ const handleABTestingSync = ({ item, canTrack }) => {
91
+ if (!canTrack) {
92
+ return item;
93
+ }
94
+ if (!item) {
95
+ return void 0;
96
+ }
97
+ if (!checkIsBuilderContentWithVariations(item)) {
98
+ return item;
99
+ }
100
+ const testGroupId = getContentVariationCookieSync({
101
+ contentId: item.id
102
+ }) || getAndSetVariantId({
103
+ variations: item.variations,
104
+ id: item.id
105
+ });
106
+ const variationValue = getTestFields({ item, testGroupId });
107
+ return __spreadValues(__spreadValues({}, item), variationValue);
108
+ };
109
+ exports.handleABTestingSync = handleABTestingSync;
110
+ const handleABTesting = (_0) => __async(void 0, [_0], function* ({ item, canTrack }) {
111
+ if (!canTrack) {
112
+ return item;
113
+ }
114
+ if (!checkIsBuilderContentWithVariations(item)) {
115
+ return item;
116
+ }
117
+ const cookieValue = yield getContentVariationCookie({
118
+ contentId: item.id
119
+ });
120
+ const testGroupId = cookieValue || getAndSetVariantId({
121
+ variations: item.variations,
122
+ id: item.id
123
+ });
124
+ const variationValue = getTestFields({ item, testGroupId });
125
+ return __spreadValues(__spreadValues({}, item), variationValue);
126
+ });
127
+ exports.handleABTesting = handleABTesting;
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getDefaultCanTrack = void 0;
4
+ const nullable_1 = require("./nullable");
5
+ const getDefaultCanTrack = (canTrack) => (0, nullable_1.checkIsDefined)(canTrack) ? canTrack : true;
6
+ exports.getDefaultCanTrack = getDefaultCanTrack;
@@ -26,6 +26,7 @@ var __async = (__this, __arguments, generator) => {
26
26
  step((generator = generator.apply(__this, __arguments)).next());
27
27
  });
28
28
  };
29
+ const logger_js_1 = require("./logger.js");
29
30
  const react_native_storage_1 = __importDefault(require("react-native-storage"));
30
31
  const is_browser_js_1 = require("../functions/is-browser.js");
31
32
  const async_storage_1 = __importDefault(require("@react-native-async-storage/async-storage"));
@@ -52,7 +53,10 @@ const getCookie = (_0) => __async(void 0, [_0], function* ({ name, canTrack }) {
52
53
  return data.value;
53
54
  }
54
55
  catch (err) {
55
- console.debug("[COOKIE] GET error: ", err);
56
+ if ((err == null ? void 0 : err.name) !== "NotFoundError") {
57
+ logger_js_1.logger.warn("[COOKIE] GET error: ", (err == null ? void 0 : err.message) || err);
58
+ }
59
+ return void 0;
56
60
  }
57
61
  });
58
62
  exports.getCookie = getCookie;
@@ -64,7 +68,10 @@ const setCookie = (_0) => __async(void 0, [_0], function* ({ name, value, expire
64
68
  yield storage.save({ key: getStorageName(name), data: { value }, expires });
65
69
  }
66
70
  catch (err) {
67
- console.warn("[COOKIE] SET error: ", err);
71
+ if ((err == null ? void 0 : err.name) !== "NotFoundError") {
72
+ logger_js_1.logger.warn("[COOKIE] SET error: ", (err == null ? void 0 : err.message) || err);
73
+ }
74
+ return void 0;
68
75
  }
69
76
  });
70
77
  exports.setCookie = setCookie;
@@ -5,6 +5,7 @@ const MSG_PREFIX = "[Builder.io]: ";
5
5
  const logger = {
6
6
  log: (...message) => console.log(MSG_PREFIX, ...message),
7
7
  error: (...message) => console.error(MSG_PREFIX, ...message),
8
- warn: (...message) => console.warn(MSG_PREFIX, ...message)
8
+ warn: (...message) => console.warn(MSG_PREFIX, ...message),
9
+ debug: (...message) => console.debug(MSG_PREFIX, ...message)
9
10
  };
10
11
  exports.logger = logger;
package/dist/index.js CHANGED
@@ -14,15 +14,24 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.track = void 0;
17
+ exports.track = exports.setEditorSettings = exports.register = exports.processContentResult = exports.isPreviewing = exports.isEditing = exports.getContent = exports.getBuilderSearchParams = exports.getAllContent = exports.createRegisterComponentMessage = void 0;
18
18
  __exportStar(require("./index-helpers/top-of-file.js"), exports);
19
19
  __exportStar(require("./index-helpers/blocks-exports.js"), exports);
20
- __exportStar(require("./functions/is-editing.js"), exports);
21
- __exportStar(require("./functions/is-previewing.js"), exports);
22
- __exportStar(require("./functions/register-component.js"), exports);
23
- __exportStar(require("./functions/register.js"), exports);
24
- __exportStar(require("./functions/set-editor-settings.js"), exports);
25
- __exportStar(require("./functions/get-content/index.js"), exports);
26
- __exportStar(require("./functions/get-builder-search-params/index.js"), exports);
27
- const index_js_1 = require("./functions/track/index.js");
28
- Object.defineProperty(exports, "track", { enumerable: true, get: function () { return index_js_1.track; } });
20
+ const is_editing_js_1 = require("./functions/is-editing.js");
21
+ Object.defineProperty(exports, "isEditing", { enumerable: true, get: function () { return is_editing_js_1.isEditing; } });
22
+ const is_previewing_js_1 = require("./functions/is-previewing.js");
23
+ Object.defineProperty(exports, "isPreviewing", { enumerable: true, get: function () { return is_previewing_js_1.isPreviewing; } });
24
+ const register_component_js_1 = require("./functions/register-component.js");
25
+ Object.defineProperty(exports, "createRegisterComponentMessage", { enumerable: true, get: function () { return register_component_js_1.createRegisterComponentMessage; } });
26
+ const register_js_1 = require("./functions/register.js");
27
+ Object.defineProperty(exports, "register", { enumerable: true, get: function () { return register_js_1.register; } });
28
+ const set_editor_settings_js_1 = require("./functions/set-editor-settings.js");
29
+ Object.defineProperty(exports, "setEditorSettings", { enumerable: true, get: function () { return set_editor_settings_js_1.setEditorSettings; } });
30
+ const index_js_1 = require("./functions/get-content/index.js");
31
+ Object.defineProperty(exports, "getAllContent", { enumerable: true, get: function () { return index_js_1.getAllContent; } });
32
+ Object.defineProperty(exports, "getContent", { enumerable: true, get: function () { return index_js_1.getContent; } });
33
+ Object.defineProperty(exports, "processContentResult", { enumerable: true, get: function () { return index_js_1.processContentResult; } });
34
+ const index_js_2 = require("./functions/get-builder-search-params/index.js");
35
+ Object.defineProperty(exports, "getBuilderSearchParams", { enumerable: true, get: function () { return index_js_2.getBuilderSearchParams; } });
36
+ const index_js_3 = require("./functions/track/index.js");
37
+ Object.defineProperty(exports, "track", { enumerable: true, get: function () { return index_js_3.track; } });
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.3.1",
4
+ "version": "0.4.1",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
7
7
  "module": "./dist/index.js",
@@ -1,3 +1,4 @@
1
+ 'use client';
1
2
  import BaseText from "../BaseText";
2
3
  import * as React from "react";
3
4
  import {
@@ -1,3 +1,4 @@
1
+ 'use client';
1
2
  import * as React from "react";
2
3
  import {
3
4
  FlatList,
@@ -1,3 +1,4 @@
1
+ 'use client';
1
2
  import * as React from "react";
2
3
  import {
3
4
  FlatList,
@@ -1,3 +1,4 @@
1
+ 'use client';
1
2
  import * as React from "react";
2
3
  import {
3
4
  FlatList,
@@ -1,3 +1,4 @@
1
+ 'use client';
1
2
  import BaseText from "../BaseText";
2
3
  import * as React from "react";
3
4
  import {
@@ -1,3 +1,4 @@
1
+ 'use client';
1
2
  import * as React from "react";
2
3
  import {
3
4
  FlatList,
@@ -1,3 +1,4 @@
1
+ 'use client';
1
2
  import * as React from "react";
2
3
  import {
3
4
  FlatList,
@@ -1,3 +1,4 @@
1
+ 'use client';
1
2
  import * as React from "react";
2
3
  import {
3
4
  FlatList,
@@ -1,3 +1,4 @@
1
+ 'use client';
1
2
  import * as React from "react";
2
3
  import {
3
4
  FlatList,
@@ -1,3 +1,4 @@
1
+ 'use client';
1
2
  import * as React from "react";
2
3
  import {
3
4
  FlatList,
@@ -1,3 +1,4 @@
1
+ 'use client';
1
2
  import BaseText from "../BaseText";
2
3
  import * as React from "react";
3
4
  import {
@@ -1,3 +1,4 @@
1
+ 'use client';
1
2
  import BaseText from "../BaseText";
2
3
  import * as React from "react";
3
4
  import {
@@ -1,3 +1,4 @@
1
+ 'use client';
1
2
  import * as React from "react";
2
3
  import {
3
4
  FlatList,
@@ -1,3 +1,4 @@
1
+ 'use client';
1
2
  import * as React from "react";
2
3
  import {
3
4
  FlatList,
@@ -1,3 +1,4 @@
1
+ 'use client';
1
2
  import * as React from "react";
2
3
  import {
3
4
  FlatList,
@@ -1,3 +1,4 @@
1
+ 'use client';
1
2
  import * as React from "react";
2
3
  import {
3
4
  FlatList,
@@ -52,7 +53,7 @@ function RenderBlock(props) {
52
53
  });
53
54
  }
54
55
 
55
- const [tag, setTag] = useState(() => props.block.tagName || "div");
56
+ const [Tag, setTag] = useState(() => props.block.tagName || "div");
56
57
 
57
58
  function canShowBlock() {
58
59
  if ("hide" in useBlock()) {
@@ -157,12 +158,12 @@ function RenderBlock(props) {
157
158
  <>
158
159
  {!component?.noWrap ? (
159
160
  <>
160
- {isEmptyHtmlElement(tag) ? (
161
+ {isEmptyHtmlElement(Tag) ? (
161
162
  <>
162
- <View {...attributes()} {...actions()} />
163
+ <Tag {...attributes()} {...actions()} />
163
164
  </>
164
165
  ) : null}
165
- {!isEmptyHtmlElement(tag) && repeatItem() ? (
166
+ {!isEmptyHtmlElement(Tag) && repeatItem() ? (
166
167
  <>
167
168
  {repeatItem()?.map((data, index) => (
168
169
  <RenderRepeatedBlock
@@ -173,9 +174,9 @@ function RenderBlock(props) {
173
174
  ))}
174
175
  </>
175
176
  ) : null}
176
- {!isEmptyHtmlElement(tag) && !repeatItem() ? (
177
+ {!isEmptyHtmlElement(Tag) && !repeatItem() ? (
177
178
  <>
178
- <View {...attributes()} {...actions()}>
179
+ <Tag {...attributes()} {...actions()}>
179
180
  <RenderComponent {...renderComponentProps()} />
180
181
 
181
182
  {childrenWithoutParentComponent()?.map((child) => (
@@ -193,7 +194,7 @@ function RenderBlock(props) {
193
194
  context={childrenContext()}
194
195
  />
195
196
  ))}
196
- </View>
197
+ </Tag>
197
198
  </>
198
199
  ) : null}
199
200
  </>
@@ -1,3 +1,4 @@
1
+ 'use client';
1
2
  import * as React from "react";
2
3
  import {
3
4
  FlatList,
@@ -13,8 +14,6 @@ import RenderBlock from "./render-block";
13
14
  import BuilderContext from "../../context/builder.context.js";
14
15
 
15
16
  function RenderComponent(props) {
16
- const ComponentRefRef = props.componentRef;
17
-
18
17
  return (
19
18
  <BuilderContext.Provider
20
19
  value={{
@@ -30,7 +29,7 @@ function RenderComponent(props) {
30
29
  >
31
30
  {props.componentRef ? (
32
31
  <>
33
- <ComponentRefRef {...props.componentOptions}>
32
+ <props.componentRef {...props.componentOptions}>
34
33
  {props.blockChildren?.map((child) => (
35
34
  <RenderBlock
36
35
  key={"render-block-" + child.id}
@@ -46,7 +45,7 @@ function RenderComponent(props) {
46
45
  context={props.context}
47
46
  />
48
47
  ))}
49
- </ComponentRefRef>
48
+ </props.componentRef>
50
49
  </>
51
50
  ) : null}
52
51
  </BuilderContext.Provider>
@@ -1,3 +1,4 @@
1
+ 'use client';
1
2
  import * as React from "react";
2
3
  import {
3
4
  FlatList,
@@ -1,3 +1,4 @@
1
+ 'use client';
1
2
  import * as React from "react";
2
3
  import {
3
4
  FlatList,
@@ -1,3 +1,4 @@
1
+ 'use client';
1
2
  import * as React from "react";
2
3
  import {
3
4
  FlatList,
@@ -1,3 +1,4 @@
1
+ 'use client';
1
2
  import * as React from "react";
2
3
  import {
3
4
  FlatList,
@@ -13,8 +14,8 @@ import { getCss } from "./render-styles.helpers";
13
14
  import { getFontCss } from "./render-styles.helpers";
14
15
 
15
16
  function RenderContentStyles(props) {
16
- const [injectedStyles, setInjectedStyles] = useState(
17
- () => `
17
+ const [injectedStyles, setInjectedStyles] = useState(() =>
18
+ `
18
19
  ${getCss({
19
20
  cssCode: props.cssCode,
20
21
  contentId: props.contentId,
@@ -35,7 +36,7 @@ ${getFontCss({
35
36
  text-align: inherit;
36
37
  font-family: inherit;
37
38
  }
38
- `
39
+ `.trim()
39
40
  );
40
41
 
41
42
  return <RenderInlinedStyles styles={injectedStyles} />;
@@ -1,3 +1,4 @@
1
+ 'use client';
1
2
  import * as React from "react";
2
3
  import {
3
4
  FlatList,
@@ -35,6 +36,8 @@ import {
35
36
  } from "./render-content.helpers.js";
36
37
  import { TARGET } from "../../constants/target.js";
37
38
  import { logger } from "../../helpers/logger.js";
39
+ import { getRenderContentScriptString } from "../render-content-variants/helpers.js";
40
+ import { wrapComponentRef } from "./wrap-component-ref.js";
38
41
 
39
42
  function RenderContent(props) {
40
43
  const elementRef = useRef(null);
@@ -105,9 +108,13 @@ function RenderContent(props) {
105
108
  ...components,
106
109
  ...(props.customComponents || []),
107
110
  ].reduce(
108
- (acc, curr) => ({
111
+ (acc, { component, ...curr }) => ({
109
112
  ...acc,
110
- [curr.name]: curr,
113
+ [curr.name]: {
114
+ component:
115
+ TARGET === "vue3" ? wrapComponentRef(component) : component,
116
+ ...curr,
117
+ },
111
118
  }),
112
119
  {}
113
120
  )
@@ -244,6 +251,14 @@ function RenderContent(props) {
244
251
  }
245
252
  }
246
253
 
254
+ const [scriptStr, setScriptStr] = useState(() =>
255
+ getRenderContentScriptString({
256
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion, @typescript-eslint/no-non-null-asserted-optional-chain
257
+ contentId: props.content?.id,
258
+ parentContentId: props.parentContentId,
259
+ })
260
+ );
261
+
247
262
  useEffect(() => {
248
263
  if (!props.apiKey) {
249
264
  logger.error(
@@ -265,6 +280,11 @@ function RenderContent(props) {
265
280
  includeRefs: props.includeRefs,
266
281
  }
267
282
  : {}),
283
+ ...(props.enrich
284
+ ? {
285
+ enrich: props.enrich,
286
+ }
287
+ : {}),
268
288
  });
269
289
  Object.values(allRegisteredComponents).forEach(
270
290
  (registeredComponent) => {
@@ -377,7 +397,27 @@ function RenderContent(props) {
377
397
  onClick={(event) => onClick(event)}
378
398
  builder-content-id={useContent?.id}
379
399
  builder-model={props.model}
400
+ {...(TARGET === "reactNative"
401
+ ? {
402
+ dataSet: {
403
+ // 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.
404
+ "builder-content-id": "",
405
+ },
406
+ }
407
+ : {})}
408
+ {...(props.hideContent
409
+ ? {
410
+ hidden: true,
411
+ "aria-hidden": true,
412
+ }
413
+ : {})}
380
414
  >
415
+ {props.isSsrAbTest ? (
416
+ <>
417
+ <ScrollView dangerouslySetInnerHTML={{ __html: scriptStr }} />
418
+ </>
419
+ ) : null}
420
+
381
421
  {TARGET !== "reactNative" ? (
382
422
  <>
383
423
  <RenderContentStyles
@@ -0,0 +1,4 @@
1
+ const wrapComponentRef = (component) => component;
2
+ export {
3
+ wrapComponentRef
4
+ };