@builder.io/sdk-qwik 0.0.7 → 0.0.10
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/README.md +65 -2
- package/lib/index.97024df8.js +80165 -0
- package/lib/index.d8c1e37f.cjs +80165 -0
- package/lib/index.qwik.cjs +2465 -0
- package/lib/index.qwik.mjs +2465 -0
- package/package.json +3 -3
- package/src/blocks/button/button.jsx +0 -175
- package/src/blocks/columns/columns.jsx +27 -197
- package/src/blocks/custom-code/custom-code.jsx +16 -75
- package/src/blocks/embed/embed.jsx +20 -87
- package/src/blocks/form/builder-blocks.jsx +0 -75
- package/src/blocks/form/form.jsx +57 -536
- package/src/blocks/fragment/fragment.jsx +8 -56
- package/src/blocks/image/image.jsx +49 -493
- package/src/blocks/img/img.jsx +15 -72
- package/src/blocks/input/input.jsx +17 -83
- package/src/blocks/raw-text/raw-text.jsx +9 -50
- package/src/blocks/section/section.jsx +17 -94
- package/src/blocks/select/select.jsx +20 -145
- package/src/blocks/submit-button/submit-button.jsx +8 -84
- package/src/blocks/symbol/symbol.jsx +60 -194
- package/src/blocks/text/text.jsx +4 -43
- package/src/blocks/textarea/textarea.jsx +12 -62
- package/src/blocks/video/video.jsx +21 -71
- package/src/components/render-block/block-styles.jsx +0 -114
- package/src/components/render-block/render-block.jsx +0 -514
- package/src/components/render-block/render-component.jsx +0 -211
- package/src/components/render-block/render-repeated-block.jsx +0 -67
- package/src/components/render-blocks.jsx +40 -334
- package/src/components/render-content/components/render-styles.jsx +0 -50
- package/src/components/render-content/render-content.jsx +96 -374
- package/src/components/render-inlined-styles.jsx +0 -116
- package/src/scripts/init-editing.js +4 -5
- package/types.d.ts +7 -12
- package/root.json +0 -1176
|
@@ -14,6 +14,10 @@ import {
|
|
|
14
14
|
createRegisterComponentMessage,
|
|
15
15
|
} from "../../functions/register-component.js";
|
|
16
16
|
import { track } from "../../functions/track.js";
|
|
17
|
+
import {
|
|
18
|
+
registerInsertMenu,
|
|
19
|
+
setupBrowserForEditing,
|
|
20
|
+
} from "../../scripts/init-editing.js";
|
|
17
21
|
import RenderBlocks from "../render-blocks";
|
|
18
22
|
import RenderContentStyles from "./components/render-styles";
|
|
19
23
|
import {
|
|
@@ -24,11 +28,11 @@ import {
|
|
|
24
28
|
useCleanup$,
|
|
25
29
|
useClientEffect$,
|
|
26
30
|
useContextProvider,
|
|
27
|
-
|
|
31
|
+
useRef,
|
|
28
32
|
useStore,
|
|
29
33
|
useWatch$,
|
|
30
34
|
} from "@builder.io/qwik";
|
|
31
|
-
export const useContent = function useContent(props, state) {
|
|
35
|
+
export const useContent = function useContent(props, state, elementRef) {
|
|
32
36
|
const mergedContent = {
|
|
33
37
|
...props.content,
|
|
34
38
|
...state.overrideContent,
|
|
@@ -40,19 +44,24 @@ export const useContent = function useContent(props, state) {
|
|
|
40
44
|
};
|
|
41
45
|
return mergedContent;
|
|
42
46
|
};
|
|
43
|
-
export const contentState = function contentState(props, state) {
|
|
47
|
+
export const contentState = function contentState(props, state, elementRef) {
|
|
44
48
|
return {
|
|
45
49
|
...props.content?.data?.state,
|
|
46
50
|
...props.data,
|
|
47
51
|
...state.overrideState,
|
|
48
52
|
};
|
|
49
53
|
};
|
|
50
|
-
export const contextContext = function contextContext(
|
|
54
|
+
export const contextContext = function contextContext(
|
|
55
|
+
props,
|
|
56
|
+
state,
|
|
57
|
+
elementRef
|
|
58
|
+
) {
|
|
51
59
|
return props.context || {};
|
|
52
60
|
};
|
|
53
61
|
export const allRegisteredComponents = function allRegisteredComponents(
|
|
54
62
|
props,
|
|
55
|
-
state
|
|
63
|
+
state,
|
|
64
|
+
elementRef
|
|
56
65
|
) {
|
|
57
66
|
const allComponentsArray = [
|
|
58
67
|
...getDefaultRegisteredComponents(), // While this `components` object is deprecated, we must maintain support for it.
|
|
@@ -69,7 +78,12 @@ export const allRegisteredComponents = function allRegisteredComponents(
|
|
|
69
78
|
);
|
|
70
79
|
return allComponents;
|
|
71
80
|
};
|
|
72
|
-
export const processMessage = function processMessage(
|
|
81
|
+
export const processMessage = function processMessage(
|
|
82
|
+
props,
|
|
83
|
+
state,
|
|
84
|
+
elementRef,
|
|
85
|
+
event
|
|
86
|
+
) {
|
|
73
87
|
const { data } = event;
|
|
74
88
|
|
|
75
89
|
if (data) {
|
|
@@ -97,44 +111,50 @@ export const processMessage = function processMessage(props, state, event) {
|
|
|
97
111
|
}
|
|
98
112
|
}
|
|
99
113
|
};
|
|
100
|
-
export const evaluateJsCode = function evaluateJsCode(
|
|
114
|
+
export const evaluateJsCode = function evaluateJsCode(
|
|
115
|
+
props,
|
|
116
|
+
state,
|
|
117
|
+
elementRef
|
|
118
|
+
) {
|
|
101
119
|
// run any dynamic JS code attached to content
|
|
102
|
-
const jsCode = useContent(props, state)?.data?.jsCode;
|
|
120
|
+
const jsCode = useContent(props, state, elementRef)?.data?.jsCode;
|
|
103
121
|
|
|
104
122
|
if (jsCode) {
|
|
105
123
|
evaluate({
|
|
106
124
|
code: jsCode,
|
|
107
|
-
context: contextContext(props, state),
|
|
108
|
-
state: contentState(props, state),
|
|
125
|
+
context: contextContext(props, state, elementRef),
|
|
126
|
+
state: contentState(props, state, elementRef),
|
|
109
127
|
});
|
|
110
128
|
}
|
|
111
129
|
};
|
|
112
|
-
export const httpReqsData = function httpReqsData(props, state) {
|
|
130
|
+
export const httpReqsData = function httpReqsData(props, state, elementRef) {
|
|
113
131
|
return {};
|
|
114
132
|
};
|
|
115
|
-
export const onClick = function onClick(props, state, _event) {
|
|
116
|
-
if (useContent(props, state) && props.canTrack !== false) {
|
|
133
|
+
export const onClick = function onClick(props, state, elementRef, _event) {
|
|
134
|
+
if (useContent(props, state, elementRef) && props.canTrack !== false) {
|
|
117
135
|
track("click", {
|
|
118
|
-
contentId: useContent(props, state).id,
|
|
136
|
+
contentId: useContent(props, state, elementRef).id,
|
|
119
137
|
});
|
|
120
138
|
}
|
|
121
139
|
};
|
|
122
140
|
export const evalExpression = function evalExpression(
|
|
123
141
|
props,
|
|
124
142
|
state,
|
|
143
|
+
elementRef,
|
|
125
144
|
expression
|
|
126
145
|
) {
|
|
127
146
|
return expression.replace(/{{([^}]+)}}/g, (_match, group) =>
|
|
128
147
|
evaluate({
|
|
129
148
|
code: group,
|
|
130
|
-
context: contextContext(props, state),
|
|
131
|
-
state: contentState(props, state),
|
|
149
|
+
context: contextContext(props, state, elementRef),
|
|
150
|
+
state: contentState(props, state, elementRef),
|
|
132
151
|
})
|
|
133
152
|
);
|
|
134
153
|
};
|
|
135
154
|
export const handleRequest = function handleRequest(
|
|
136
155
|
props,
|
|
137
156
|
state,
|
|
157
|
+
elementRef,
|
|
138
158
|
{ url, key }
|
|
139
159
|
) {
|
|
140
160
|
const fetchAndSetState = async () => {
|
|
@@ -147,24 +167,33 @@ export const handleRequest = function handleRequest(
|
|
|
147
167
|
|
|
148
168
|
fetchAndSetState();
|
|
149
169
|
};
|
|
150
|
-
export const runHttpRequests = function runHttpRequests(
|
|
151
|
-
|
|
170
|
+
export const runHttpRequests = function runHttpRequests(
|
|
171
|
+
props,
|
|
172
|
+
state,
|
|
173
|
+
elementRef
|
|
174
|
+
) {
|
|
175
|
+
const requests =
|
|
176
|
+
useContent(props, state, elementRef)?.data?.httpRequests ?? {};
|
|
152
177
|
Object.entries(requests).forEach(([key, url]) => {
|
|
153
|
-
if (url && (!httpReqsData(props, state)[key] || isEditing())) {
|
|
154
|
-
const evaluatedUrl = evalExpression(props, state, url);
|
|
155
|
-
handleRequest(props, state, {
|
|
178
|
+
if (url && (!httpReqsData(props, state, elementRef)[key] || isEditing())) {
|
|
179
|
+
const evaluatedUrl = evalExpression(props, state, elementRef, url);
|
|
180
|
+
handleRequest(props, state, elementRef, {
|
|
156
181
|
url: evaluatedUrl,
|
|
157
182
|
key,
|
|
158
183
|
});
|
|
159
184
|
}
|
|
160
185
|
});
|
|
161
186
|
};
|
|
162
|
-
export const emitStateUpdate = function emitStateUpdate(
|
|
187
|
+
export const emitStateUpdate = function emitStateUpdate(
|
|
188
|
+
props,
|
|
189
|
+
state,
|
|
190
|
+
elementRef
|
|
191
|
+
) {
|
|
163
192
|
if (isEditing()) {
|
|
164
193
|
window.dispatchEvent(
|
|
165
194
|
new CustomEvent("builder:component:stateChange", {
|
|
166
195
|
detail: {
|
|
167
|
-
state: contentState(props, state),
|
|
196
|
+
state: contentState(props, state, elementRef),
|
|
168
197
|
ref: {
|
|
169
198
|
name: props.model,
|
|
170
199
|
},
|
|
@@ -175,17 +204,19 @@ export const emitStateUpdate = function emitStateUpdate(props, state) {
|
|
|
175
204
|
};
|
|
176
205
|
export const shouldRenderContentStyles = function shouldRenderContentStyles(
|
|
177
206
|
props,
|
|
178
|
-
state
|
|
207
|
+
state,
|
|
208
|
+
elementRef
|
|
179
209
|
) {
|
|
180
210
|
return Boolean(
|
|
181
|
-
(useContent(props, state)?.data?.cssCode ||
|
|
182
|
-
useContent(props, state)?.data?.customFonts?.length) &&
|
|
211
|
+
(useContent(props, state, elementRef)?.data?.cssCode ||
|
|
212
|
+
useContent(props, state, elementRef)?.data?.customFonts?.length) &&
|
|
183
213
|
TARGET !== "reactNative"
|
|
184
214
|
);
|
|
185
215
|
};
|
|
186
216
|
export const RenderContent = component$((props) => {
|
|
187
|
-
const
|
|
217
|
+
const elementRef = useRef();
|
|
188
218
|
const state = useStore({
|
|
219
|
+
forceReRenderCount: 0,
|
|
189
220
|
overrideContent: null,
|
|
190
221
|
update: 0,
|
|
191
222
|
overrideState: {},
|
|
@@ -194,45 +225,49 @@ export const RenderContent = component$((props) => {
|
|
|
194
225
|
BuilderContext,
|
|
195
226
|
useStore({
|
|
196
227
|
content: (() => {
|
|
197
|
-
return useContent(props, state);
|
|
228
|
+
return useContent(props, state, elementRef);
|
|
198
229
|
})(),
|
|
199
230
|
state: (() => {
|
|
200
|
-
return contentState(props, state);
|
|
231
|
+
return contentState(props, state, elementRef);
|
|
201
232
|
})(),
|
|
202
233
|
context: (() => {
|
|
203
|
-
return contextContext(props, state);
|
|
234
|
+
return contextContext(props, state, elementRef);
|
|
204
235
|
})(),
|
|
205
236
|
apiKey: (() => {
|
|
206
237
|
return props.apiKey;
|
|
207
238
|
})(),
|
|
208
239
|
registeredComponents: (() => {
|
|
209
|
-
return allRegisteredComponents(props, state);
|
|
240
|
+
return allRegisteredComponents(props, state, elementRef);
|
|
210
241
|
})(),
|
|
211
242
|
})
|
|
212
243
|
);
|
|
213
244
|
useClientEffect$(() => {
|
|
214
245
|
if (isBrowser()) {
|
|
215
246
|
if (isEditing()) {
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
247
|
+
state.forceReRenderCount++;
|
|
248
|
+
_useMutableProps(elementRef.current, true);
|
|
249
|
+
|
|
250
|
+
registerInsertMenu();
|
|
251
|
+
setupBrowserForEditing();
|
|
252
|
+
Object.values(
|
|
253
|
+
allRegisteredComponents(props, state, elementRef)
|
|
254
|
+
).forEach((registeredComponent) => {
|
|
255
|
+
const message = createRegisterComponentMessage(registeredComponent);
|
|
256
|
+
window.parent?.postMessage(message, "*");
|
|
257
|
+
});
|
|
223
258
|
window.addEventListener(
|
|
224
259
|
"message",
|
|
225
|
-
processMessage.bind(null, props, state)
|
|
260
|
+
processMessage.bind(null, props, state, elementRef)
|
|
226
261
|
);
|
|
227
262
|
window.addEventListener(
|
|
228
263
|
"builder:component:stateChangeListenerActivated",
|
|
229
|
-
emitStateUpdate.bind(null, props, state)
|
|
264
|
+
emitStateUpdate.bind(null, props, state, elementRef)
|
|
230
265
|
);
|
|
231
266
|
}
|
|
232
267
|
|
|
233
|
-
if (useContent(props, state) && props.canTrack !== false) {
|
|
268
|
+
if (useContent(props, state, elementRef) && props.canTrack !== false) {
|
|
234
269
|
track("impression", {
|
|
235
|
-
contentId: useContent(props, state).id,
|
|
270
|
+
contentId: useContent(props, state, elementRef).id,
|
|
236
271
|
});
|
|
237
272
|
} // override normal content in preview mode
|
|
238
273
|
|
|
@@ -259,50 +294,54 @@ export const RenderContent = component$((props) => {
|
|
|
259
294
|
}
|
|
260
295
|
}
|
|
261
296
|
|
|
262
|
-
evaluateJsCode(props, state);
|
|
263
|
-
runHttpRequests(props, state);
|
|
264
|
-
emitStateUpdate(props, state);
|
|
297
|
+
evaluateJsCode(props, state, elementRef);
|
|
298
|
+
runHttpRequests(props, state, elementRef);
|
|
299
|
+
emitStateUpdate(props, state, elementRef);
|
|
265
300
|
}
|
|
266
301
|
});
|
|
267
302
|
useWatch$(({ track }) => {
|
|
268
303
|
state.useContent?.data && track(state.useContent?.data, "jsCode");
|
|
269
|
-
evaluateJsCode(props, state);
|
|
304
|
+
evaluateJsCode(props, state, elementRef);
|
|
270
305
|
});
|
|
271
306
|
useWatch$(({ track }) => {
|
|
272
307
|
state.useContent?.data && track(state.useContent?.data, "httpRequests");
|
|
273
|
-
runHttpRequests(props, state);
|
|
308
|
+
runHttpRequests(props, state, elementRef);
|
|
274
309
|
});
|
|
275
310
|
useWatch$(({ track }) => {
|
|
276
311
|
state && track(state, "contentState");
|
|
277
|
-
emitStateUpdate(props, state);
|
|
312
|
+
emitStateUpdate(props, state, elementRef);
|
|
278
313
|
});
|
|
279
314
|
useCleanup$(() => {
|
|
280
315
|
if (isBrowser()) {
|
|
281
316
|
window.removeEventListener(
|
|
282
317
|
"message",
|
|
283
|
-
processMessage.bind(null, props, state)
|
|
318
|
+
processMessage.bind(null, props, state, elementRef)
|
|
284
319
|
);
|
|
285
320
|
window.removeEventListener(
|
|
286
321
|
"builder:component:stateChangeListenerActivated",
|
|
287
|
-
emitStateUpdate.bind(null, props, state)
|
|
322
|
+
emitStateUpdate.bind(null, props, state, elementRef)
|
|
288
323
|
);
|
|
289
324
|
}
|
|
290
325
|
});
|
|
291
326
|
return (
|
|
292
327
|
<>
|
|
293
|
-
{useContent(props, state) ? (
|
|
328
|
+
{useContent(props, state, elementRef) ? (
|
|
294
329
|
<div
|
|
295
|
-
|
|
296
|
-
|
|
330
|
+
ref={elementRef}
|
|
331
|
+
onClick$={(event) => onClick(props, state, elementRef, event)}
|
|
332
|
+
builder-content-id={useContent(props, state, elementRef)?.id}
|
|
297
333
|
>
|
|
298
|
-
{shouldRenderContentStyles(props, state) ? (
|
|
334
|
+
{shouldRenderContentStyles(props, state, elementRef) ? (
|
|
299
335
|
<RenderContentStyles
|
|
300
|
-
cssCode={useContent(props, state)?.data?.cssCode}
|
|
301
|
-
customFonts={
|
|
336
|
+
cssCode={useContent(props, state, elementRef)?.data?.cssCode}
|
|
337
|
+
customFonts={
|
|
338
|
+
useContent(props, state, elementRef)?.data?.customFonts
|
|
339
|
+
}
|
|
302
340
|
></RenderContentStyles>
|
|
303
341
|
) : null}
|
|
304
342
|
<RenderBlocks
|
|
305
|
-
blocks={useContent(props, state)?.data?.blocks}
|
|
343
|
+
blocks={useContent(props, state, elementRef)?.data?.blocks}
|
|
344
|
+
key={state.forceReRenderCount}
|
|
306
345
|
></RenderBlocks>
|
|
307
346
|
</div>
|
|
308
347
|
) : null}
|
|
@@ -310,320 +349,3 @@ export const RenderContent = component$((props) => {
|
|
|
310
349
|
);
|
|
311
350
|
});
|
|
312
351
|
export default RenderContent;
|
|
313
|
-
export const COMPONENT = {
|
|
314
|
-
"@type": "@builder.io/mitosis/component",
|
|
315
|
-
imports: [
|
|
316
|
-
{
|
|
317
|
-
imports: {
|
|
318
|
-
getDefaultRegisteredComponents: "getDefaultRegisteredComponents",
|
|
319
|
-
},
|
|
320
|
-
path: "../../constants/builder-registered-components.js",
|
|
321
|
-
},
|
|
322
|
-
{
|
|
323
|
-
imports: {
|
|
324
|
-
TARGET: "TARGET",
|
|
325
|
-
},
|
|
326
|
-
path: "../../constants/target.js",
|
|
327
|
-
},
|
|
328
|
-
{
|
|
329
|
-
imports: {
|
|
330
|
-
BuilderContext: "default",
|
|
331
|
-
},
|
|
332
|
-
path: "../../context/builder.context.lite",
|
|
333
|
-
},
|
|
334
|
-
{
|
|
335
|
-
imports: {
|
|
336
|
-
evaluate: "evaluate",
|
|
337
|
-
},
|
|
338
|
-
path: "../../functions/evaluate.js",
|
|
339
|
-
},
|
|
340
|
-
{
|
|
341
|
-
imports: {
|
|
342
|
-
getContent: "getContent",
|
|
343
|
-
},
|
|
344
|
-
path: "../../functions/get-content/index.js",
|
|
345
|
-
},
|
|
346
|
-
{
|
|
347
|
-
imports: {
|
|
348
|
-
getFetch: "getFetch",
|
|
349
|
-
},
|
|
350
|
-
path: "../../functions/get-fetch.js",
|
|
351
|
-
},
|
|
352
|
-
{
|
|
353
|
-
imports: {
|
|
354
|
-
isBrowser: "isBrowser",
|
|
355
|
-
},
|
|
356
|
-
path: "../../functions/is-browser.js",
|
|
357
|
-
},
|
|
358
|
-
{
|
|
359
|
-
imports: {
|
|
360
|
-
isEditing: "isEditing",
|
|
361
|
-
},
|
|
362
|
-
path: "../../functions/is-editing.js",
|
|
363
|
-
},
|
|
364
|
-
{
|
|
365
|
-
imports: {
|
|
366
|
-
isPreviewing: "isPreviewing",
|
|
367
|
-
},
|
|
368
|
-
path: "../../functions/is-previewing.js",
|
|
369
|
-
},
|
|
370
|
-
{
|
|
371
|
-
imports: {
|
|
372
|
-
components: "components",
|
|
373
|
-
createRegisterComponentMessage: "createRegisterComponentMessage",
|
|
374
|
-
},
|
|
375
|
-
path: "../../functions/register-component.js",
|
|
376
|
-
},
|
|
377
|
-
{
|
|
378
|
-
imports: {
|
|
379
|
-
track: "track",
|
|
380
|
-
},
|
|
381
|
-
path: "../../functions/track.js",
|
|
382
|
-
},
|
|
383
|
-
{
|
|
384
|
-
imports: {
|
|
385
|
-
RenderBlocks: "default",
|
|
386
|
-
},
|
|
387
|
-
path: "../render-blocks.lite",
|
|
388
|
-
},
|
|
389
|
-
{
|
|
390
|
-
imports: {
|
|
391
|
-
RenderContentStyles: "default",
|
|
392
|
-
},
|
|
393
|
-
path: "./components/render-styles.lite",
|
|
394
|
-
},
|
|
395
|
-
],
|
|
396
|
-
exports: {},
|
|
397
|
-
inputs: [],
|
|
398
|
-
meta: {
|
|
399
|
-
useMetadata: {
|
|
400
|
-
qwik: {
|
|
401
|
-
component: {
|
|
402
|
-
useHostElement: true,
|
|
403
|
-
},
|
|
404
|
-
replace: {
|
|
405
|
-
"// QWIK-REPLACE: _useMutableProps":
|
|
406
|
-
"_useMutableProps(hostElement, true);",
|
|
407
|
-
},
|
|
408
|
-
imports: {
|
|
409
|
-
_useMutableProps: "@builder.io/qwik",
|
|
410
|
-
},
|
|
411
|
-
},
|
|
412
|
-
},
|
|
413
|
-
},
|
|
414
|
-
refs: {},
|
|
415
|
-
state: {
|
|
416
|
-
useContent:
|
|
417
|
-
"@builder.io/mitosis/method:get useContent() {\n const mergedContent: BuilderContent = { ...props.content,\n ...state.overrideContent,\n data: { ...props.content?.data,\n ...props.data,\n ...state.overrideContent?.data\n }\n };\n return mergedContent;\n}",
|
|
418
|
-
overrideContent: null,
|
|
419
|
-
update: 0,
|
|
420
|
-
overrideState: {},
|
|
421
|
-
contentState:
|
|
422
|
-
"@builder.io/mitosis/method:get contentState() {\n return { ...props.content?.data?.state,\n ...props.data,\n ...state.overrideState\n };\n}",
|
|
423
|
-
contextContext:
|
|
424
|
-
"@builder.io/mitosis/method:get contextContext() {\n return props.context || {};\n}",
|
|
425
|
-
allRegisteredComponents:
|
|
426
|
-
"@builder.io/mitosis/method:get allRegisteredComponents() {\n const allComponentsArray = [...getDefaultRegisteredComponents(), // While this `components` object is deprecated, we must maintain support for it.\n // Since users are able to override our default components, we need to make sure that we do not break such\n // existing usage.\n // This is why we spread `components` after the default Builder.io components, but before the `props.customComponents`,\n // which is the new standard way of providing custom components, and must therefore take precedence.\n ...components, ...(props.customComponents || [])];\n const allComponents = allComponentsArray.reduce((acc, curr) => ({ ...acc,\n [curr.name]: curr\n }), ({} as RegisteredComponents));\n return allComponents;\n}",
|
|
427
|
-
processMessage:
|
|
428
|
-
"@builder.io/mitosis/method:processMessage(event: MessageEvent) {\n const {\n data\n } = event;\n\n if (data) {\n switch (data.type) {\n case 'builder.contentUpdate':\n {\n const messageContent = data.data;\n const key = messageContent.key || messageContent.alias || messageContent.entry || messageContent.modelName;\n const contentData = messageContent.data;\n\n if (key === props.model) {\n state.overrideContent = contentData;\n }\n\n break;\n }\n\n case 'builder.patchUpdates':\n {\n // TODO\n break;\n }\n }\n }\n}",
|
|
429
|
-
evaluateJsCode:
|
|
430
|
-
"@builder.io/mitosis/method:evaluateJsCode() {\n // run any dynamic JS code attached to content\n const jsCode = useContent(props,state)?.data?.jsCode;\n\n if (jsCode) {\n evaluate({\n code: jsCode,\n context: contextContext(props,state),\n state: contentState(props,state)\n });\n }\n}",
|
|
431
|
-
httpReqsData:
|
|
432
|
-
"@builder.io/mitosis/method:get httpReqsData() {\n return {};\n}",
|
|
433
|
-
onClick:
|
|
434
|
-
"@builder.io/mitosis/method:onClick(_event: MouseEvent) {\n if (useContent(props,state) && props.canTrack !== false) {\n track('click', {\n contentId: useContent(props,state).id\n });\n }\n}",
|
|
435
|
-
evalExpression:
|
|
436
|
-
"@builder.io/mitosis/method:evalExpression(expression: string) {\n return expression.replace(/{{([^}]+)}}/g, (_match, group) => evaluate({\n code: group,\n context: contextContext(props,state),\n state: contentState(props,state)\n }));\n}",
|
|
437
|
-
handleRequest:
|
|
438
|
-
"@builder.io/mitosis/method:handleRequest({\n url,\n key\n}: {\n key: string;\n url: string;\n}) {\n const fetchAndSetState = async () => {\n const fetch = await getFetch();\n const response = await fetch(url);\n const json = await response.json();\n const newOverrideState = { ...state.overrideState,\n [key]: json\n };\n state.overrideState = newOverrideState;\n };\n\n fetchAndSetState();\n}",
|
|
439
|
-
runHttpRequests:
|
|
440
|
-
"@builder.io/mitosis/method:runHttpRequests() {\n const requests = useContent(props,state)?.data?.httpRequests ?? {};\n Object.entries(requests).forEach(([key, url]) => {\n if (url && (!httpReqsData(props,state)[key] || isEditing())) {\n const evaluatedUrl = evalExpression(props,state,url);\n handleRequest(props,state,{\n url: evaluatedUrl,\n key\n });\n }\n });\n}",
|
|
441
|
-
emitStateUpdate:
|
|
442
|
-
"@builder.io/mitosis/method:emitStateUpdate() {\n if (isEditing()) {\n window.dispatchEvent(new CustomEvent<BuilderComponentStateChange>('builder:component:stateChange', {\n detail: {\n state: contentState(props,state),\n ref: {\n name: props.model\n }\n }\n }));\n }\n}",
|
|
443
|
-
shouldRenderContentStyles:
|
|
444
|
-
"@builder.io/mitosis/method:get shouldRenderContentStyles() {\n return Boolean((useContent(props,state)?.data?.cssCode || useContent(props,state)?.data?.customFonts?.length) && TARGET !== 'reactNative');\n}",
|
|
445
|
-
},
|
|
446
|
-
children: [
|
|
447
|
-
{
|
|
448
|
-
"@type": "@builder.io/mitosis/node",
|
|
449
|
-
name: "Show",
|
|
450
|
-
meta: {},
|
|
451
|
-
scope: {},
|
|
452
|
-
properties: {},
|
|
453
|
-
bindings: {
|
|
454
|
-
when: {
|
|
455
|
-
code: "useContent(props,state)",
|
|
456
|
-
},
|
|
457
|
-
},
|
|
458
|
-
children: [
|
|
459
|
-
{
|
|
460
|
-
"@type": "@builder.io/mitosis/node",
|
|
461
|
-
name: "div",
|
|
462
|
-
meta: {},
|
|
463
|
-
scope: {},
|
|
464
|
-
properties: {
|
|
465
|
-
_text: "\n ",
|
|
466
|
-
},
|
|
467
|
-
bindings: {},
|
|
468
|
-
children: [],
|
|
469
|
-
},
|
|
470
|
-
{
|
|
471
|
-
"@type": "@builder.io/mitosis/node",
|
|
472
|
-
name: "div",
|
|
473
|
-
meta: {},
|
|
474
|
-
scope: {},
|
|
475
|
-
properties: {},
|
|
476
|
-
bindings: {
|
|
477
|
-
onClick: {
|
|
478
|
-
code: "onClick(props,state,event)",
|
|
479
|
-
arguments: ["event"],
|
|
480
|
-
},
|
|
481
|
-
"builder-content-id": {
|
|
482
|
-
code: "useContent(props,state)?.id",
|
|
483
|
-
},
|
|
484
|
-
},
|
|
485
|
-
children: [
|
|
486
|
-
{
|
|
487
|
-
"@type": "@builder.io/mitosis/node",
|
|
488
|
-
name: "div",
|
|
489
|
-
meta: {},
|
|
490
|
-
scope: {},
|
|
491
|
-
properties: {
|
|
492
|
-
_text: "\n ",
|
|
493
|
-
},
|
|
494
|
-
bindings: {},
|
|
495
|
-
children: [],
|
|
496
|
-
},
|
|
497
|
-
{
|
|
498
|
-
"@type": "@builder.io/mitosis/node",
|
|
499
|
-
name: "Show",
|
|
500
|
-
meta: {},
|
|
501
|
-
scope: {},
|
|
502
|
-
properties: {},
|
|
503
|
-
bindings: {
|
|
504
|
-
when: {
|
|
505
|
-
code: "shouldRenderContentStyles(props,state)",
|
|
506
|
-
},
|
|
507
|
-
},
|
|
508
|
-
children: [
|
|
509
|
-
{
|
|
510
|
-
"@type": "@builder.io/mitosis/node",
|
|
511
|
-
name: "RenderContentStyles",
|
|
512
|
-
meta: {},
|
|
513
|
-
scope: {},
|
|
514
|
-
properties: {},
|
|
515
|
-
bindings: {
|
|
516
|
-
cssCode: {
|
|
517
|
-
code: "useContent(props,state)?.data?.cssCode",
|
|
518
|
-
},
|
|
519
|
-
customFonts: {
|
|
520
|
-
code: "useContent(props,state)?.data?.customFonts",
|
|
521
|
-
},
|
|
522
|
-
},
|
|
523
|
-
children: [],
|
|
524
|
-
},
|
|
525
|
-
],
|
|
526
|
-
},
|
|
527
|
-
{
|
|
528
|
-
"@type": "@builder.io/mitosis/node",
|
|
529
|
-
name: "div",
|
|
530
|
-
meta: {},
|
|
531
|
-
scope: {},
|
|
532
|
-
properties: {
|
|
533
|
-
_text: "\n ",
|
|
534
|
-
},
|
|
535
|
-
bindings: {},
|
|
536
|
-
children: [],
|
|
537
|
-
},
|
|
538
|
-
{
|
|
539
|
-
"@type": "@builder.io/mitosis/node",
|
|
540
|
-
name: "RenderBlocks",
|
|
541
|
-
meta: {},
|
|
542
|
-
scope: {},
|
|
543
|
-
properties: {},
|
|
544
|
-
bindings: {
|
|
545
|
-
blocks: {
|
|
546
|
-
code: "useContent(props,state)?.data?.blocks",
|
|
547
|
-
},
|
|
548
|
-
},
|
|
549
|
-
children: [],
|
|
550
|
-
},
|
|
551
|
-
{
|
|
552
|
-
"@type": "@builder.io/mitosis/node",
|
|
553
|
-
name: "div",
|
|
554
|
-
meta: {},
|
|
555
|
-
scope: {},
|
|
556
|
-
properties: {
|
|
557
|
-
_text: "\n ",
|
|
558
|
-
},
|
|
559
|
-
bindings: {},
|
|
560
|
-
children: [],
|
|
561
|
-
},
|
|
562
|
-
],
|
|
563
|
-
},
|
|
564
|
-
{
|
|
565
|
-
"@type": "@builder.io/mitosis/node",
|
|
566
|
-
name: "div",
|
|
567
|
-
meta: {},
|
|
568
|
-
scope: {},
|
|
569
|
-
properties: {
|
|
570
|
-
_text: "\n ",
|
|
571
|
-
},
|
|
572
|
-
bindings: {},
|
|
573
|
-
children: [],
|
|
574
|
-
},
|
|
575
|
-
],
|
|
576
|
-
},
|
|
577
|
-
],
|
|
578
|
-
hooks: {
|
|
579
|
-
onMount: {
|
|
580
|
-
code: "\n if (isBrowser()) {\n if (isEditing()) {\n _useMutableProps(hostElement, true);\n Object.values(allRegisteredComponents(props,state)).forEach(registeredComponent => {\n const message = createRegisterComponentMessage(registeredComponent);\n window.parent?.postMessage(message, '*');\n });\n window.addEventListener('message', processMessage.bind(null,props,state));\n window.addEventListener('builder:component:stateChangeListenerActivated', emitStateUpdate.bind(null,props,state));\n }\n\n if (useContent(props,state) && props.canTrack !== false) {\n track('impression', {\n contentId: useContent(props,state).id\n });\n } // override normal content in preview mode\n\n\n if (isPreviewing()) {\n const searchParams = new URL(location.href).searchParams;\n\n if (props.model && searchParams.get('builder.preview') === props.model) {\n const previewApiKey = searchParams.get('apiKey') || searchParams.get('builder.space');\n\n if (previewApiKey) {\n getContent({\n model: props.model,\n apiKey: previewApiKey\n }).then(content => {\n if (content) {\n state.overrideContent = content;\n }\n });\n }\n }\n }\n\n evaluateJsCode(props,state,);\n runHttpRequests(props,state,);\n emitStateUpdate(props,state,);\n }\n",
|
|
581
|
-
},
|
|
582
|
-
onUpdate: [
|
|
583
|
-
{
|
|
584
|
-
code: "\n evaluateJsCode(props,state,);\n",
|
|
585
|
-
deps: "[state.useContent?.data?.jsCode]",
|
|
586
|
-
},
|
|
587
|
-
{
|
|
588
|
-
code: "\n runHttpRequests(props,state,);\n",
|
|
589
|
-
deps: "[state.useContent?.data?.httpRequests]",
|
|
590
|
-
},
|
|
591
|
-
{
|
|
592
|
-
code: "\n emitStateUpdate(props,state,);\n",
|
|
593
|
-
deps: "[state.contentState]",
|
|
594
|
-
},
|
|
595
|
-
],
|
|
596
|
-
onUnMount: {
|
|
597
|
-
code: "\n if (isBrowser()) {\n window.removeEventListener('message', processMessage.bind(null,props,state));\n window.removeEventListener('builder:component:stateChangeListenerActivated', emitStateUpdate.bind(null,props,state));\n }\n",
|
|
598
|
-
},
|
|
599
|
-
},
|
|
600
|
-
context: {
|
|
601
|
-
get: {},
|
|
602
|
-
set: {
|
|
603
|
-
"../../context/builder.context.lite:default": {
|
|
604
|
-
name: "BuilderContext",
|
|
605
|
-
value: {
|
|
606
|
-
content:
|
|
607
|
-
"@builder.io/mitosis/method:get content() {\n return useContent(props,state);\n}",
|
|
608
|
-
state:
|
|
609
|
-
"@builder.io/mitosis/method:get state() {\n return contentState(props,state);\n}",
|
|
610
|
-
context:
|
|
611
|
-
"@builder.io/mitosis/method:get context() {\n return contextContext(props,state);\n}",
|
|
612
|
-
apiKey:
|
|
613
|
-
"@builder.io/mitosis/method:get apiKey() {\n return props.apiKey;\n}",
|
|
614
|
-
registeredComponents:
|
|
615
|
-
"@builder.io/mitosis/method:get registeredComponents() {\n return allRegisteredComponents(props,state);\n}",
|
|
616
|
-
},
|
|
617
|
-
},
|
|
618
|
-
},
|
|
619
|
-
},
|
|
620
|
-
name: "RenderContent",
|
|
621
|
-
subComponents: [],
|
|
622
|
-
types: [
|
|
623
|
-
"export type RenderContentProps = {\n content?: Nullable<BuilderContent>;\n model?: string;\n data?: {\n [key: string]: any;\n };\n context?: BuilderRenderContext;\n apiKey: string;\n customComponents?: RegisteredComponent[];\n canTrack?: boolean;\n};",
|
|
624
|
-
],
|
|
625
|
-
interfaces: [
|
|
626
|
-
"interface BuilderComponentStateChange {\n state: BuilderRenderState;\n ref: {\n name?: string;\n props?: {\n builderBlock?: {\n id?: string;\n };\n };\n };\n}",
|
|
627
|
-
],
|
|
628
|
-
propsTypeRef: "RenderContentProps",
|
|
629
|
-
};
|