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

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 (147) hide show
  1. package/dist/blocks/BaseText.d.ts +6 -0
  2. package/dist/blocks/button/button.d.ts +9 -0
  3. package/dist/blocks/button/component-info.d.ts +2 -0
  4. package/dist/blocks/columns/columns.d.ts +16 -0
  5. package/dist/blocks/columns/component-info.d.ts +2 -0
  6. package/dist/blocks/custom-code/component-info.d.ts +2 -0
  7. package/dist/blocks/custom-code/custom-code.d.ts +5 -0
  8. package/dist/blocks/embed/component-info.d.ts +2 -0
  9. package/dist/blocks/embed/embed.d.ts +5 -0
  10. package/dist/blocks/embed/helpers.d.ts +1 -0
  11. package/dist/blocks/form/component-info.d.ts +2 -0
  12. package/dist/blocks/form/form.d.ts +28 -0
  13. package/dist/blocks/fragment/component-info.d.ts +2 -0
  14. package/dist/blocks/fragment/fragment.d.ts +8 -0
  15. package/dist/blocks/image/component-info.d.ts +2 -0
  16. package/dist/blocks/image/image.d.ts +17 -0
  17. package/dist/blocks/image/image.helpers.d.ts +1 -0
  18. package/dist/blocks/img/component-info.d.ts +2 -0
  19. package/dist/blocks/img/component-info.js +1 -1
  20. package/dist/blocks/img/img.d.ts +11 -0
  21. package/dist/blocks/input/component-info.d.ts +2 -0
  22. package/dist/blocks/input/input.d.ts +12 -0
  23. package/dist/blocks/raw-text/component-info.d.ts +2 -0
  24. package/dist/blocks/raw-text/raw-text.d.ts +5 -0
  25. package/dist/blocks/section/component-info.d.ts +2 -0
  26. package/dist/blocks/section/section.d.ts +9 -0
  27. package/dist/blocks/select/component-info.d.ts +2 -0
  28. package/dist/blocks/select/select.d.ts +13 -0
  29. package/dist/blocks/submit-button/component-info.d.ts +2 -0
  30. package/dist/blocks/submit-button/submit-button.d.ts +7 -0
  31. package/dist/blocks/symbol/component-info.d.ts +2 -0
  32. package/dist/blocks/symbol/symbol.d.ts +21 -0
  33. package/dist/blocks/text/component-info.d.ts +2 -0
  34. package/dist/blocks/text/text.d.ts +7 -0
  35. package/dist/blocks/textarea/component-info.d.ts +2 -0
  36. package/dist/blocks/textarea/textarea.d.ts +10 -0
  37. package/dist/blocks/util.d.ts +4 -0
  38. package/dist/blocks/video/component-info.d.ts +2 -0
  39. package/dist/blocks/video/video.d.ts +31 -0
  40. package/dist/components/render-block/block-styles.d.ts +9 -0
  41. package/dist/components/render-block/render-block.d.ts +9 -0
  42. package/dist/components/render-block/render-block.helpers.d.ts +12 -0
  43. package/dist/components/render-block/render-block.js +18 -26
  44. package/dist/components/render-block/render-component.d.ts +17 -0
  45. package/dist/components/render-block/render-repeated-block.d.ts +9 -0
  46. package/dist/components/render-block/render-repeated-block.js +3 -12
  47. package/dist/components/render-block/types.d.ts +6 -0
  48. package/dist/components/render-blocks.d.ts +10 -0
  49. package/dist/components/render-blocks.js +1 -1
  50. package/dist/components/render-content/builder-editing.d.ts +3 -0
  51. package/dist/components/render-content/components/render-styles.d.ts +9 -0
  52. package/dist/components/render-content/components/render-styles.helpers.d.ts +15 -0
  53. package/dist/components/render-content/index.d.ts +1 -0
  54. package/dist/components/render-content/render-content.d.ts +4 -0
  55. package/dist/components/render-content/render-content.helpers.d.ts +7 -0
  56. package/dist/components/render-content/render-content.js +77 -71
  57. package/dist/components/render-content/render-content.types.d.ts +38 -0
  58. package/dist/components/render-content/wrap-component-ref.d.ts +6 -0
  59. package/dist/components/render-content-variants/helpers.d.ts +17 -0
  60. package/dist/components/render-content-variants/helpers.js +3 -1
  61. package/dist/components/render-content-variants/render-content-variants.d.ts +5 -0
  62. package/dist/components/render-inlined-styles.d.ts +7 -0
  63. package/dist/constants/builder-registered-components.d.ts +6 -0
  64. package/dist/constants/device-sizes.d.ts +13 -0
  65. package/dist/constants/sdk-version.d.ts +1 -0
  66. package/dist/constants/sdk-version.js +1 -1
  67. package/dist/constants/target.d.ts +3 -0
  68. package/dist/context/builder.context.d.ts +3 -0
  69. package/dist/context/types.d.ts +35 -0
  70. package/dist/functions/camel-to-kebab-case.d.ts +1 -0
  71. package/dist/functions/evaluate.d.ts +7 -0
  72. package/dist/functions/evaluate.test.d.ts +1 -0
  73. package/dist/functions/event-handler-name.d.ts +1 -0
  74. package/dist/functions/extract-text-styles.d.ts +4 -0
  75. package/dist/functions/fast-clone.d.ts +4 -0
  76. package/dist/functions/get-block-actions-handler.d.ts +8 -0
  77. package/dist/functions/get-block-actions.d.ts +9 -0
  78. package/dist/functions/get-block-component-options.d.ts +2 -0
  79. package/dist/functions/get-block-properties.d.ts +2 -0
  80. package/dist/functions/get-builder-search-params/fn.test.d.ts +1 -0
  81. package/dist/functions/get-builder-search-params/index.d.ts +12 -0
  82. package/dist/functions/get-content/generate-content-url.d.ts +2 -0
  83. package/dist/functions/get-content/generate-content-url.test.d.ts +1 -0
  84. package/dist/functions/get-content/index.d.ts +16 -0
  85. package/dist/functions/get-content/types.d.ts +51 -0
  86. package/dist/functions/get-fetch.d.ts +1 -0
  87. package/dist/functions/get-processed-block.d.ts +10 -0
  88. package/dist/functions/get-processed-block.test.d.ts +1 -0
  89. package/dist/functions/get-react-native-block-styles.d.ts +7 -0
  90. package/dist/functions/if-target.d.ts +7 -0
  91. package/dist/functions/is-browser.d.ts +1 -0
  92. package/dist/functions/is-editing.d.ts +1 -0
  93. package/dist/functions/is-iframe.d.ts +1 -0
  94. package/dist/functions/is-previewing.d.ts +1 -0
  95. package/dist/functions/on-change.d.ts +7 -0
  96. package/dist/functions/on-change.test.d.ts +1 -0
  97. package/dist/functions/register-component.d.ts +14 -0
  98. package/dist/functions/register.d.ts +16 -0
  99. package/dist/functions/sanitize-react-native-block-styles.d.ts +3 -0
  100. package/dist/functions/set-editor-settings.d.ts +4 -0
  101. package/dist/functions/set.d.ts +7 -0
  102. package/dist/functions/set.test.d.ts +1 -0
  103. package/dist/functions/track/helpers.d.ts +5 -0
  104. package/dist/functions/track/index.d.ts +51 -0
  105. package/dist/functions/track/interaction.d.ts +13 -0
  106. package/dist/functions/transform-block-properties.d.ts +3 -0
  107. package/dist/functions/transform-block.d.ts +2 -0
  108. package/dist/helpers/ab-tests.d.ts +9 -0
  109. package/dist/helpers/canTrack.d.ts +1 -0
  110. package/dist/helpers/cookie.d.ts +9 -0
  111. package/dist/helpers/css.d.ts +7 -0
  112. package/dist/helpers/flatten.d.ts +6 -0
  113. package/dist/helpers/localStorage.d.ts +9 -0
  114. package/dist/helpers/logger.d.ts +6 -0
  115. package/dist/helpers/nullable.d.ts +2 -0
  116. package/dist/helpers/sessionId.d.ts +6 -0
  117. package/dist/helpers/time.d.ts +1 -0
  118. package/dist/helpers/url.d.ts +6 -0
  119. package/dist/helpers/url.test.d.ts +1 -0
  120. package/dist/helpers/uuid.d.ts +8 -0
  121. package/dist/helpers/visitorId.d.ts +6 -0
  122. package/dist/index-helpers/blocks-exports.d.ts +8 -0
  123. package/dist/index-helpers/top-of-file.d.ts +1 -0
  124. package/dist/index.d.ts +15 -0
  125. package/dist/scripts/init-editing.d.ts +6 -0
  126. package/dist/types/api-version.d.ts +2 -0
  127. package/dist/types/builder-block.d.ts +66 -0
  128. package/dist/types/builder-content.d.ts +44 -0
  129. package/dist/types/can-track.d.ts +3 -0
  130. package/dist/types/components.d.ts +105 -0
  131. package/dist/types/deep-partial.d.ts +3 -0
  132. package/dist/types/element.d.ts +59 -0
  133. package/dist/types/input.d.ts +121 -0
  134. package/dist/types/targets.d.ts +3 -0
  135. package/dist/types/typescript.d.ts +5 -0
  136. package/package.json +1 -1
  137. package/src/blocks/img/component-info.js +1 -1
  138. package/src/components/render-block/render-block.jsx +21 -29
  139. package/src/components/render-block/render-repeated-block.jsx +5 -15
  140. package/src/components/render-blocks.jsx +1 -0
  141. package/src/components/render-content/render-content.jsx +77 -85
  142. package/src/components/render-content-variants/helpers.js +3 -1
  143. package/src/constants/sdk-version.js +1 -1
  144. package/dist/components/render-block/render-component-with-context.js +0 -45
  145. package/dist/functions/get-block-tag.js +0 -8
  146. package/dist/functions/get-content/ab-testing.js +0 -89
  147. package/dist/functions/track.js +0 -120
