@builder.io/sdk-qwik 0.0.7 → 0.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (105) hide show
  1. package/lib/index.97024df8.js +80165 -0
  2. package/lib/index.d8c1e37f.cjs +80165 -0
  3. package/lib/index.qwik.cjs +2424 -0
  4. package/lib/index.qwik.mjs +2424 -0
  5. package/package.json +1 -1
  6. package/src/blocks/button/button.jsx +0 -197
  7. package/src/blocks/button/component-info.js +0 -41
  8. package/src/blocks/columns/columns.jsx +0 -267
  9. package/src/blocks/columns/component-info.js +0 -242
  10. package/src/blocks/custom-code/component-info.js +0 -31
  11. package/src/blocks/custom-code/custom-code.jsx +0 -130
  12. package/src/blocks/embed/component-info.js +0 -44
  13. package/src/blocks/embed/embed.jsx +0 -130
  14. package/src/blocks/embed/helpers.js +0 -9
  15. package/src/blocks/form/builder-blocks.jsx +0 -86
  16. package/src/blocks/form/component-info.js +0 -262
  17. package/src/blocks/form/form.jsx +0 -782
  18. package/src/blocks/fragment/component-info.js +0 -11
  19. package/src/blocks/fragment/fragment.jsx +0 -59
  20. package/src/blocks/image/component-info.js +0 -151
  21. package/src/blocks/image/image.helpers.js +0 -48
  22. package/src/blocks/image/image.jsx +0 -554
  23. package/src/blocks/img/component-info.js +0 -20
  24. package/src/blocks/img/img.jsx +0 -76
  25. package/src/blocks/input/component-info.js +0 -74
  26. package/src/blocks/input/input.jsx +0 -87
  27. package/src/blocks/raw-text/component-info.js +0 -16
  28. package/src/blocks/raw-text/raw-text.jsx +0 -53
  29. package/src/blocks/section/component-info.js +0 -49
  30. package/src/blocks/section/section.jsx +0 -97
  31. package/src/blocks/select/component-info.js +0 -59
  32. package/src/blocks/select/select.jsx +0 -149
  33. package/src/blocks/submit-button/component-info.js +0 -28
  34. package/src/blocks/submit-button/submit-button.jsx +0 -87
  35. package/src/blocks/symbol/component-info.js +0 -43
  36. package/src/blocks/symbol/symbol.jsx +0 -211
  37. package/src/blocks/text/component-info.js +0 -24
  38. package/src/blocks/text/text.jsx +0 -46
  39. package/src/blocks/textarea/component-info.js +0 -47
  40. package/src/blocks/textarea/textarea.jsx +0 -65
  41. package/src/blocks/util.js +0 -7
  42. package/src/blocks/video/component-info.js +0 -106
  43. package/src/blocks/video/video.jsx +0 -103
  44. package/src/components/render-block/block-styles.jsx +0 -174
  45. package/src/components/render-block/render-block.helpers.js +0 -23
  46. package/src/components/render-block/render-block.jsx +0 -733
  47. package/src/components/render-block/render-component.jsx +0 -245
  48. package/src/components/render-block/render-repeated-block.jsx +0 -104
  49. package/src/components/render-block/types.js +0 -0
  50. package/src/components/render-blocks.jsx +0 -387
  51. package/src/components/render-content/components/render-styles.jsx +0 -126
  52. package/src/components/render-content/index.js +0 -4
  53. package/src/components/render-content/render-content.jsx +0 -629
  54. package/src/components/render-inlined-styles.jsx +0 -141
  55. package/src/constants/builder-registered-components.js +0 -48
  56. package/src/constants/device-sizes.js +0 -21
  57. package/src/constants/target.js +0 -4
  58. package/src/context/builder.context.js +0 -5
  59. package/src/functions/camel-to-kebab-case.js +0 -4
  60. package/src/functions/convert-style-object.js +0 -6
  61. package/src/functions/evaluate.js +0 -28
  62. package/src/functions/event-handler-name.js +0 -7
  63. package/src/functions/get-block-actions.js +0 -23
  64. package/src/functions/get-block-component-options.js +0 -28
  65. package/src/functions/get-block-properties.js +0 -29
  66. package/src/functions/get-block-styles.js +0 -34
  67. package/src/functions/get-block-tag.js +0 -6
  68. package/src/functions/get-builder-search-params/fn.test.js +0 -13
  69. package/src/functions/get-builder-search-params/index.js +0 -33
  70. package/src/functions/get-content/ab-testing.js +0 -38
  71. package/src/functions/get-content/fn.test.js +0 -31
  72. package/src/functions/get-content/index.js +0 -96
  73. package/src/functions/get-content/types.js +0 -0
  74. package/src/functions/get-fetch.js +0 -34
  75. package/src/functions/get-global-this.js +0 -18
  76. package/src/functions/get-processed-block.js +0 -53
  77. package/src/functions/get-processed-block.test.js +0 -32
  78. package/src/functions/if-target.js +0 -15
  79. package/src/functions/is-browser.js +0 -6
  80. package/src/functions/is-editing.js +0 -7
  81. package/src/functions/is-iframe.js +0 -7
  82. package/src/functions/is-previewing.js +0 -14
  83. package/src/functions/on-change.js +0 -27
  84. package/src/functions/on-change.test.js +0 -19
  85. package/src/functions/register-component.js +0 -72
  86. package/src/functions/register.js +0 -29
  87. package/src/functions/sanitize-styles.js +0 -5
  88. package/src/functions/set-editor-settings.js +0 -15
  89. package/src/functions/set.js +0 -11
  90. package/src/functions/set.test.js +0 -16
  91. package/src/functions/track.js +0 -22
  92. package/src/functions/transform-block.js +0 -6
  93. package/src/helpers/css.js +0 -12
  94. package/src/helpers/flatten.js +0 -34
  95. package/src/index-helpers/blocks-exports.js +0 -22
  96. package/src/index-helpers/top-of-file.js +0 -4
  97. package/src/index.js +0 -10
  98. package/src/scripts/init-editing.js +0 -80
  99. package/src/types/builder-block.js +0 -0
  100. package/src/types/builder-content.js +0 -0
  101. package/src/types/components.js +0 -0
  102. package/src/types/deep-partial.js +0 -0
  103. package/src/types/element.js +0 -0
  104. package/src/types/targets.js +0 -0
  105. package/src/types/typescript.js +0 -0
