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