@builder.io/sdk-react-native 0.4.1 → 0.4.2
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/BaseText.d.ts +6 -0
- package/dist/blocks/button/button.d.ts +9 -0
- package/dist/blocks/button/component-info.d.ts +2 -0
- package/dist/blocks/columns/columns.d.ts +16 -0
- package/dist/blocks/columns/component-info.d.ts +2 -0
- package/dist/blocks/custom-code/component-info.d.ts +2 -0
- package/dist/blocks/custom-code/custom-code.d.ts +5 -0
- package/dist/blocks/embed/component-info.d.ts +2 -0
- package/dist/blocks/embed/embed.d.ts +5 -0
- package/dist/blocks/embed/helpers.d.ts +1 -0
- package/dist/blocks/form/component-info.d.ts +2 -0
- package/dist/blocks/form/form.d.ts +28 -0
- package/dist/blocks/fragment/component-info.d.ts +2 -0
- package/dist/blocks/fragment/fragment.d.ts +8 -0
- package/dist/blocks/image/component-info.d.ts +2 -0
- package/dist/blocks/image/image.d.ts +17 -0
- package/dist/blocks/image/image.helpers.d.ts +1 -0
- package/dist/blocks/img/component-info.d.ts +2 -0
- package/dist/blocks/img/component-info.js +1 -1
- package/dist/blocks/img/img.d.ts +11 -0
- package/dist/blocks/input/component-info.d.ts +2 -0
- package/dist/blocks/input/input.d.ts +12 -0
- package/dist/blocks/raw-text/component-info.d.ts +2 -0
- package/dist/blocks/raw-text/raw-text.d.ts +5 -0
- package/dist/blocks/section/component-info.d.ts +2 -0
- package/dist/blocks/section/section.d.ts +9 -0
- package/dist/blocks/select/component-info.d.ts +2 -0
- package/dist/blocks/select/select.d.ts +13 -0
- package/dist/blocks/submit-button/component-info.d.ts +2 -0
- package/dist/blocks/submit-button/submit-button.d.ts +7 -0
- package/dist/blocks/symbol/component-info.d.ts +2 -0
- package/dist/blocks/symbol/symbol.d.ts +21 -0
- package/dist/blocks/text/component-info.d.ts +2 -0
- package/dist/blocks/text/text.d.ts +7 -0
- package/dist/blocks/textarea/component-info.d.ts +2 -0
- package/dist/blocks/textarea/textarea.d.ts +10 -0
- package/dist/blocks/util.d.ts +4 -0
- package/dist/blocks/video/component-info.d.ts +2 -0
- package/dist/blocks/video/video.d.ts +31 -0
- package/dist/components/render-block/block-styles.d.ts +9 -0
- package/dist/components/render-block/render-block.d.ts +9 -0
- package/dist/components/render-block/render-block.helpers.d.ts +12 -0
- package/dist/components/render-block/render-block.js +18 -26
- package/dist/components/render-block/render-component.d.ts +17 -0
- package/dist/components/render-block/render-repeated-block.d.ts +9 -0
- package/dist/components/render-block/render-repeated-block.js +3 -12
- package/dist/components/render-block/types.d.ts +6 -0
- package/dist/components/render-blocks.d.ts +10 -0
- package/dist/components/render-blocks.js +1 -1
- package/dist/components/render-content/builder-editing.d.ts +3 -0
- package/dist/components/render-content/components/render-styles.d.ts +9 -0
- package/dist/components/render-content/components/render-styles.helpers.d.ts +15 -0
- package/dist/components/render-content/index.d.ts +1 -0
- package/dist/components/render-content/render-content.d.ts +4 -0
- package/dist/components/render-content/render-content.helpers.d.ts +7 -0
- package/dist/components/render-content/render-content.js +77 -71
- package/dist/components/render-content/render-content.types.d.ts +38 -0
- package/dist/components/render-content/wrap-component-ref.d.ts +6 -0
- package/dist/components/render-content-variants/helpers.d.ts +17 -0
- package/dist/components/render-content-variants/render-content-variants.d.ts +5 -0
- package/dist/components/render-inlined-styles.d.ts +7 -0
- package/dist/constants/builder-registered-components.d.ts +6 -0
- package/dist/constants/device-sizes.d.ts +13 -0
- package/dist/constants/sdk-version.d.ts +1 -0
- package/dist/constants/sdk-version.js +1 -1
- package/dist/constants/target.d.ts +3 -0
- package/dist/context/builder.context.d.ts +3 -0
- package/dist/context/types.d.ts +35 -0
- package/dist/functions/camel-to-kebab-case.d.ts +1 -0
- package/dist/functions/evaluate.d.ts +7 -0
- package/dist/functions/evaluate.test.d.ts +1 -0
- package/dist/functions/event-handler-name.d.ts +1 -0
- package/dist/functions/extract-text-styles.d.ts +4 -0
- package/dist/functions/fast-clone.d.ts +4 -0
- package/dist/functions/get-block-actions-handler.d.ts +8 -0
- package/dist/functions/get-block-actions.d.ts +9 -0
- package/dist/functions/get-block-component-options.d.ts +2 -0
- package/dist/functions/get-block-properties.d.ts +2 -0
- package/dist/functions/get-builder-search-params/fn.test.d.ts +1 -0
- package/dist/functions/get-builder-search-params/index.d.ts +12 -0
- package/dist/functions/get-content/generate-content-url.d.ts +2 -0
- package/dist/functions/get-content/generate-content-url.test.d.ts +1 -0
- package/dist/functions/get-content/index.d.ts +16 -0
- package/dist/functions/get-content/types.d.ts +51 -0
- package/dist/functions/get-fetch.d.ts +1 -0
- package/dist/functions/get-processed-block.d.ts +10 -0
- package/dist/functions/get-processed-block.test.d.ts +1 -0
- package/dist/functions/get-react-native-block-styles.d.ts +7 -0
- package/dist/functions/if-target.d.ts +7 -0
- package/dist/functions/is-browser.d.ts +1 -0
- package/dist/functions/is-editing.d.ts +1 -0
- package/dist/functions/is-iframe.d.ts +1 -0
- package/dist/functions/is-previewing.d.ts +1 -0
- package/dist/functions/on-change.d.ts +7 -0
- package/dist/functions/on-change.test.d.ts +1 -0
- package/dist/functions/register-component.d.ts +14 -0
- package/dist/functions/register.d.ts +16 -0
- package/dist/functions/sanitize-react-native-block-styles.d.ts +3 -0
- package/dist/functions/set-editor-settings.d.ts +4 -0
- package/dist/functions/set.d.ts +7 -0
- package/dist/functions/set.test.d.ts +1 -0
- package/dist/functions/track/helpers.d.ts +5 -0
- package/dist/functions/track/index.d.ts +51 -0
- package/dist/functions/track/interaction.d.ts +13 -0
- package/dist/functions/transform-block-properties.d.ts +3 -0
- package/dist/functions/transform-block.d.ts +2 -0
- package/dist/helpers/ab-tests.d.ts +9 -0
- package/dist/helpers/canTrack.d.ts +1 -0
- package/dist/helpers/cookie.d.ts +9 -0
- package/dist/helpers/css.d.ts +7 -0
- package/dist/helpers/flatten.d.ts +6 -0
- package/dist/helpers/localStorage.d.ts +9 -0
- package/dist/helpers/logger.d.ts +6 -0
- package/dist/helpers/nullable.d.ts +2 -0
- package/dist/helpers/sessionId.d.ts +6 -0
- package/dist/helpers/time.d.ts +1 -0
- package/dist/helpers/url.d.ts +6 -0
- package/dist/helpers/url.test.d.ts +1 -0
- package/dist/helpers/uuid.d.ts +8 -0
- package/dist/helpers/visitorId.d.ts +6 -0
- package/dist/index-helpers/blocks-exports.d.ts +8 -0
- package/dist/index-helpers/top-of-file.d.ts +1 -0
- package/dist/index.d.ts +15 -0
- package/dist/scripts/init-editing.d.ts +6 -0
- package/dist/types/api-version.d.ts +2 -0
- package/dist/types/builder-block.d.ts +66 -0
- package/dist/types/builder-content.d.ts +44 -0
- package/dist/types/can-track.d.ts +3 -0
- package/dist/types/components.d.ts +105 -0
- package/dist/types/deep-partial.d.ts +3 -0
- package/dist/types/element.d.ts +59 -0
- package/dist/types/input.d.ts +121 -0
- package/dist/types/targets.d.ts +3 -0
- package/dist/types/typescript.d.ts +5 -0
- package/package.json +1 -1
- package/src/blocks/img/component-info.js +1 -1
- package/src/components/render-block/render-block.jsx +21 -29
- package/src/components/render-block/render-repeated-block.jsx +5 -15
- package/src/components/render-blocks.jsx +1 -0
- package/src/components/render-content/render-content.jsx +77 -85
- package/src/constants/sdk-version.js +1 -1
- package/dist/components/render-block/render-component-with-context.js +0 -45
- package/dist/functions/get-block-tag.js +0 -8
- package/dist/functions/get-content/ab-testing.js +0 -89
- 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
|
-
|
|
65
|
-
...
|
|
59
|
+
var _a, _b, _c, _d, _e;
|
|
60
|
+
builderContextSignal.content = {
|
|
61
|
+
...builderContextSignal.content,
|
|
66
62
|
...newContent,
|
|
67
63
|
data: {
|
|
68
|
-
...
|
|
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
|
-
...
|
|
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: ((
|
|
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
|
-
|
|
80
|
-
|
|
76
|
+
var _a;
|
|
77
|
+
builderContextSignal.content = {
|
|
78
|
+
...builderContextSignal.content,
|
|
81
79
|
meta: {
|
|
82
|
-
...
|
|
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
|
-
|
|
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 !== (
|
|
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 =
|
|
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:
|
|
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
|
-
|
|
167
|
-
|
|
168
|
-
const
|
|
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:
|
|
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
|
-
...
|
|
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 =
|
|
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:
|
|
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(
|
|
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 (
|
|
273
|
-
const variationId =
|
|
274
|
-
const contentId =
|
|
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
|
-
}, [
|
|
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
|
-
}, [(
|
|
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
|
-
}, [
|
|
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
|
-
|
|
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:
|
|
365
|
-
React.createElement(render_blocks_1.default, { blocks: (
|
|
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,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 {};
|
|
@@ -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,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";
|
|
@@ -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,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 @@
|
|
|
1
|
+
export {};
|
|
@@ -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 @@
|
|
|
1
|
+
export {};
|
|
@@ -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>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function isBrowser(): boolean;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function isEditing(): boolean;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function isIframe(): boolean;
|