@builder.io/sdk-react-native 0.1.2 → 0.1.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.
Files changed (181) hide show
  1. package/dist/blocks/BaseText.js +40 -0
  2. package/dist/blocks/button/button.js +39 -0
  3. package/dist/blocks/button/component-info.js +42 -0
  4. package/dist/blocks/columns/columns.js +149 -0
  5. package/dist/blocks/columns/component-info.js +244 -0
  6. package/dist/blocks/custom-code/component-info.js +32 -0
  7. package/dist/blocks/custom-code/custom-code.js +76 -0
  8. package/dist/blocks/embed/component-info.js +47 -0
  9. package/dist/blocks/embed/embed.js +67 -0
  10. package/dist/blocks/embed/helpers.js +10 -0
  11. package/dist/blocks/form/component-info.js +263 -0
  12. package/dist/blocks/form/form.js +232 -0
  13. package/dist/blocks/fragment/component-info.js +12 -0
  14. package/dist/blocks/fragment/fragment.js +36 -0
  15. package/dist/blocks/image/component-info.js +152 -0
  16. package/dist/blocks/image/image.helpers.js +49 -0
  17. package/dist/blocks/image/image.js +81 -0
  18. package/dist/blocks/img/component-info.js +21 -0
  19. package/dist/blocks/img/img.js +35 -0
  20. package/dist/blocks/input/component-info.js +75 -0
  21. package/dist/blocks/input/input.js +32 -0
  22. package/dist/blocks/raw-text/component-info.js +17 -0
  23. package/dist/blocks/raw-text/raw-text.js +31 -0
  24. package/dist/blocks/section/component-info.js +50 -0
  25. package/dist/blocks/section/section.js +49 -0
  26. package/dist/blocks/select/component-info.js +60 -0
  27. package/dist/blocks/select/select.js +38 -0
  28. package/dist/blocks/submit-button/component-info.js +29 -0
  29. package/dist/blocks/submit-button/submit-button.js +36 -0
  30. package/dist/blocks/symbol/component-info.js +44 -0
  31. package/dist/blocks/symbol/symbol.js +97 -0
  32. package/dist/blocks/text/component-info.js +25 -0
  33. package/dist/blocks/text/text.js +112 -0
  34. package/dist/blocks/textarea/component-info.js +48 -0
  35. package/dist/blocks/textarea/textarea.js +31 -0
  36. package/dist/blocks/util.js +9 -0
  37. package/dist/blocks/video/component-info.js +107 -0
  38. package/dist/blocks/video/video.js +81 -0
  39. package/dist/components/render-block/block-styles.js +79 -0
  40. package/dist/components/render-block/render-block.helpers.js +109 -0
  41. package/dist/components/render-block/render-block.js +154 -0
  42. package/dist/components/render-block/render-component-with-context.js +45 -0
  43. package/dist/components/render-block/render-component.js +50 -0
  44. package/dist/components/render-block/render-repeated-block.js +45 -0
  45. package/dist/components/render-block/types.js +1 -0
  46. package/dist/components/render-blocks.js +76 -0
  47. package/dist/components/render-content/builder-editing.js +31 -0
  48. package/dist/components/render-content/components/render-styles.js +91 -0
  49. package/dist/components/render-content/index.js +8 -0
  50. package/dist/components/render-content/render-content.js +325 -0
  51. package/dist/components/render-inlined-styles.js +42 -0
  52. package/dist/constants/builder-registered-components.js +46 -0
  53. package/dist/constants/device-sizes.js +49 -0
  54. package/dist/constants/target.js +5 -0
  55. package/dist/context/builder.context.js +13 -0
  56. package/dist/context/types.js +1 -0
  57. package/dist/functions/camel-to-kebab-case.js +5 -0
  58. package/dist/functions/evaluate.js +25 -0
  59. package/dist/functions/event-handler-name.js +8 -0
  60. package/dist/functions/extract-text-styles.js +23 -0
  61. package/dist/functions/fast-clone.js +5 -0
  62. package/dist/functions/get-block-actions-handler.js +12 -0
  63. package/dist/functions/get-block-actions.js +19 -0
  64. package/dist/functions/get-block-component-options.js +29 -0
  65. package/dist/functions/get-block-properties.js +51 -0
  66. package/dist/functions/get-block-tag.js +8 -0
  67. package/dist/functions/get-builder-search-params/fn.test.js +15 -0
  68. package/dist/functions/get-builder-search-params/index.js +39 -0
  69. package/dist/functions/get-content/ab-testing.js +89 -0
  70. package/dist/functions/get-content/generate-content-url.js +44 -0
  71. package/dist/functions/get-content/generate-content-url.test.js +33 -0
  72. package/dist/functions/get-content/index.js +68 -0
  73. package/dist/functions/get-content/types.js +1 -0
  74. package/dist/functions/get-fetch.js +15 -0
  75. package/dist/functions/get-global-this.js +19 -0
  76. package/dist/functions/get-processed-block.js +52 -0
  77. package/dist/functions/get-processed-block.test.js +34 -0
  78. package/dist/functions/get-react-native-block-styles.js +30 -0
  79. package/dist/functions/if-target.js +13 -0
  80. package/dist/functions/is-browser.js +7 -0
  81. package/dist/functions/is-editing.js +8 -0
  82. package/dist/functions/is-iframe.js +8 -0
  83. package/dist/functions/is-previewing.js +15 -0
  84. package/dist/functions/on-change.js +28 -0
  85. package/dist/functions/on-change.test.js +21 -0
  86. package/dist/functions/register-component.js +65 -0
  87. package/dist/functions/register.js +31 -0
  88. package/dist/functions/sanitize-react-native-block-styles.js +71 -0
  89. package/dist/functions/set-editor-settings.js +16 -0
  90. package/dist/functions/set.js +12 -0
  91. package/dist/functions/set.test.js +18 -0
  92. package/dist/functions/track/helpers.js +53 -0
  93. package/dist/functions/track/index.js +124 -0
  94. package/dist/functions/track/interaction.js +51 -0
  95. package/dist/functions/track.js +120 -0
  96. package/dist/functions/transform-block-properties.js +18 -0
  97. package/dist/functions/transform-block.js +38 -0
  98. package/dist/helpers/ab-tests.js +10 -0
  99. package/dist/helpers/cookie.js +70 -0
  100. package/dist/helpers/css.js +33 -0
  101. package/dist/helpers/flatten.js +35 -0
  102. package/dist/helpers/localStorage.js +31 -0
  103. package/dist/helpers/nullable.js +5 -0
  104. package/dist/helpers/sessionId.js +51 -0
  105. package/dist/helpers/time.js +6 -0
  106. package/dist/helpers/url.js +14 -0
  107. package/dist/helpers/url.test.js +23 -0
  108. package/dist/helpers/uuid.js +14 -0
  109. package/dist/helpers/visitorId.js +33 -0
  110. package/dist/index-helpers/blocks-exports.js +22 -0
  111. package/dist/index-helpers/top-of-file.js +3 -0
  112. package/dist/index.js +29 -0
  113. package/dist/scripts/init-editing.js +97 -0
  114. package/dist/types/builder-block.js +1 -0
  115. package/dist/types/builder-content.js +1 -0
  116. package/dist/types/can-track.js +1 -0
  117. package/dist/types/components.js +1 -0
  118. package/dist/types/deep-partial.js +1 -0
  119. package/dist/types/element.js +1 -0
  120. package/dist/types/targets.js +1 -0
  121. package/dist/types/typescript.js +1 -0
  122. package/package.json +13 -5
  123. package/src/blocks/BaseText.jsx +17 -0
  124. package/src/blocks/button/button.jsx +28 -0
  125. package/src/blocks/columns/{columns.js → columns.jsx} +61 -38
  126. package/src/blocks/custom-code/{custom-code.js → custom-code.jsx} +22 -15
  127. package/src/blocks/embed/{embed.js → embed.jsx} +12 -11
  128. package/src/blocks/form/form.jsx +251 -0
  129. package/src/blocks/fragment/fragment.jsx +11 -0
  130. package/src/blocks/image/image.jsx +78 -0
  131. package/src/blocks/img/img.jsx +18 -0
  132. package/src/blocks/input/input.jsx +20 -0
  133. package/src/blocks/raw-text/raw-text.jsx +6 -0
  134. package/src/blocks/section/section.jsx +29 -0
  135. package/src/blocks/select/select.jsx +24 -0
  136. package/src/blocks/submit-button/submit-button.jsx +11 -0
  137. package/src/blocks/symbol/symbol.jsx +86 -0
  138. package/src/blocks/text/text.jsx +100 -0
  139. package/src/blocks/textarea/textarea.jsx +14 -0
  140. package/src/blocks/video/video.jsx +70 -0
  141. package/src/components/render-block/block-styles.jsx +70 -0
  142. package/src/components/render-block/render-block.helpers.js +90 -0
  143. package/src/components/render-block/render-block.jsx +183 -0
  144. package/src/components/render-block/render-component.jsx +45 -0
  145. package/src/components/render-block/render-repeated-block.jsx +22 -0
  146. package/src/components/render-blocks.jsx +86 -0
  147. package/src/components/render-content/builder-editing.jsx +6 -0
  148. package/src/components/render-content/components/{render-styles.js → render-styles.jsx} +22 -15
  149. package/src/components/render-content/index.js +1 -1
  150. package/src/components/render-content/render-content.jsx +373 -0
  151. package/src/components/render-inlined-styles.jsx +29 -0
  152. package/src/constants/builder-registered-components.js +7 -7
  153. package/src/functions/track/helpers.js +50 -0
  154. package/src/functions/{track.js → track/index.js} +10 -6
  155. package/src/functions/track/interaction.js +53 -0
  156. package/src/index-helpers/blocks-exports.js +8 -8
  157. package/src/index.js +1 -1
  158. package/src/blocks/BaseText.js +0 -31
  159. package/src/blocks/button/button.js +0 -36
  160. package/src/blocks/form/form.js +0 -222
  161. package/src/blocks/fragment/fragment.js +0 -9
  162. package/src/blocks/image/image.js +0 -55
  163. package/src/blocks/img/img.js +0 -33
  164. package/src/blocks/input/input.js +0 -36
  165. package/src/blocks/raw-text/raw-text.js +0 -10
  166. package/src/blocks/section/section.js +0 -41
  167. package/src/blocks/select/select.js +0 -37
  168. package/src/blocks/submit-button/submit-button.js +0 -27
  169. package/src/blocks/symbol/symbol.js +0 -73
  170. package/src/blocks/text/text.js +0 -67
  171. package/src/blocks/textarea/textarea.js +0 -32
  172. package/src/blocks/video/video.js +0 -55
  173. package/src/components/render-block/block-styles.js +0 -50
  174. package/src/components/render-block/render-block.js +0 -202
  175. package/src/components/render-block/render-component-with-context.js +0 -35
  176. package/src/components/render-block/render-component.js +0 -35
  177. package/src/components/render-block/render-repeated-block.js +0 -33
  178. package/src/components/render-blocks.js +0 -63
  179. package/src/components/render-content/builder-editing.js +0 -8
  180. package/src/components/render-content/render-content.js +0 -297
  181. package/src/components/render-inlined-styles.js +0 -17