@@ -1,629 +0,0 @@
1
- // GENERATED BY MITOSIS
2
-
3
- import { getDefaultRegisteredComponents } from "../../constants/builder-registered-components.js";
4
- import { TARGET } from "../../constants/target.js";
5
- import BuilderContext from "../../context/builder.context";
6
- import { evaluate } from "../../functions/evaluate.js";
7
- import { getContent } from "../../functions/get-content/index.js";
8
- import { getFetch } from "../../functions/get-fetch.js";
9
- import { isBrowser } from "../../functions/is-browser.js";
10
- import { isEditing } from "../../functions/is-editing.js";
11
- import { isPreviewing } from "../../functions/is-previewing.js";
12
- import {
13
- components,
14
- createRegisterComponentMessage,
15
- } from "../../functions/register-component.js";
16
- import { track } from "../../functions/track.js";
17
- import RenderBlocks from "../render-blocks";
18
- import RenderContentStyles from "./components/render-styles";
19
- import {
20
- Fragment,
21
- _useMutableProps,
22
- component$,
23
- h,
24
- useCleanup$,
25
- useClientEffect$,
26
- useContextProvider,
27
- useHostElement,
28
- useStore,
29
- useWatch$,
30
- } from "@builder.io/qwik";
31
- export const useContent = function useContent(props, state) {
32
- const mergedContent = {
33
- ...props.content,
34
- ...state.overrideContent,
35
- data: {
36
- ...props.content?.data,
37
- ...props.data,
38
- ...state.overrideContent?.data,
39
- },
40
- };
41
- return mergedContent;
42
- };
43
- export const contentState = function contentState(props, state) {
44
- return {
45
- ...props.content?.data?.state,
46
- ...props.data,
47
- ...state.overrideState,
48
- };
49
- };
50
- export const contextContext = function contextContext(props, state) {
51
- return props.context || {};
52
- };
53
- export const allRegisteredComponents = function allRegisteredComponents(
54
- props,
55
- state
56
- ) {
57
- const allComponentsArray = [
58
- ...getDefaultRegisteredComponents(), // While this `components` object is deprecated, we must maintain support for it.
59
- // Since users are able to override our default components, we need to make sure that we do not break such
60
- // existing usage.
61
- // This is why we spread `components` after the default Builder.io components, but before the `props.customComponents`,
62
- // which is the new standard way of providing custom components, and must therefore take precedence.
63
- ...components,
64
- ...(props.customComponents || []),
65
- ];
66
- const allComponents = allComponentsArray.reduce(
67
- (acc, curr) => ({ ...acc, [curr.name]: curr }),
68
- {}
69
- );
70
- return allComponents;
71
- };
72
- export const processMessage = function processMessage(props, state, event) {
73
- const { data } = event;
74
-
75
- if (data) {
76
- switch (data.type) {
77
- case "builder.contentUpdate": {
78
- const messageContent = data.data;
79
- const key =
80
- messageContent.key ||
81
- messageContent.alias ||
82
- messageContent.entry ||
83
- messageContent.modelName;
84
- const contentData = messageContent.data;
85
-
86
- if (key === props.model) {
87
- state.overrideContent = contentData;
88
- }
89
-
90
- break;
91
- }
92
-
93
- case "builder.patchUpdates": {
94
- // TODO
95
- break;
96
- }
97
- }
98
- }
99
- };
100
- export const evaluateJsCode = function evaluateJsCode(props, state) {
101
- // run any dynamic JS code attached to content
102
- const jsCode = useContent(props, state)?.data?.jsCode;
103
-
104
- if (jsCode) {
105
- evaluate({
106
- code: jsCode,
107
- context: contextContext(props, state),
108
- state: contentState(props, state),
109
- });
110
- }
111
- };
112
- export const httpReqsData = function httpReqsData(props, state) {
113
- return {};
114
- };
115
- export const onClick = function onClick(props, state, _event) {
116
- if (useContent(props, state) && props.canTrack !== false) {
117
- track("click", {
118
- contentId: useContent(props, state).id,
119
- });
120
- }
121
- };
122
- export const evalExpression = function evalExpression(
123
- props,
124
- state,
125
- expression
126
- ) {
127
- return expression.replace(/{{([^}]+)}}/g, (_match, group) =>
128
- evaluate({
129
- code: group,
130
- context: contextContext(props, state),
131
- state: contentState(props, state),
132
- })
133
- );
134
- };
135
- export const handleRequest = function handleRequest(
136
- props,
137
- state,
138
- { url, key }
139
- ) {
140
- const fetchAndSetState = async () => {
141
- const fetch = await getFetch();
142
- const response = await fetch(url);
143
- const json = await response.json();
144
- const newOverrideState = { ...state.overrideState, [key]: json };
145
- state.overrideState = newOverrideState;
146
- };
147
-
148
- fetchAndSetState();
149
- };
150
- export const runHttpRequests = function runHttpRequests(props, state) {
151
- const requests = useContent(props, state)?.data?.httpRequests ?? {};
152
- 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, {
156
- url: evaluatedUrl,
157
- key,
158
- });
159
- }
160
- });
161
- };
162
- export const emitStateUpdate = function emitStateUpdate(props, state) {
163
- if (isEditing()) {
164
- window.dispatchEvent(
165
- new CustomEvent("builder:component:stateChange", {
166
- detail: {
167
- state: contentState(props, state),
168
- ref: {
169
- name: props.model,
170
- },
171
- },
172
- })
173
- );
174
- }
175
- };
176
- export const shouldRenderContentStyles = function shouldRenderContentStyles(
177
- props,
178
- state
179
- ) {
180
- return Boolean(
181
- (useContent(props, state)?.data?.cssCode ||
182
- useContent(props, state)?.data?.customFonts?.length) &&
183
- TARGET !== "reactNative"
184
- );
185
- };
186
- export const RenderContent = component$((props) => {
187
- const hostElement = useHostElement();
188
- const state = useStore({
189
- overrideContent: null,
190
- update: 0,
191
- overrideState: {},
192
- });
193
- useContextProvider(
194
- BuilderContext,
195
- useStore({
196
- content: (() => {
197
- return useContent(props, state);
198
- })(),
199
- state: (() => {
200
- return contentState(props, state);
201
- })(),
202
- context: (() => {
203
- return contextContext(props, state);
204
- })(),
205
- apiKey: (() => {
206
- return props.apiKey;
207
- })(),
208
- registeredComponents: (() => {
209
- return allRegisteredComponents(props, state);
210
- })(),
211
- })
212
- );
213
- useClientEffect$(() => {
214
- if (isBrowser()) {
215
- if (isEditing()) {
216
- _useMutableProps(hostElement, true);
217
- Object.values(allRegisteredComponents(props, state)).forEach(
218
- (registeredComponent) => {
219
- const message = createRegisterComponentMessage(registeredComponent);
220
- window.parent?.postMessage(message, "*");
221
- }
222
- );
223
- window.addEventListener(
224
- "message",
225
- processMessage.bind(null, props, state)
226
- );
227
- window.addEventListener(
228
- "builder:component:stateChangeListenerActivated",
229
- emitStateUpdate.bind(null, props, state)
230
- );
231
- }
232
-
233
- if (useContent(props, state) && props.canTrack !== false) {
234
- track("impression", {
235
- contentId: useContent(props, state).id,
236
- });
237
- } // override normal content in preview mode
238
-
239
- if (isPreviewing()) {
240
- const searchParams = new URL(location.href).searchParams;
241
-
242
- if (
243
- props.model &&
244
- searchParams.get("builder.preview") === props.model
245
- ) {
246
- const previewApiKey =
247
- searchParams.get("apiKey") || searchParams.get("builder.space");
248
-
249
- if (previewApiKey) {
250
- getContent({
251
- model: props.model,
252
- apiKey: previewApiKey,
253
- }).then((content) => {
254
- if (content) {
255
- state.overrideContent = content;
256
- }
257
- });
258
- }
259
- }
260
- }
261
-
262
- evaluateJsCode(props, state);
263
- runHttpRequests(props, state);
264
- emitStateUpdate(props, state);
265
- }
266
- });
267
- useWatch$(({ track }) => {
268
- state.useContent?.data && track(state.useContent?.data, "jsCode");
269
- evaluateJsCode(props, state);
270
- });
271
- useWatch$(({ track }) => {
272
- state.useContent?.data && track(state.useContent?.data, "httpRequests");
273
- runHttpRequests(props, state);
274
- });
275
- useWatch$(({ track }) => {
276
- state && track(state, "contentState");
277
- emitStateUpdate(props, state);
278
- });
279
- useCleanup$(() => {
280
- if (isBrowser()) {
281
- window.removeEventListener(
282
- "message",
283
- processMessage.bind(null, props, state)
284
- );
285
- window.removeEventListener(
286
- "builder:component:stateChangeListenerActivated",
287
- emitStateUpdate.bind(null, props, state)
288
- );
289
- }
290
- });
291
- return (
292
- <>
293
- {useContent(props, state) ? (
294
- <div
295
- onClick$={(event) => onClick(props, state, event)}
296
- builder-content-id={useContent(props, state)?.id}
297
- >
298
- {shouldRenderContentStyles(props, state) ? (
299
- <RenderContentStyles
300
- cssCode={useContent(props, state)?.data?.cssCode}
301
- customFonts={useContent(props, state)?.data?.customFonts}
302
- ></RenderContentStyles>
303
- ) : null}
304
- <RenderBlocks
305
- blocks={useContent(props, state)?.data?.blocks}
306
- ></RenderBlocks>
307
- </div>
308
- ) : null}
309
- </>
310
- );
311
- });
312
- 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
- };