@@ -51,73 +51,51 @@ const logger_js_1 = require("../../helpers/logger.js");
51
51
  const helpers_js_1 = require("../render-content-variants/helpers.js");
52
52
  const wrap_component_ref_js_1 = require("./wrap-component-ref.js");
53
53
  function RenderContent(props) {
54
- var _a, _b, _c, _d, _e;
54
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
55
55
  const elementRef = (0, react_1.useRef)(null);
56
56
  const [forceReRenderCount, setForceReRenderCount] = (0, react_1.useState)(() => 0);
57
57
  const [overrideContent, setOverrideContent] = (0, react_1.useState)(() => null);
58
- const [useContent, setUseContent] = (0, react_1.useState)(() => (0, render_content_helpers_js_1.getContentInitialValue)({
59
- content: props.content,
60
- data: props.data,
61
- }));
62
58
  function mergeNewContent(newContent) {
63
- var _a, _b;
64
- setUseContent({
65
- ...useContent,
59
+ var _a, _b, _c, _d, _e;
60
+ builderContextSignal.content = {
61
+ ...builderContextSignal.content,
66
62
  ...newContent,
67
63
  data: {
68
- ...useContent === null || useContent === void 0 ? void 0 : useContent.data,
64
+ ...(_a = builderContextSignal.content) === null || _a === void 0 ? void 0 : _a.data,
69
65
  ...newContent === null || newContent === void 0 ? void 0 : newContent.data,
70
66
  },
71
67
  meta: {
72
- ...useContent === null || useContent === void 0 ? void 0 : useContent.meta,
68
+ ...(_b = builderContextSignal.content) === null || _b === void 0 ? void 0 : _b.meta,
73
69
  ...newContent === null || newContent === void 0 ? void 0 : newContent.meta,
74
- breakpoints: ((_a = newContent === null || newContent === void 0 ? void 0 : newContent.meta) === null || _a === void 0 ? void 0 : _a.breakpoints) || ((_b = useContent === null || useContent === void 0 ? void 0 : useContent.meta) === null || _b === void 0 ? void 0 : _b.breakpoints),
70
+ breakpoints: ((_c = newContent === null || newContent === void 0 ? void 0 : newContent.meta) === null || _c === void 0 ? void 0 : _c.breakpoints) ||
71
+ ((_e = (_d = builderContextSignal.content) === null || _d === void 0 ? void 0 : _d.meta) === null || _e === void 0 ? void 0 : _e.breakpoints),
75
72
  },
76
- });
73
+ };
77
74
  }
78
75
  function setBreakpoints(breakpoints) {
79
- setUseContent({
80
- ...useContent,
76
+ var _a;
77
+ builderContextSignal.content = {
78
+ ...builderContextSignal.content,
81
79
  meta: {
82
- ...useContent === null || useContent === void 0 ? void 0 : useContent.meta,
80
+ ...(_a = builderContextSignal.content) === null || _a === void 0 ? void 0 : _a.meta,
83
81
  breakpoints,
84
82
  },
85
- });
83
+ };
86
84
  }
87
85
  const [update, setUpdate] = (0, react_1.useState)(() => 0);
88
86
  const [canTrackToUse, setCanTrackToUse] = (0, react_1.useState)(() => (0, nullable_js_1.checkIsDefined)(props.canTrack) ? props.canTrack : true);
89
- const [contentState, setContentState] = (0, react_1.useState)(() => (0, render_content_helpers_js_1.getContextStateInitialValue)({
90
- content: props.content,
91
- data: props.data,
92
- locale: props.locale,
93
- }));
94
87
  function contentSetState(newRootState) {
95
- setContentState(newRootState);
88
+ builderContextSignal.rootState = newRootState;
96
89
  }
97
- const [allRegisteredComponents, setAllRegisteredComponents] = (0, react_1.useState)(() => [
98
- ...(0, builder_registered_components_js_1.getDefaultRegisteredComponents)(),
99
- // While this `components` object is deprecated, we must maintain support for it.
100
- // Since users are able to override our default components, we need to make sure that we do not break such
101
- // existing usage.
102
- // This is why we spread `components` after the default Builder.io components, but before the `props.customComponents`,
103
- // which is the new standard way of providing custom components, and must therefore take precedence.
104
- ...register_component_js_1.components,
105
- ...(props.customComponents || []),
106
- ].reduce((acc, { component, ...curr }) => ({
107
- ...acc,
108
- [curr.name]: {
109
- component: target_js_1.TARGET === "vue3" ? (0, wrap_component_ref_js_1.wrapComponentRef)(component) : component,
110
- ...curr,
111
- },
112
- }), {}));
113
90
  function processMessage(event) {
91
+ var _a;
114
92
  const { data } = event;
115
93
  if (data) {
116
94
  switch (data.type) {
117
95
  case "builder.configureSdk": {
118
96
  const messageContent = data.data;
119
97
  const { breakpoints, contentId } = messageContent;
120
- if (!contentId || contentId !== (useContent === null || useContent === void 0 ? void 0 : useContent.id)) {
98
+ if (!contentId || contentId !== ((_a = builderContextSignal.content) === null || _a === void 0 ? void 0 : _a.id)) {
121
99
  return;
122
100
  }
123
101
  if (breakpoints) {
@@ -147,15 +125,15 @@ function RenderContent(props) {
147
125
  }
148
126
  }
149
127
  function evaluateJsCode() {
150
- var _a;
128
+ var _a, _b;
151
129
  // run any dynamic JS code attached to content
152
- const jsCode = (_a = useContent === null || useContent === void 0 ? void 0 : useContent.data) === null || _a === void 0 ? void 0 : _a.jsCode;
130
+ const jsCode = (_b = (_a = builderContextSignal.content) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.jsCode;
153
131
  if (jsCode) {
154
132
  (0, evaluate_js_1.evaluate)({
155
133
  code: jsCode,
156
134
  context: props.context || {},
157
135
  localState: undefined,
158
- rootState: contentState,
136
+ rootState: builderContextSignal.rootState,
159
137
  rootSetState: contentSetState,
160
138
  });
161
139
  }
@@ -163,9 +141,10 @@ function RenderContent(props) {
163
141
  const [httpReqsData, setHttpReqsData] = (0, react_1.useState)(() => ({}));
164
142
  const [clicked, setClicked] = (0, react_1.useState)(() => false);
165
143
  function onClick(event) {
166
- if (useContent) {
167
- const variationId = useContent === null || useContent === void 0 ? void 0 : useContent.testVariationId;
168
- const contentId = useContent === null || useContent === void 0 ? void 0 : useContent.id;
144
+ var _a, _b;
145
+ if (builderContextSignal.content) {
146
+ const variationId = (_a = builderContextSignal.content) === null || _a === void 0 ? void 0 : _a.testVariationId;
147
+ const contentId = (_b = builderContextSignal.content) === null || _b === void 0 ? void 0 : _b.id;
169
148
  (0, index_js_2._track)({
170
149
  type: "click",
171
150
  canTrack: canTrackToUse,
@@ -185,7 +164,7 @@ function RenderContent(props) {
185
164
  code: group,
186
165
  context: props.context || {},
187
166
  localState: undefined,
188
- rootState: contentState,
167
+ rootState: builderContextSignal.rootState,
189
168
  rootSetState: contentSetState,
190
169
  }));
191
170
  }
@@ -194,7 +173,7 @@ function RenderContent(props) {
194
173
  .then((response) => response.json())
195
174
  .then((json) => {
196
175
  const newState = {
197
- ...contentState,
176
+ ...builderContextSignal.rootState,
198
177
  [key]: json,
199
178
  };
200
179
  contentSetState(newState);
@@ -204,8 +183,8 @@ function RenderContent(props) {
204
183
  });
205
184
  }
206
185
  function runHttpRequests() {
207
- var _a, _b;
208
- const requests = (_b = (_a = useContent === null || useContent === void 0 ? void 0 : useContent.data) === null || _a === void 0 ? void 0 : _a.httpRequests) !== null && _b !== void 0 ? _b : {};
186
+ var _a, _b, _c;
187
+ const requests = (_c = (_b = (_a = builderContextSignal.content) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.httpRequests) !== null && _c !== void 0 ? _c : {};
209
188
  Object.entries(requests).forEach(([key, url]) => {
210
189
  if (url && (!httpReqsData[key] || (0, is_editing_js_1.isEditing)())) {
211
190
  const evaluatedUrl = evalExpression(url);
@@ -220,7 +199,7 @@ function RenderContent(props) {
220
199
  if ((0, is_editing_js_1.isEditing)()) {
221
200
  window.dispatchEvent(new CustomEvent("builder:component:stateChange", {
222
201
  detail: {
223
- state: contentState,
202
+ state: builderContextSignal.rootState,
224
203
  ref: {
225
204
  name: props.model,
226
205
  },
@@ -236,7 +215,41 @@ function RenderContent(props) {
236
215
  parentContentId: props.parentContentId,
237
216
  });
238
217
  });
218
+ const [builderContextSignal, setBuilderContextSignal] = (0, react_1.useState)(() => ({
219
+ content: (0, render_content_helpers_js_1.getContentInitialValue)({
220
+ content: props.content,
221
+ data: props.data,
222
+ }),
223
+ localState: undefined,
224
+ rootState: (0, render_content_helpers_js_1.getContextStateInitialValue)({
225
+ content: props.content,
226
+ data: props.data,
227
+ locale: props.locale,
228
+ }),
229
+ rootSetState: contentSetState,
230
+ context: props.context || {},
231
+ apiKey: props.apiKey,
232
+ apiVersion: props.apiVersion,
233
+ registeredComponents: [
234
+ ...(0, builder_registered_components_js_1.getDefaultRegisteredComponents)(),
235
+ // While this `components` object is deprecated, we must maintain support for it.
236
+ // Since users are able to override our default components, we need to make sure that we do not break such
237
+ // existing usage.
238
+ // This is why we spread `components` after the default Builder.io components, but before the `props.customComponents`,
239
+ // which is the new standard way of providing custom components, and must therefore take precedence.
240
+ ...register_component_js_1.components,
241
+ ...(props.customComponents || []),
242
+ ].reduce((acc, { component, ...curr }) => ({
243
+ ...acc,
244
+ [curr.name]: {
245
+ component: target_js_1.TARGET === "vue3" ? (0, wrap_component_ref_js_1.wrapComponentRef)(component) : component,
246
+ ...curr,
247
+ },
248
+ }), {}),
249
+ inheritedStyles: {},
250
+ }));
239
251
  (0, react_1.useEffect)(() => {
252
+ var _a, _b;
240
253
  if (!props.apiKey) {
241
254
  logger_js_1.logger.error("No API key provided to `RenderContent` component. This can cause issues. Please provide an API key using the `apiKey` prop.");
242
255
  }
@@ -261,7 +274,7 @@ function RenderContent(props) {
261
274
  }
262
275
  : {}),
263
276
  });
264
- Object.values(allRegisteredComponents).forEach((registeredComponent) => {
277
+ Object.values(builderContextSignal.registeredComponents).forEach((registeredComponent) => {
265
278
  var _a;
266
279
  const message = (0, register_component_js_1.createRegisterComponentMessage)(registeredComponent);
267
280
  (_a = window.parent) === null || _a === void 0 ? void 0 : _a.postMessage(message, "*");
@@ -269,9 +282,9 @@ function RenderContent(props) {
269
282
  window.addEventListener("message", processMessage);
270
283
  window.addEventListener("builder:component:stateChangeListenerActivated", emitStateUpdate);
271
284
  }
272
- if (useContent) {
273
- const variationId = useContent === null || useContent === void 0 ? void 0 : useContent.testVariationId;
274
- const contentId = useContent === null || useContent === void 0 ? void 0 : useContent.id;
285
+ if (builderContextSignal.content) {
286
+ const variationId = (_a = builderContextSignal.content) === null || _a === void 0 ? void 0 : _a.testVariationId;
287
+ const contentId = (_b = builderContextSignal.content) === null || _b === void 0 ? void 0 : _b.id;
275
288
  (0, index_js_2._track)({
276
289
  type: "impression",
277
290
  canTrack: canTrackToUse,
@@ -319,13 +332,16 @@ function RenderContent(props) {
319
332
  }, [props.content]);
320
333
  (0, react_1.useEffect)(() => {
321
334
  evaluateJsCode();
322
- }, [(_a = useContent === null || useContent === void 0 ? void 0 : useContent.data) === null || _a === void 0 ? void 0 : _a.jsCode, contentState]);
335
+ }, [
336
+ (_b = (_a = builderContextSignal.content) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.jsCode,
337
+ builderContextSignal.rootState,
338
+ ]);
323
339
  (0, react_1.useEffect)(() => {
324
340
  runHttpRequests();
325
- }, [(_b = useContent === null || useContent === void 0 ? void 0 : useContent.data) === null || _b === void 0 ? void 0 : _b.httpRequests]);
341
+ }, [(_d = (_c = builderContextSignal.content) === null || _c === void 0 ? void 0 : _c.data) === null || _d === void 0 ? void 0 : _d.httpRequests]);
326
342
  (0, react_1.useEffect)(() => {
327
343
  emitStateUpdate();
328
- }, [contentState]);
344
+ }, [builderContextSignal.rootState]);
329
345
  (0, react_1.useEffect)(() => {
330
346
  return () => {
331
347
  if ((0, is_browser_js_1.isBrowser)()) {
@@ -334,18 +350,8 @@ function RenderContent(props) {
334
350
  }
335
351
  };
336
352
  }, []);
337
- return (React.createElement(builder_context_js_1.default.Provider, { value: {
338
- content: useContent,
339
- localState: undefined,
340
- rootState: contentState,
341
- rootSetState: target_js_1.TARGET === "qwik" ? undefined : contentSetState,
342
- context: props.context || {},
343
- apiKey: props.apiKey,
344
- apiVersion: props.apiVersion,
345
- registeredComponents: allRegisteredComponents,
346
- inheritedStyles: {},
347
- } }, useContent ? (React.createElement(React.Fragment, null,
348
- React.createElement(react_native_1.ScrollView, { ref: elementRef, onClick: (event) => onClick(event), "builder-content-id": useContent === null || useContent === void 0 ? void 0 : useContent.id, "builder-model": props.model, ...(target_js_1.TARGET === "reactNative"
353
+ return (React.createElement(builder_context_js_1.default.Provider, { value: builderContextSignal }, builderContextSignal.content ? (React.createElement(React.Fragment, null,
354
+ React.createElement(react_native_1.ScrollView, { ref: elementRef, onClick: (event) => onClick(event), "builder-content-id": (_e = builderContextSignal.content) === null || _e === void 0 ? void 0 : _e.id, "builder-model": props.model, ...(target_js_1.TARGET === "reactNative"
349
355
  ? {
350
356
  dataSet: {
351
357
  // 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.
@@ -361,7 +367,7 @@ function RenderContent(props) {
361
367
  props.isSsrAbTest ? (React.createElement(React.Fragment, null,
362
368
  React.createElement(react_native_1.ScrollView, { dangerouslySetInnerHTML: { __html: scriptStr } }))) : null,
363
369
  target_js_1.TARGET !== "reactNative" ? (React.createElement(React.Fragment, null,
364
- React.createElement(render_styles_1.default, { contentId: useContent === null || useContent === void 0 ? void 0 : useContent.id, cssCode: (_c = useContent === null || useContent === void 0 ? void 0 : useContent.data) === null || _c === void 0 ? void 0 : _c.cssCode, customFonts: (_d = useContent === null || useContent === void 0 ? void 0 : useContent.data) === null || _d === void 0 ? void 0 : _d.customFonts }))) : null,
365
- React.createElement(render_blocks_1.default, { blocks: (_e = useContent === null || useContent === void 0 ? void 0 : useContent.data) === null || _e === void 0 ? void 0 : _e.blocks, key: forceReRenderCount })))) : null));
370
+ React.createElement(render_styles_1.default, { contentId: (_f = builderContextSignal.content) === null || _f === void 0 ? void 0 : _f.id, cssCode: (_h = (_g = builderContextSignal.content) === null || _g === void 0 ? void 0 : _g.data) === null || _h === void 0 ? void 0 : _h.cssCode, customFonts: (_k = (_j = builderContextSignal.content) === null || _j === void 0 ? void 0 : _j.data) === null || _k === void 0 ? void 0 : _k.customFonts }))) : null,
371
+ React.createElement(render_blocks_1.default, { blocks: (_m = (_l = builderContextSignal.content) === null || _l === void 0 ? void 0 : _l.data) === null || _m === void 0 ? void 0 : _m.blocks, key: forceReRenderCount })))) : null));
366
372
  }
367
373
  exports.default = RenderContent;
@@ -0,0 +1,38 @@
1
+ import type { BuilderRenderContext, RegisteredComponent, BuilderRenderState } from '../../context/types';
2
+ import type { BuilderContent } from '../../types/builder-content';
3
+ import type { Nullable } from '../../types/typescript';
4
+ import type { ApiVersion } from '../../types/api-version';
5
+ export interface RenderContentProps {
6
+ content?: Nullable<BuilderContent>;
7
+ model?: string;
8
+ data?: {
9
+ [key: string]: any;
10
+ };
11
+ context?: BuilderRenderContext;
12
+ apiKey: string;
13
+ apiVersion?: ApiVersion;
14
+ customComponents?: RegisteredComponent[];
15
+ canTrack?: boolean;
16
+ locale?: string;
17
+ /** @deprecated use `enrich` instead **/
18
+ includeRefs?: boolean;
19
+ enrich?: boolean;
20
+ /**
21
+ * TO-DO: improve qwik generator to not remap this name for non-HTML tags, then name it `className`
22
+ */
23
+ classNameProp?: string;
24
+ hideContent?: boolean;
25
+ parentContentId?: string;
26
+ isSsrAbTest?: boolean;
27
+ }
28
+ export interface BuilderComponentStateChange {
29
+ state: BuilderRenderState;
30
+ ref: {
31
+ name?: string;
32
+ props?: {
33
+ builderBlock?: {
34
+ id?: string;
35
+ };
36
+ };
37
+ };
38
+ }
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Apply target-specific transformations to the component reference.
3
+ *
4
+ * See overrides/* for examples.
5
+ */
6
+ export declare const wrapComponentRef: (component: any) => any;
@@ -0,0 +1,17 @@
1
+ import type { Nullable } from '../../helpers/nullable';
2
+ import type { BuilderContent } from '../../types/builder-content';
3
+ export declare const getVariants: (content: Nullable<BuilderContent>) => import("../../types/builder-content").BuilderContentVariation[];
4
+ export declare const checkShouldRunVariants: ({ canTrack, content, }: {
5
+ canTrack: Nullable<boolean>;
6
+ content: Nullable<BuilderContent>;
7
+ }) => boolean;
8
+ type VariantData = {
9
+ id: string;
10
+ testRatio?: number;
11
+ };
12
+ export declare const getVariantsScriptString: (variants: VariantData[], contentId: string) => string;
13
+ export declare const getRenderContentScriptString: ({ parentContentId, contentId, }: {
14
+ contentId: string;
15
+ parentContentId: string;
16
+ }) => string;
17
+ export {};
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getVariantsScriptString = exports.getVariants = exports.getRenderContentScriptString = exports.checkShouldRunVariants = void 0;
4
+ const target_1 = require("../../constants/target");
4
5
  const is_browser_1 = require("../../functions/is-browser");
5
6
  const getVariants = (content) => Object.values((content == null ? void 0 : content.variations) || {});
6
7
  exports.getVariants = getVariants;
@@ -117,7 +118,8 @@ function bldrCntntScrpt(variantContentId, defaultContentId, isHydrationTarget2)
117
118
  }
118
119
  return;
119
120
  }
120
- const isHydrationTarget = (target) => target === "react" || target === "reactNative" || target === "vue3" || target === "vue2";
121
+ const getIsHydrationTarget = (target) => target === "react" || target === "reactNative" || target === "vue3" || target === "vue2";
122
+ const isHydrationTarget = getIsHydrationTarget(target_1.TARGET);
121
123
  const AB_TEST_FN_NAME = "bldrAbTest";
122
124
  const CONTENT_FN_NAME = "bldrCntntScrpt";
123
125
  const getVariantsScriptString = (variants, contentId) => {
@@ -0,0 +1,5 @@
1
+ /// <reference types="react" />
2
+ type VariantsProviderProps = RenderContentProps;
3
+ import type { RenderContentProps } from "../render-content/render-content.types";
4
+ declare function RenderContentVariants(props: VariantsProviderProps): JSX.Element;
5
+ export default RenderContentVariants;
@@ -0,0 +1,7 @@
1
+ /// <reference types="react" />
2
+ interface Props {
3
+ styles: string;
4
+ id?: string;
5
+ }
6
+ declare function RenderInlinedStyles(props: Props): JSX.Element;
7
+ export default RenderInlinedStyles;
@@ -0,0 +1,6 @@
1
+ import type { RegisteredComponent } from '../context/types.js';
2
+ /**
3
+ * Returns a list of all registered components.
4
+ * NOTE: This needs to be a function to work around ESM circular dependencies.
5
+ */
6
+ export declare const getDefaultRegisteredComponents: () => RegisteredComponent[];
@@ -0,0 +1,13 @@
1
+ export type SizeName = 'large' | 'medium' | 'small';
2
+ interface Size {
3
+ min: number;
4
+ default: number;
5
+ max: number;
6
+ }
7
+ export declare const getMaxWidthQueryForSize: (size: SizeName, sizeValues?: Record<SizeName, Size>) => string;
8
+ interface Breakpoints {
9
+ small?: number;
10
+ medium?: number;
11
+ }
12
+ export declare const getSizesForBreakpoints: ({ small, medium }: Breakpoints) => Record<SizeName, Size>;
13
+ export {};
@@ -0,0 +1 @@
1
+ export declare const SDK_VERSION = "UNKNOWN_VERSION";
@@ -1,4 +1,4 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.SDK_VERSION = void 0;
4
- exports.SDK_VERSION = "0.4.1";
4
+ exports.SDK_VERSION = "0.4.3";
@@ -0,0 +1,3 @@
1
+ type Target = import('../types/targets').Target;
2
+ export declare const TARGET: Target;
3
+ export {};
@@ -0,0 +1,3 @@
1
+ /// <reference types="react" />
2
+ declare const _default: React.Context<any>;
3
+ export default _default;
@@ -0,0 +1,35 @@
1
+ import type { BuilderContent } from '../types/builder-content.js';
2
+ import type { ComponentInfo } from '../types/components.js';
3
+ import type { Dictionary, Nullable } from '../types/typescript.js';
4
+ import type { ApiVersion } from '../types/api-version.js';
5
+ export type RegisteredComponent = ComponentInfo & {
6
+ component: any;
7
+ };
8
+ export type RegisteredComponents = Dictionary<RegisteredComponent>;
9
+ export type BuilderRenderState = Record<string, unknown>;
10
+ export type BuilderRenderContext = Record<string, unknown>;
11
+ export interface BuilderContextInterface {
12
+ content: Nullable<BuilderContent>;
13
+ context: BuilderRenderContext;
14
+ /**
15
+ * The state of the application.
16
+ *
17
+ * NOTE: see `localState` below to understand how it is different from `rootState`.
18
+ */
19
+ rootState: BuilderRenderState;
20
+ /**
21
+ * Some frameworks have a `setState` function which needs to be invoked to notify
22
+ * the framework of state change. (other frameworks don't in which case it is `undefined')
23
+ */
24
+ rootSetState: ((rootState: BuilderRenderState) => void) | undefined;
25
+ /**
26
+ * The local state of the current component. This is different from `rootState` in that
27
+ * it can be a child state created by a repeater containing local state.
28
+ * The `rootState` is where all of the state mutations are actually stored.
29
+ */
30
+ localState: BuilderRenderState | undefined;
31
+ apiKey: string | null;
32
+ apiVersion: ApiVersion | undefined;
33
+ registeredComponents: RegisteredComponents;
34
+ inheritedStyles: Record<string, unknown>;
35
+ }
@@ -0,0 +1 @@
1
+ export declare const camelToKebabCase: (string: string) => string;
@@ -0,0 +1,7 @@
1
+ import type { BuilderContextInterface, BuilderRenderState } from '../context/types.js';
2
+ export declare function evaluate({ code, context, localState, rootState, rootSetState, event, isExpression, }: {
3
+ code: string;
4
+ event?: Event;
5
+ isExpression?: boolean;
6
+ } & Pick<BuilderContextInterface, 'localState' | 'context' | 'rootState' | 'rootSetState'>): any;
7
+ export declare function flattenState(rootState: Record<string | symbol, any>, localState: Record<string | symbol, any> | undefined, rootSetState: ((rootState: BuilderRenderState) => void) | undefined): BuilderRenderState;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export declare const getEventHandlerName: (key: string) => string;
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Extract styles that apply to text from a style object.
3
+ */
4
+ export declare const extractTextStyles: (styles: Partial<CSSStyleDeclaration>) => Partial<CSSStyleDeclaration>;
@@ -0,0 +1,4 @@
1
+ /**
2
+ * We need to serialize values to a string in case there are Proxy values, as is the case with SolidJS etc.
3
+ */
4
+ export declare const fastClone: <T extends object>(obj: T) => T;
@@ -0,0 +1,8 @@
1
+ import type { BuilderContextInterface } from '../context/types.js';
2
+ import type { BuilderBlock } from '../types/builder-block.js';
3
+ type Options = {
4
+ block: BuilderBlock;
5
+ } & Pick<BuilderContextInterface, 'localState' | 'context' | 'rootState' | 'rootSetState'>;
6
+ type EventHandler = (event: Event) => any;
7
+ export declare const createEventHandler: (value: string, options: Options) => EventHandler;
8
+ export {};
@@ -0,0 +1,9 @@
1
+ import type { BuilderContextInterface } from '../context/types.js';
2
+ import type { BuilderBlock } from '../types/builder-block.js';
3
+ type Actions = {
4
+ [index: string]: (event: Event) => any;
5
+ };
6
+ export declare function getBlockActions(options: {
7
+ block: BuilderBlock;
8
+ } & Pick<BuilderContextInterface, 'localState' | 'context' | 'rootState' | 'rootSetState'>): Actions;
9
+ export {};
@@ -0,0 +1,2 @@
1
+ import type { BuilderBlock } from '../types/builder-block.js';
2
+ export declare function getBlockComponentOptions(block: BuilderBlock): any;
@@ -0,0 +1,2 @@
1
+ import type { BuilderBlock } from '../types/builder-block.js';
2
+ export declare function getBlockProperties(block: BuilderBlock): any;
@@ -0,0 +1,12 @@
1
+ type QueryObject = Record<string, string | string[]>;
2
+ export declare const convertSearchParamsToQueryObject: (searchParams: URLSearchParams) => QueryObject;
3
+ /**
4
+ * Receives a `URLSearchParams` object or a regular query object, and returns the subset of query params that are
5
+ * relevant to the Builder SDK.
6
+ *
7
+ * @returns
8
+ */
9
+ export declare const getBuilderSearchParams: (_options: QueryObject | URLSearchParams | undefined) => QueryObject;
10
+ export declare const getBuilderSearchParamsFromWindow: () => QueryObject;
11
+ export declare const normalizeSearchParams: (searchParams: QueryObject | URLSearchParams) => QueryObject;
12
+ export {};
@@ -0,0 +1,2 @@
1
+ import type { GetContentOptions } from './types.js';
2
+ export declare const generateContentUrl: (options: GetContentOptions) => URL;
@@ -0,0 +1,16 @@
1
+ import type { BuilderContent } from '../../types/builder-content.js';
2
+ import type { GetContentOptions } from './types.js';
3
+ export declare function getContent(options: GetContentOptions): Promise<BuilderContent | null>;
4
+ type ContentResults = {
5
+ results: BuilderContent[];
6
+ };
7
+ type ContentResponse = ContentResults | {
8
+ status: number;
9
+ message: string;
10
+ };
11
+ /**
12
+ * Exported only for testing purposes. Should not be used directly.
13
+ */
14
+ export declare const processContentResult: (options: GetContentOptions, content: ContentResults) => Promise<ContentResults>;
15
+ export declare function getAllContent(options: GetContentOptions): Promise<ContentResponse | null>;
16
+ export {};
@@ -0,0 +1,51 @@
1
+ export interface GetContentOptions {
2
+ /** The model to get content for */
3
+ model: string;
4
+ /** Your public API key */
5
+ apiKey: string;
6
+ /** Number of items to fetch. Default is 1 */
7
+ limit?: number;
8
+ /** User attributes to target on, such as { urlPath: '/foo', device: 'mobile', ...etc } */
9
+ userAttributes?: (Record<string, string> & {
10
+ urlPath?: string;
11
+ }) | null;
12
+ /** Custom query */
13
+ query?: Record<string, any>;
14
+ /**
15
+ * Any other API options.
16
+ * Accepts both a key/value object or a `URLSearchParams` instance
17
+ * */
18
+ options?: Record<string, any> | URLSearchParams;
19
+ /**
20
+ * If set to `true`, it will lazy load symbols/references.
21
+ * If set to `false`, it will render the entire content tree eagerly.
22
+ * @deprecated use `enrich` instead
23
+ */
24
+ noTraverse?: boolean;
25
+ /**
26
+ * If set to `false`, it will not use cookies to target content. Therefore, A/B Testing will be disabled and
27
+ * only the default variation will be returned to every user.
28
+ *
29
+ * Defaults to `true`.
30
+ */
31
+ canTrack?: boolean;
32
+ /**
33
+ * Include references in the response. Defaults to `true`.
34
+ * @deprecated use `enrich` instead
35
+ */
36
+ includeRefs?: boolean;
37
+ /**
38
+ * Include multilevel references in the response.
39
+ */
40
+ enrich?: boolean;
41
+ /**
42
+ * If provided, the API will auto-resolve localized objects to the value of this `locale` key.
43
+ */
44
+ locale?: string;
45
+ /**
46
+ * If provided, sets the Builder API version used to fetch content.
47
+ *
48
+ * Defaults to `v3`.
49
+ */
50
+ apiVersion?: 'v2' | 'v3';
51
+ }
@@ -0,0 +1 @@
1
+ export declare const fetch: any;
@@ -0,0 +1,10 @@
1
+ import type { BuilderContextInterface } from '../context/types.js';
2
+ import type { BuilderBlock } from '../types/builder-block.js';
3
+ export declare function getProcessedBlock({ block, context, shouldEvaluateBindings, localState, rootState, rootSetState, }: {
4
+ block: BuilderBlock;
5
+ /**
6
+ * In some cases, we want to avoid evaluating bindings and only want framework-specific block transformation. It is
7
+ * also sometimes too early to consider bindings, e.g. when we might be looking at a repeated block.
8
+ */
9
+ shouldEvaluateBindings: boolean;
10
+ } & Pick<BuilderContextInterface, 'localState' | 'context' | 'rootState' | 'rootSetState'>): BuilderBlock;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,7 @@
1
+ import type { BuilderContextInterface } from '../context/types.js';
2
+ import type { BuilderBlock } from '../types/builder-block.js';
3
+ export declare function getReactNativeBlockStyles({ block, context, blockStyles, }: {
4
+ block: BuilderBlock;
5
+ context: BuilderContextInterface;
6
+ blockStyles: any;
7
+ }): CSSStyleDeclaration | Record<string, string | undefined>;