@@ -1,63 +0,0 @@
1
- import * as React from "react";
2
- import { View, StyleSheet } from "react-native";
3
- import { useContext } from "react";
4
- import BuilderContext from "../context/builder.context.js";
5
- import { isEditing } from "../functions/is-editing.js";
6
- import BlockStyles from "./render-block/block-styles.js";
7
- import RenderBlock from "./render-block/render-block.js";
8
- function RenderBlocks(props) {
9
- var _a, _b;
10
- function className() {
11
- var _a2;
12
- return "builder-blocks" + (!((_a2 = props.blocks) == null ? void 0 : _a2.length) ? " no-blocks" : "");
13
- }
14
- function onClick() {
15
- var _a2, _b2;
16
- if (isEditing() && !((_a2 = props.blocks) == null ? void 0 : _a2.length)) {
17
- (_b2 = window.parent) == null ? void 0 : _b2.postMessage({
18
- type: "builder.clickEmptyBlocks",
19
- data: {
20
- parentElementId: props.parent,
21
- dataPath: props.path
22
- }
23
- }, "*");
24
- }
25
- }
26
- function onMouseEnter() {
27
- var _a2, _b2;
28
- if (isEditing() && !((_a2 = props.blocks) == null ? void 0 : _a2.length)) {
29
- (_b2 = window.parent) == null ? void 0 : _b2.postMessage({
30
- type: "builder.hoverEmptyBlocks",
31
- data: {
32
- parentElementId: props.parent,
33
- dataPath: props.path
34
- }
35
- }, "*");
36
- }
37
- }
38
- const builderContext = useContext(BuilderContext);
39
- return /* @__PURE__ */ React.createElement(View, {
40
- "builder-path": props.path,
41
- "builder-parent-id": props.parent,
42
- dataSet: {
43
- class: className()
44
- },
45
- style: styles.view1,
46
- onClick: (event) => onClick(),
47
- onMouseEnter: (event) => onMouseEnter()
48
- }, props.blocks ? /* @__PURE__ */ React.createElement(React.Fragment, null, (_a = props.blocks) == null ? void 0 : _a.map((block) => /* @__PURE__ */ React.createElement(RenderBlock, {
49
- key: "render-block-" + block.id,
50
- block,
51
- context: builderContext
52
- }))) : null, props.blocks ? /* @__PURE__ */ React.createElement(React.Fragment, null, (_b = props.blocks) == null ? void 0 : _b.map((block) => /* @__PURE__ */ React.createElement(BlockStyles, {
53
- key: "block-style-" + block.id,
54
- block,
55
- context: builderContext
56
- }))) : null);
57
- }
58
- const styles = StyleSheet.create({
59
- view1: { display: "flex", flexDirection: "column", alignItems: "stretch" }
60
- });
61
- export {
62
- RenderBlocks as default
63
- };
@@ -1,8 +0,0 @@
1
- import * as React from "react";
2
- import { View } from "react-native";
3
- function BuilderEditing(props) {
4
- return /* @__PURE__ */ React.createElement(View, null);
5
- }
6
- export {
7
- BuilderEditing as default
8
- };
@@ -1,297 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __defProps = Object.defineProperties;
3
- var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
4
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
7
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8
- var __spreadValues = (a, b) => {
9
- for (var prop in b || (b = {}))
10
- if (__hasOwnProp.call(b, prop))
11
- __defNormalProp(a, prop, b[prop]);
12
- if (__getOwnPropSymbols)
13
- for (var prop of __getOwnPropSymbols(b)) {
14
- if (__propIsEnum.call(b, prop))
15
- __defNormalProp(a, prop, b[prop]);
16
- }
17
- return a;
18
- };
19
- var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
20
- import * as React from "react";
21
- import { View } from "react-native";
22
- import { useState, useRef, useEffect } from "react";
23
- import { getDefaultRegisteredComponents } from "../../constants/builder-registered-components.js";
24
- import { TARGET } from "../../constants/target.js";
25
- import { evaluate } from "../../functions/evaluate.js";
26
- import { getContent } from "../../functions/get-content/index.js";
27
- import { fetch } from "../../functions/get-fetch.js";
28
- import { isBrowser } from "../../functions/is-browser.js";
29
- import { isEditing } from "../../functions/is-editing.js";
30
- import { isPreviewing } from "../../functions/is-previewing.js";
31
- import {
32
- components,
33
- createRegisterComponentMessage
34
- } from "../../functions/register-component.js";
35
- import { _track } from "../../functions/track.js";
36
- import RenderBlocks from "../render-blocks.js";
37
- import RenderContentStyles from "./components/render-styles.js";
38
- import BuilderContext from "../../context/builder.context.js";
39
- import {
40
- registerInsertMenu,
41
- setupBrowserForEditing
42
- } from "../../scripts/init-editing.js";
43
- import { checkIsDefined } from "../../helpers/nullable.js";
44
- function RenderContent(props) {
45
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
46
- const elementRef = useRef(null);
47
- const [forceReRenderCount, setForceReRenderCount] = useState(() => 0);
48
- const [overrideContent, setOverrideContent] = useState(() => null);
49
- function useContent() {
50
- var _a2, _b2, _c2, _d2, _e2;
51
- if (!props.content && !overrideContent) {
52
- return void 0;
53
- }
54
- const mergedContent = __spreadProps(__spreadValues(__spreadValues({}, props.content), overrideContent), {
55
- data: __spreadValues(__spreadValues(__spreadValues({}, (_a2 = props.content) == null ? void 0 : _a2.data), props.data), overrideContent == null ? void 0 : overrideContent.data),
56
- meta: __spreadProps(__spreadValues(__spreadValues({}, (_b2 = props.content) == null ? void 0 : _b2.meta), overrideContent == null ? void 0 : overrideContent.meta), {
57
- breakpoints: useBreakpoints || ((_c2 = overrideContent == null ? void 0 : overrideContent.meta) == null ? void 0 : _c2.breakpoints) || ((_e2 = (_d2 = props.content) == null ? void 0 : _d2.meta) == null ? void 0 : _e2.breakpoints)
58
- })
59
- });
60
- return mergedContent;
61
- }
62
- const [update, setUpdate] = useState(() => 0);
63
- const [useBreakpoints, setUseBreakpoints] = useState(() => null);
64
- function canTrackToUse() {
65
- return checkIsDefined(props.canTrack) ? props.canTrack : true;
66
- }
67
- const [overrideState, setOverrideState] = useState(() => ({}));
68
- function contentState() {
69
- var _a2, _b2;
70
- return __spreadValues(__spreadValues(__spreadValues(__spreadValues({}, (_b2 = (_a2 = props.content) == null ? void 0 : _a2.data) == null ? void 0 : _b2.state), props.data), props.locale ? {
71
- locale: props.locale
72
- } : {}), overrideState);
73
- }
74
- function contextContext() {
75
- return props.context || {};
76
- }
77
- function allRegisteredComponents() {
78
- const allComponentsArray = [
79
- ...getDefaultRegisteredComponents(),
80
- ...components,
81
- ...props.customComponents || []
82
- ];
83
- const allComponents = allComponentsArray.reduce((acc, curr) => __spreadProps(__spreadValues({}, acc), {
84
- [curr.name]: curr
85
- }), {});
86
- return allComponents;
87
- }
88
- function processMessage(event) {
89
- var _a2;
90
- const { data } = event;
91
- if (data) {
92
- switch (data.type) {
93
- case "builder.configureSdk": {
94
- const messageContent = data.data;
95
- const { breakpoints, contentId } = messageContent;
96
- if (!contentId || contentId !== ((_a2 = useContent == null ? void 0 : useContent()) == null ? void 0 : _a2.id)) {
97
- return;
98
- }
99
- setUseBreakpoints(breakpoints);
100
- setForceReRenderCount(forceReRenderCount + 1);
101
- break;
102
- }
103
- case "builder.contentUpdate": {
104
- const messageContent = data.data;
105
- const key = messageContent.key || messageContent.alias || messageContent.entry || messageContent.modelName;
106
- const contentData = messageContent.data;
107
- if (key === props.model) {
108
- setOverrideContent(contentData);
109
- setForceReRenderCount(forceReRenderCount + 1);
110
- }
111
- break;
112
- }
113
- case "builder.patchUpdates": {
114
- break;
115
- }
116
- }
117
- }
118
- }
119
- function evaluateJsCode() {
120
- var _a2, _b2;
121
- const jsCode = (_b2 = (_a2 = useContent == null ? void 0 : useContent()) == null ? void 0 : _a2.data) == null ? void 0 : _b2.jsCode;
122
- if (jsCode) {
123
- evaluate({
124
- code: jsCode,
125
- context: contextContext(),
126
- state: contentState()
127
- });
128
- }
129
- }
130
- function httpReqsData() {
131
- return {};
132
- }
133
- function onClick(_event) {
134
- var _a2, _b2;
135
- if (useContent()) {
136
- const variationId = (_a2 = useContent == null ? void 0 : useContent()) == null ? void 0 : _a2.testVariationId;
137
- const contentId = (_b2 = useContent == null ? void 0 : useContent()) == null ? void 0 : _b2.id;
138
- _track({
139
- type: "click",
140
- canTrack: canTrackToUse(),
141
- contentId,
142
- apiKey: props.apiKey,
143
- variationId: variationId !== contentId ? variationId : void 0
144
- });
145
- }
146
- }
147
- function evalExpression(expression) {
148
- return expression.replace(/{{([^}]+)}}/g, (_match, group) => evaluate({
149
- code: group,
150
- context: contextContext(),
151
- state: contentState()
152
- }));
153
- }
154
- function handleRequest({ url, key }) {
155
- fetch(url).then((response) => response.json()).then((json) => {
156
- const newOverrideState = __spreadProps(__spreadValues({}, overrideState), {
157
- [key]: json
158
- });
159
- setOverrideState(newOverrideState);
160
- }).catch((err) => {
161
- console.log("error fetching dynamic data", url, err);
162
- });
163
- }
164
- function runHttpRequests() {
165
- var _a2, _b2, _c2;
166
- const requests = (_c2 = (_b2 = (_a2 = useContent == null ? void 0 : useContent()) == null ? void 0 : _a2.data) == null ? void 0 : _b2.httpRequests) != null ? _c2 : {};
167
- Object.entries(requests).forEach(([key, url]) => {
168
- if (url && (!httpReqsData()[key] || isEditing())) {
169
- const evaluatedUrl = evalExpression(url);
170
- handleRequest({
171
- url: evaluatedUrl,
172
- key
173
- });
174
- }
175
- });
176
- }
177
- function emitStateUpdate() {
178
- if (isEditing()) {
179
- window.dispatchEvent(new CustomEvent("builder:component:stateChange", {
180
- detail: {
181
- state: contentState(),
182
- ref: {
183
- name: props.model
184
- }
185
- }
186
- }));
187
- }
188
- }
189
- function shouldRenderContentStyles() {
190
- var _a2, _b2, _c2, _d2, _e2;
191
- return Boolean((((_b2 = (_a2 = useContent == null ? void 0 : useContent()) == null ? void 0 : _a2.data) == null ? void 0 : _b2.cssCode) || ((_e2 = (_d2 = (_c2 = useContent == null ? void 0 : useContent()) == null ? void 0 : _c2.data) == null ? void 0 : _d2.customFonts) == null ? void 0 : _e2.length)) && TARGET !== "reactNative");
192
- }
193
- useEffect(() => {
194
- var _a2, _b2;
195
- if (!props.apiKey) {
196
- console.error("[Builder.io]: No API key provided to `RenderContent` component. This can cause issues. Please provide an API key using the `apiKey` prop.");
197
- }
198
- if (isBrowser()) {
199
- if (isEditing()) {
200
- setForceReRenderCount(forceReRenderCount + 1);
201
- registerInsertMenu();
202
- setupBrowserForEditing(__spreadValues(__spreadValues({}, props.locale ? {
203
- locale: props.locale
204
- } : {}), props.includeRefs ? {
205
- includeRefs: props.includeRefs
206
- } : {}));
207
- Object.values(allRegisteredComponents()).forEach((registeredComponent) => {
208
- var _a3;
209
- const message = createRegisterComponentMessage(registeredComponent);
210
- (_a3 = window.parent) == null ? void 0 : _a3.postMessage(message, "*");
211
- });
212
- window.addEventListener("message", processMessage);
213
- window.addEventListener("builder:component:stateChangeListenerActivated", emitStateUpdate);
214
- }
215
- if (useContent()) {
216
- const variationId = (_a2 = useContent == null ? void 0 : useContent()) == null ? void 0 : _a2.testVariationId;
217
- const contentId = (_b2 = useContent == null ? void 0 : useContent()) == null ? void 0 : _b2.id;
218
- _track({
219
- type: "impression",
220
- canTrack: canTrackToUse(),
221
- contentId,
222
- apiKey: props.apiKey,
223
- variationId: variationId !== contentId ? variationId : void 0
224
- });
225
- }
226
- if (isPreviewing()) {
227
- const searchParams = new URL(location.href).searchParams;
228
- if (props.model && searchParams.get("builder.preview") === props.model) {
229
- const previewApiKey = searchParams.get("apiKey") || searchParams.get("builder.space");
230
- if (previewApiKey) {
231
- getContent({
232
- model: props.model,
233
- apiKey: previewApiKey
234
- }).then((content) => {
235
- if (content) {
236
- setOverrideContent(content);
237
- }
238
- });
239
- }
240
- }
241
- }
242
- evaluateJsCode();
243
- runHttpRequests();
244
- emitStateUpdate();
245
- }
246
- }, []);
247
- useEffect(() => {
248
- evaluateJsCode();
249
- }, [(_b = (_a = useContent == null ? void 0 : useContent()) == null ? void 0 : _a.data) == null ? void 0 : _b.jsCode, contentState()]);
250
- useEffect(() => {
251
- runHttpRequests();
252
- }, [(_d = (_c = useContent == null ? void 0 : useContent()) == null ? void 0 : _c.data) == null ? void 0 : _d.httpRequests]);
253
- useEffect(() => {
254
- emitStateUpdate();
255
- }, [contentState()]);
256
- useEffect(() => {
257
- return () => {
258
- if (isBrowser()) {
259
- window.removeEventListener("message", processMessage);
260
- window.removeEventListener("builder:component:stateChangeListenerActivated", emitStateUpdate);
261
- }
262
- };
263
- }, []);
264
- return /* @__PURE__ */ React.createElement(BuilderContext.Provider, {
265
- value: {
266
- get content() {
267
- return useContent();
268
- },
269
- get state() {
270
- return contentState();
271
- },
272
- get context() {
273
- return contextContext();
274
- },
275
- get apiKey() {
276
- return props.apiKey;
277
- },
278
- get registeredComponents() {
279
- return allRegisteredComponents();
280
- }
281
- }
282
- }, useContent() ? /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(View, {
283
- ref: elementRef,
284
- onClick: (event) => onClick(event),
285
- "builder-content-id": (_e = useContent == null ? void 0 : useContent()) == null ? void 0 : _e.id,
286
- "builder-model": props.model
287
- }, shouldRenderContentStyles() ? /* @__PURE__ */ React.createElement(RenderContentStyles, {
288
- cssCode: (_g = (_f = useContent == null ? void 0 : useContent()) == null ? void 0 : _f.data) == null ? void 0 : _g.cssCode,
289
- customFonts: (_i = (_h = useContent == null ? void 0 : useContent()) == null ? void 0 : _h.data) == null ? void 0 : _i.customFonts
290
- }) : null, /* @__PURE__ */ React.createElement(RenderBlocks, {
291
- blocks: (_k = (_j = useContent == null ? void 0 : useContent()) == null ? void 0 : _j.data) == null ? void 0 : _k.blocks,
292
- key: forceReRenderCount
293
- }))) : null);
294
- }
295
- export {
296
- RenderContent as default
297
- };
@@ -1,17 +0,0 @@
1
- import * as React from "react";
2
- import { View, Text } from "react-native";
3
- import { TARGET } from "../constants/target.js";
4
- function RenderInlinedStyles(props) {
5
- function injectedStyleScript() {
6
- return `<${tag()}>${props.styles}</${tag()}>`;
7
- }
8
- function tag() {
9
- return "style";
10
- }
11
- return /* @__PURE__ */ React.createElement(React.Fragment, null, TARGET === "svelte" ? /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(View, {
12
- dangerouslySetInnerHTML: { __html: injectedStyleScript() }
13
- })) : /* @__PURE__ */ React.createElement(View, null, /* @__PURE__ */ React.createElement(Text, null, props.styles)));
14
- }
15
- export {
16
- RenderInlinedStyles as default
17
- };