@builder.io/sdk-qwik 0.0.25 → 0.0.27

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.
@@ -69,53 +69,55 @@ const setupBrowserForEditing = () => {
69
69
  type: "builder.sdkInfo",
70
70
  data: {
71
71
  target: TARGET,
72
- supportsPatchUpdates: false
72
+ supportsPatchUpdates: false,
73
+ supportsAddBlockScoping: true
73
74
  }
74
75
  }, "*");
75
76
  window.addEventListener("message", ({ data }) => {
76
- if (data)
77
- switch (data.type) {
78
- case "builder.evaluate": {
79
- const text = data.data.text;
80
- const args = data.data.arguments || [];
81
- const id = data.data.id;
82
- const fn = new Function(text);
83
- let result;
84
- let error = null;
85
- try {
86
- result = fn.apply(null, args);
87
- } catch (err) {
88
- error = err;
89
- }
90
- if (error)
91
- window.parent?.postMessage({
92
- type: "builder.evaluateError",
93
- data: {
94
- id,
95
- error: error.message
96
- }
97
- }, "*");
98
- else if (result && typeof result.then === "function")
99
- result.then((finalResult) => {
100
- window.parent?.postMessage({
101
- type: "builder.evaluateResult",
102
- data: {
103
- id,
104
- result: finalResult
105
- }
106
- }, "*");
107
- }).catch(console.error);
108
- else
77
+ if (!data?.type)
78
+ return;
79
+ switch (data.type) {
80
+ case "builder.evaluate": {
81
+ const text = data.data.text;
82
+ const args = data.data.arguments || [];
83
+ const id = data.data.id;
84
+ const fn = new Function(text);
85
+ let result;
86
+ let error = null;
87
+ try {
88
+ result = fn.apply(null, args);
89
+ } catch (err) {
90
+ error = err;
91
+ }
92
+ if (error)
93
+ window.parent?.postMessage({
94
+ type: "builder.evaluateError",
95
+ data: {
96
+ id,
97
+ error: error.message
98
+ }
99
+ }, "*");
100
+ else if (result && typeof result.then === "function")
101
+ result.then((finalResult) => {
109
102
  window.parent?.postMessage({
110
103
  type: "builder.evaluateResult",
111
104
  data: {
112
- result,
113
- id
105
+ id,
106
+ result: finalResult
114
107
  }
115
108
  }, "*");
116
- break;
117
- }
109
+ }).catch(console.error);
110
+ else
111
+ window.parent?.postMessage({
112
+ type: "builder.evaluateResult",
113
+ data: {
114
+ result,
115
+ id
116
+ }
117
+ }, "*");
118
+ break;
118
119
  }
120
+ }
119
121
  });
120
122
  }
121
123
  };
@@ -162,6 +164,7 @@ function evaluate({ code, context, state, event }) {
162
164
  console.warn("Builder custom code error: \n While Evaluating: \n ", useCode, "\n", e.message || e);
163
165
  }
164
166
  }
167
+ const fastClone = (obj) => JSON.parse(JSON.stringify(obj));
165
168
  const set = (obj, _path, value) => {
166
169
  if (Object(obj) !== obj)
167
170
  return obj;
@@ -175,13 +178,14 @@ function transformBlock(block) {
175
178
  const evaluateBindings = ({ block, context, state }) => {
176
179
  if (!block.bindings)
177
180
  return block;
181
+ const copy = fastClone(block);
178
182
  const copied = {
179
- ...block,
183
+ ...copy,
180
184
  properties: {
181
- ...block.properties
185
+ ...copy.properties
182
186
  },
183
187
  actions: {
184
- ...block.actions
188
+ ...copy.actions
185
189
  }
186
190
  };
187
191
  for (const binding in block.bindings) {
@@ -214,13 +218,22 @@ const convertStyleMaptoCSS = (style) => {
214
218
  });
215
219
  return cssProps.join("\n");
216
220
  };
221
+ const createCssClass = ({ mediaQuery, className: className3, styles }) => {
222
+ const cssClass = `.${className3} {
223
+ ${convertStyleMaptoCSS(styles)}
224
+ }`;
225
+ if (mediaQuery)
226
+ return `${mediaQuery} {
227
+ ${cssClass}
228
+ }`;
229
+ else
230
+ return cssClass;
231
+ };
217
232
  const tagName$1 = function tagName(props, state) {
218
233
  return "style";
219
234
  };
220
235
  const RenderInlinedStyles = (props) => {
221
- const state = {
222
- tagName: ""
223
- };
236
+ const state = {};
224
237
  state.tagName = tagName$1();
225
238
  return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, {
226
239
  children: /* @__PURE__ */ jsxRuntime.jsx(state.tagName, {
@@ -242,19 +255,30 @@ const css = function css2(props, state) {
242
255
  const largeStyles = styles?.large;
243
256
  const mediumStyles = styles?.medium;
244
257
  const smallStyles = styles?.small;
245
- return `
246
- ${largeStyles ? `.${useBlock$1(props).id} {${convertStyleMaptoCSS(largeStyles)}}` : ""}
247
- ${mediumStyles ? `${getMaxWidthQueryForSize("medium")} {
248
- .${useBlock$1(props).id} {${convertStyleMaptoCSS(mediumStyles)}}
249
- }` : ""}
250
- ${smallStyles ? `${getMaxWidthQueryForSize("small")} {
251
- .${useBlock$1(props).id} {${convertStyleMaptoCSS(smallStyles)}}
252
- }` : ""}
253
- }`;
258
+ const className3 = useBlock$1(props).id;
259
+ const largeStylesClass = largeStyles ? createCssClass({
260
+ className: className3,
261
+ styles: largeStyles
262
+ }) : "";
263
+ const mediumStylesClass = mediumStyles ? createCssClass({
264
+ className: className3,
265
+ styles: mediumStyles,
266
+ mediaQuery: getMaxWidthQueryForSize("medium")
267
+ }) : "";
268
+ const smallStylesClass = smallStyles ? createCssClass({
269
+ className: className3,
270
+ styles: smallStyles,
271
+ mediaQuery: getMaxWidthQueryForSize("small")
272
+ }) : "";
273
+ return [
274
+ largeStylesClass,
275
+ mediumStylesClass,
276
+ smallStylesClass
277
+ ].join(" ");
254
278
  };
255
279
  const BlockStyles = (props) => {
256
280
  return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, {
257
- children: TARGET === "vue2" || TARGET === "vue3" || TARGET === "svelte" || TARGET === "qwik" ? /* @__PURE__ */ jsxRuntime.jsx(RenderInlinedStyles$1, {
281
+ children: TARGET !== "reactNative" && css(props) ? /* @__PURE__ */ jsxRuntime.jsx(RenderInlinedStyles$1, {
258
282
  styles: css(props)
259
283
  }) : null
260
284
  });
@@ -308,37 +332,6 @@ function getBlockProperties(block) {
308
332
  ].filter(Boolean).join(" ")
309
333
  };
310
334
  }
311
- const convertStyleObject = (obj) => {
312
- return obj;
313
- };
314
- const sanitizeBlockStyles = (styles) => styles;
315
- const getStyleForTarget = (styles) => {
316
- switch (TARGET) {
317
- case "reactNative":
318
- return {
319
- ...styles.large ? convertStyleObject(styles.large) : {},
320
- ...styles.medium ? convertStyleObject(styles.medium) : {},
321
- ...styles.small ? convertStyleObject(styles.small) : {}
322
- };
323
- default:
324
- return {
325
- ...styles.large ? convertStyleObject(styles.large) : {},
326
- ...styles.medium ? {
327
- [getMaxWidthQueryForSize("medium")]: convertStyleObject(styles.medium)
328
- } : {},
329
- ...styles.small ? {
330
- [getMaxWidthQueryForSize("small")]: convertStyleObject(styles.small)
331
- } : {}
332
- };
333
- }
334
- };
335
- function getBlockStyles(block) {
336
- if (!block.responsiveStyles)
337
- return {};
338
- const styles = getStyleForTarget(block.responsiveStyles);
339
- const newStyles = sanitizeBlockStyles(styles);
340
- return newStyles;
341
- }
342
335
  function getBlockTag(block) {
343
336
  return block.tagName || "div";
344
337
  }
@@ -393,6 +386,35 @@ const RenderComponent = (props) => {
393
386
  });
394
387
  };
395
388
  const RenderComponent$1 = RenderComponent;
389
+ const RenderComponentWithContext = /* @__PURE__ */ qwik.componentQrl(qwik.inlinedQrl((props) => {
390
+ qwik.useContextProvider(BuilderContext, qwik.useStore({
391
+ content: (() => {
392
+ return props.context.content;
393
+ })(),
394
+ state: (() => {
395
+ return props.context.state;
396
+ })(),
397
+ context: (() => {
398
+ return props.context.context;
399
+ })(),
400
+ apiKey: (() => {
401
+ return props.context.apiKey;
402
+ })(),
403
+ registeredComponents: (() => {
404
+ return props.context.registeredComponents;
405
+ })(),
406
+ inheritedStyles: (() => {
407
+ return props.context.inheritedStyles;
408
+ })()
409
+ }));
410
+ return /* @__PURE__ */ jsxRuntime.jsx(RenderComponent$1, {
411
+ componentRef: props.componentRef,
412
+ componentOptions: props.componentOptions,
413
+ blockChildren: props.blockChildren,
414
+ context: props.context
415
+ });
416
+ }, "RenderComponentWithContext_component_nXOUbUnjTAo"));
417
+ const RenderComponentWithContext$1 = RenderComponentWithContext;
396
418
  const RenderRepeatedBlock = /* @__PURE__ */ qwik.componentQrl(qwik.inlinedQrl((props) => {
397
419
  qwik.useContextProvider(BuilderContext, qwik.useStore({
398
420
  content: (() => {
@@ -409,6 +431,9 @@ const RenderRepeatedBlock = /* @__PURE__ */ qwik.componentQrl(qwik.inlinedQrl((p
409
431
  })(),
410
432
  registeredComponents: (() => {
411
433
  return props.repeatContext.registeredComponents;
434
+ })(),
435
+ inheritedStyles: (() => {
436
+ return props.repeatContext.inheritedStyles;
412
437
  })()
413
438
  }));
414
439
  return /* @__PURE__ */ jsxRuntime.jsx(RenderBlock$1, {
@@ -435,16 +460,6 @@ const component = function component2(props, state) {
435
460
  } else
436
461
  return ref;
437
462
  };
438
- const componentInfo$b = function componentInfo(props, state) {
439
- if (component(props)) {
440
- const { component: _, ...info } = component(props);
441
- return info;
442
- } else
443
- return void 0;
444
- };
445
- const componentRef = function componentRef2(props, state) {
446
- return component(props)?.component;
447
- };
448
463
  const tagName2 = function tagName3(props, state) {
449
464
  return getBlockTag(useBlock2(props));
450
465
  };
@@ -464,33 +479,30 @@ const attributes = function attributes2(props, state) {
464
479
  state: props.context.state,
465
480
  context: props.context.context
466
481
  }),
467
- style: getBlockStyles(useBlock2(props))
482
+ ...{}
468
483
  };
469
484
  };
470
485
  const shouldWrap = function shouldWrap2(props, state) {
471
- return !componentInfo$b(props)?.noWrap;
472
- };
473
- const componentOptions = function componentOptions2(props, state) {
474
- return {
475
- ...getBlockComponentOptions(useBlock2(props)),
476
- ...shouldWrap(props) ? {} : {
477
- attributes: attributes(props)
478
- }
479
- };
486
+ return !component(props)?.noWrap;
480
487
  };
481
488
  const renderComponentProps = function renderComponentProps2(props, state) {
482
489
  return {
483
490
  blockChildren: children(props),
484
- componentRef: componentRef(props),
485
- componentOptions: componentOptions(props),
486
- context: props.context
491
+ componentRef: component(props)?.component,
492
+ componentOptions: {
493
+ ...getBlockComponentOptions(useBlock2(props)),
494
+ ...shouldWrap(props) ? {} : {
495
+ attributes: attributes(props)
496
+ }
497
+ },
498
+ context: childrenContext(props)
487
499
  };
488
500
  };
489
501
  const children = function children2(props, state) {
490
502
  return useBlock2(props).children ?? [];
491
503
  };
492
504
  const childrenWithoutParentComponent = function childrenWithoutParentComponent2(props, state) {
493
- const shouldRenderChildrenOutsideRef = !componentRef(props) && !repeatItemData(props);
505
+ const shouldRenderChildrenOutsideRef = !component(props)?.component && !repeatItemData(props);
494
506
  return shouldRenderChildrenOutsideRef ? children(props) : [];
495
507
  };
496
508
  const repeatItemData = function repeatItemData2(props, state) {
@@ -521,27 +533,36 @@ const repeatItemData = function repeatItemData2(props, state) {
521
533
  }));
522
534
  return repeatArray;
523
535
  };
524
- const RenderBlock = (props) => {
525
- const state = {
526
- tagName: ""
536
+ const inheritedTextStyles = function inheritedTextStyles2(props, state) {
537
+ return {};
538
+ };
539
+ const childrenContext = function childrenContext2(props, state) {
540
+ return {
541
+ apiKey: props.context.apiKey,
542
+ state: props.context.state,
543
+ content: props.context.content,
544
+ context: props.context.context,
545
+ registeredComponents: props.context.registeredComponents,
546
+ inheritedStyles: inheritedTextStyles()
527
547
  };
548
+ };
549
+ const renderComponentTag = function renderComponentTag2(props, state) {
550
+ if (TARGET === "reactNative")
551
+ return RenderComponentWithContext$1;
552
+ else
553
+ return RenderComponent$1;
554
+ };
555
+ const RenderBlock = (props) => {
556
+ const state = {};
528
557
  state.tagName = tagName2(props);
558
+ state.renderComponentTag = renderComponentTag();
529
559
  return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, {
530
560
  children: shouldWrap(props) ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, {
531
561
  children: [
532
562
  isEmptyHtmlElement(tagName2(props)) ? /* @__PURE__ */ jsxRuntime.jsx(state.tagName, {
533
563
  ...attributes(props)
534
564
  }) : null,
535
- !isEmptyHtmlElement(tagName2(props)) && TARGET === "vue2" && repeatItemData(props) ? /* @__PURE__ */ jsxRuntime.jsx("div", {
536
- class: "vue2-root-element-workaround",
537
- children: (repeatItemData(props) || []).map(function(data, index) {
538
- return /* @__PURE__ */ jsxRuntime.jsx(RenderRepeatedBlock$1, {
539
- repeatContext: data.context,
540
- block: data.block
541
- }, index);
542
- })
543
- }) : null,
544
- !isEmptyHtmlElement(tagName2(props)) && TARGET !== "vue2" && repeatItemData(props) ? (repeatItemData(props) || []).map(function(data, index) {
565
+ !isEmptyHtmlElement(tagName2(props)) && repeatItemData(props) ? (repeatItemData(props) || []).map(function(data, index) {
545
566
  return /* @__PURE__ */ jsxRuntime.jsx(RenderRepeatedBlock$1, {
546
567
  repeatContext: data.context,
547
568
  block: data.block
@@ -550,27 +571,26 @@ const RenderBlock = (props) => {
550
571
  !isEmptyHtmlElement(tagName2(props)) && !repeatItemData(props) ? /* @__PURE__ */ jsxRuntime.jsxs(state.tagName, {
551
572
  ...attributes(props),
552
573
  children: [
553
- /* @__PURE__ */ jsxRuntime.jsx(RenderComponent$1, {
574
+ /* @__PURE__ */ jsxRuntime.jsx(state.renderComponentTag, {
554
575
  ...renderComponentProps(props)
555
576
  }),
556
577
  (childrenWithoutParentComponent(props) || []).map(function(child) {
557
578
  return /* @__PURE__ */ jsxRuntime.jsx(RenderBlock, {
558
579
  block: child,
559
- context: props.context
580
+ context: childrenContext(props)
560
581
  }, "render-block-" + child.id);
561
582
  }),
562
583
  (childrenWithoutParentComponent(props) || []).map(function(child) {
563
584
  return /* @__PURE__ */ jsxRuntime.jsx(BlockStyles$1, {
564
585
  block: child,
565
- context: props.context
586
+ context: childrenContext(props)
566
587
  }, "block-style-" + child.id);
567
588
  })
568
589
  ]
569
590
  }) : null
570
591
  ]
571
- }) : /* @__PURE__ */ jsxRuntime.jsx(RenderComponent$1, {
572
- ...renderComponentProps(props),
573
- context: props.context
592
+ }) : /* @__PURE__ */ jsxRuntime.jsx(state.renderComponentTag, {
593
+ ...renderComponentProps(props)
574
594
  })
575
595
  });
576
596
  };
@@ -601,14 +621,12 @@ const onMouseEnter = function onMouseEnter2(props, state, builderContext) {
601
621
  const RenderBlocks = /* @__PURE__ */ qwik.componentQrl(qwik.inlinedQrl((props) => {
602
622
  qwik.useStylesScopedQrl(qwik.inlinedQrl(STYLES$3, "RenderBlocks_component_useStylesScoped_0XKYzaR059E"));
603
623
  const builderContext = qwik.useContext(BuilderContext);
604
- const state = {
605
- tagName: ""
606
- };
624
+ const state = {};
607
625
  return /* @__PURE__ */ jsxRuntime.jsxs("div", {
608
626
  class: className(props) + " div-RenderBlocks",
609
627
  "builder-path": props.path,
610
628
  "builder-parent-id": props.parent,
611
- style: props.style,
629
+ style: props.styleProp,
612
630
  onClick$: qwik.inlinedQrl((event) => {
613
631
  const [builderContext2, props2, state2] = qwik.useLexicalScope();
614
632
  return onClick$1(props2);
@@ -685,9 +703,7 @@ const columnCssVars = function columnCssVars2(props, state) {
685
703
  };
686
704
  const Columns = /* @__PURE__ */ qwik.componentQrl(qwik.inlinedQrl((props) => {
687
705
  qwik.useStylesScopedQrl(qwik.inlinedQrl(STYLES$2, "Columns_component_useStylesScoped_s7JLZz7MCCQ"));
688
- const state = {
689
- tagName: ""
690
- };
706
+ const state = {};
691
707
  return /* @__PURE__ */ jsxRuntime.jsx("div", {
692
708
  class: "builder-columns div-Columns",
693
709
  style: columnsCssVars(props, state),
@@ -703,7 +719,7 @@ const Columns = /* @__PURE__ */ qwik.componentQrl(qwik.inlinedQrl((props) => {
703
719
  blocks: markMutable(column.blocks),
704
720
  path: `component.options.columns.${index}.blocks`,
705
721
  parent: props.builderBlock.id,
706
- style: {
722
+ styleProp: {
707
723
  flexGrow: "1"
708
724
  }
709
725
  })
@@ -801,8 +817,7 @@ const webpSrcSet = function webpSrcSet2(props, state) {
801
817
  };
802
818
  const Image = /* @__PURE__ */ qwik.componentQrl(qwik.inlinedQrl((props) => {
803
819
  qwik.useStylesScopedQrl(qwik.inlinedQrl(STYLES$1, "Image_component_useStylesScoped_fBMYiVf9fuU"));
804
- return /* @__PURE__ */ jsxRuntime.jsxs("div", {
805
- class: "div-Image",
820
+ return /* @__PURE__ */ jsxRuntime.jsxs(qwik.Fragment, {
806
821
  children: [
807
822
  /* @__PURE__ */ jsxRuntime.jsxs("picture", {
808
823
  children: [
@@ -828,33 +843,32 @@ const Image = /* @__PURE__ */ qwik.componentQrl(qwik.inlinedQrl((props) => {
828
843
  })
829
844
  ]
830
845
  }),
831
- props.aspectRatio && !(props.fitContent && props.builderBlock?.children?.length) ? /* @__PURE__ */ jsxRuntime.jsx("div", {
832
- class: "builder-image-sizer div-Image-2",
846
+ props.aspectRatio && !(props.builderBlock?.children?.length && props.fitContent) ? /* @__PURE__ */ jsxRuntime.jsx("div", {
847
+ class: "builder-image-sizer div-Image",
833
848
  style: {
834
849
  paddingTop: props.aspectRatio * 100 + "%"
835
850
  }
836
851
  }) : null,
837
852
  props.builderBlock?.children?.length && props.fitContent ? /* @__PURE__ */ jsxRuntime.jsx(qwik.Slot, {}) : null,
838
- !props.fitContent ? /* @__PURE__ */ jsxRuntime.jsx("div", {
839
- class: "div-Image-3",
853
+ !props.fitContent && props.children ? /* @__PURE__ */ jsxRuntime.jsx("div", {
854
+ class: "div-Image-2",
840
855
  children: /* @__PURE__ */ jsxRuntime.jsx(qwik.Slot, {})
841
856
  }) : null
842
857
  ]
843
858
  });
844
859
  }, "Image_component_LRxDkFa1EfU"));
845
860
  const Image$1 = Image;
846
- const STYLES$1 = `.div-Image {
847
- position: relative; }.img-Image {
861
+ const STYLES$1 = `.img-Image {
848
862
  opacity: 1;
849
863
  transition: opacity 0.2s ease-in-out;
850
864
  position: absolute;
851
865
  height: 100%;
852
866
  width: 100%;
853
867
  top: 0px;
854
- left: 0px; }.div-Image-2 {
868
+ left: 0px; }.div-Image {
855
869
  width: 100%;
856
870
  pointer-events: none;
857
- font-size: 0; }.div-Image-3 {
871
+ font-size: 0; }.div-Image-2 {
858
872
  display: flex;
859
873
  flex-direction: column;
860
874
  align-items: stretch;
@@ -889,9 +903,15 @@ const videoProps = function videoProps2(props, state) {
889
903
  } : {}
890
904
  };
891
905
  };
906
+ const spreadProps = function spreadProps2(props, state) {
907
+ return {
908
+ ...props.attributes,
909
+ ...videoProps(props)
910
+ };
911
+ };
892
912
  const Video = /* @__PURE__ */ qwik.componentQrl(qwik.inlinedQrl((props) => {
893
913
  return /* @__PURE__ */ jsxRuntime.jsx("video", {
894
- ...videoProps(props),
914
+ ...spreadProps(props),
895
915
  style: {
896
916
  width: "100%",
897
917
  height: "100%",
@@ -1776,7 +1796,7 @@ const CustomCode = /* @__PURE__ */ qwik.componentQrl(qwik.inlinedQrl((props) =>
1776
1796
  });
1777
1797
  }, "CustomCode_component_uYOSy7w7Zqw"));
1778
1798
  const customCode = CustomCode;
1779
- const componentInfo2 = {
1799
+ const componentInfo = {
1780
1800
  name: "Custom Code",
1781
1801
  static: true,
1782
1802
  builtIn: true,
@@ -1849,7 +1869,7 @@ const getDefaultRegisteredComponents = () => [
1849
1869
  },
1850
1870
  {
1851
1871
  component: customCode,
1852
- ...componentInfo2
1872
+ ...componentInfo
1853
1873
  }
1854
1874
  ];
1855
1875
  function flatten(object, path = null, separator = ".") {
@@ -2126,7 +2146,6 @@ const createRegisterComponentMessage = ({ component: _, ...info }) => ({
2126
2146
  type: "builder.registerComponent",
2127
2147
  data: prepareComponentInfoToSend(info)
2128
2148
  });
2129
- const fastClone = (obj) => JSON.parse(JSON.stringify(obj));
2130
2149
  const serializeValue = (value) => typeof value === "function" ? serializeFn(value) : fastClone(value);
2131
2150
  const serializeFn = (fnValue) => {
2132
2151
  const fnStr = fnValue.toString().trim();
@@ -2232,18 +2251,18 @@ const getTrackingEventData = async ({ canTrack }) => {
2232
2251
  visitorId
2233
2252
  };
2234
2253
  };
2235
- const createEvent = async ({ type: eventType, canTrack, orgId, contentId, ...properties }) => ({
2254
+ const createEvent = async ({ type: eventType, canTrack, apiKey, metadata, ...properties }) => ({
2236
2255
  type: eventType,
2237
2256
  data: {
2238
2257
  ...properties,
2258
+ metadata: JSON.stringify(metadata),
2239
2259
  ...await getTrackingEventData({
2240
2260
  canTrack
2241
2261
  }),
2242
- ownerId: orgId,
2243
- contentId
2262
+ ownerId: apiKey
2244
2263
  }
2245
2264
  });
2246
- async function track(eventProps) {
2265
+ async function _track(eventProps) {
2247
2266
  if (!eventProps.canTrack)
2248
2267
  return;
2249
2268
  if (isEditing())
@@ -2265,6 +2284,10 @@ async function track(eventProps) {
2265
2284
  console.error("Failed to track: ", err);
2266
2285
  });
2267
2286
  }
2287
+ const track = (args) => _track({
2288
+ ...args,
2289
+ canTrack: true
2290
+ });
2268
2291
  const getCssFromFont = function getCssFromFont2(props, state, font) {
2269
2292
  const family = font.family + (font.kind && !font.kind.includes("#") ? ", " + font.kind : "");
2270
2293
  const name = family.split(",")[0];
@@ -2308,9 +2331,7 @@ ${getFontCss(props, state, {
2308
2331
  })}`;
2309
2332
  };
2310
2333
  const RenderContentStyles = /* @__PURE__ */ qwik.componentQrl(qwik.inlinedQrl((props) => {
2311
- const state = {
2312
- tagName: ""
2313
- };
2334
+ const state = {};
2314
2335
  return /* @__PURE__ */ jsxRuntime.jsx(RenderInlinedStyles$1, {
2315
2336
  styles: injectedStyles(props, state)
2316
2337
  });
@@ -2384,13 +2405,17 @@ const httpReqsData = function httpReqsData2(props, state, elementRef) {
2384
2405
  return {};
2385
2406
  };
2386
2407
  const onClick2 = function onClick3(props, state, elementRef, _event) {
2387
- if (useContent(props, state))
2388
- track({
2408
+ if (useContent(props, state)) {
2409
+ const variationId = useContent(props, state)?.testVariationId;
2410
+ const contentId = useContent(props, state)?.id;
2411
+ _track({
2389
2412
  type: "click",
2390
2413
  canTrack: canTrackToUse(props),
2391
- contentId: useContent(props, state)?.id,
2392
- orgId: props.apiKey
2414
+ contentId,
2415
+ apiKey: props.apiKey,
2416
+ variationId: variationId !== contentId ? variationId : void 0
2393
2417
  });
2418
+ }
2394
2419
  };
2395
2420
  const evalExpression = function evalExpression2(props, state, elementRef, expression) {
2396
2421
  return expression.replace(/{{([^}]+)}}/g, (_match, group) => evaluate({
@@ -2466,6 +2491,7 @@ const RenderContent = /* @__PURE__ */ qwik.componentQrl(qwik.inlinedQrl((props)
2466
2491
  if (isBrowser()) {
2467
2492
  if (isEditing()) {
2468
2493
  state2.forceReRenderCount = state2.forceReRenderCount + 1;
2494
+ elementRef2.current && qwik._useMutableProps(elementRef2.current, true);
2469
2495
  registerInsertMenu();
2470
2496
  setupBrowserForEditing();
2471
2497
  Object.values(allRegisteredComponents(props2)).forEach((registeredComponent) => {
@@ -2475,13 +2501,17 @@ const RenderContent = /* @__PURE__ */ qwik.componentQrl(qwik.inlinedQrl((props)
2475
2501
  window.addEventListener("message", processMessage.bind(null, props2, state2, elementRef2));
2476
2502
  window.addEventListener("builder:component:stateChangeListenerActivated", emitStateUpdate.bind(null, props2, state2, elementRef2));
2477
2503
  }
2478
- if (useContent(props2, state2))
2479
- track({
2504
+ if (useContent(props2, state2)) {
2505
+ const variationId = useContent(props2, state2)?.testVariationId;
2506
+ const contentId = useContent(props2, state2)?.id;
2507
+ _track({
2480
2508
  type: "impression",
2481
2509
  canTrack: canTrackToUse(props2),
2482
- contentId: useContent(props2, state2)?.id,
2483
- orgId: props2.apiKey
2510
+ contentId,
2511
+ apiKey: props2.apiKey,
2512
+ variationId: variationId !== contentId ? variationId : void 0
2484
2513
  });
2514
+ }
2485
2515
  if (isPreviewing()) {
2486
2516
  const searchParams = new URL(location.href).searchParams;
2487
2517
  if (props2.model && searchParams.get("builder.preview") === props2.model) {
@@ -2555,6 +2585,7 @@ const RenderContent = /* @__PURE__ */ qwik.componentQrl(qwik.inlinedQrl((props)
2555
2585
  state
2556
2586
  ]),
2557
2587
  "builder-content-id": useContent(props, state)?.id,
2588
+ "builder-model": props.model,
2558
2589
  children: [
2559
2590
  shouldRenderContentStyles(props, state) ? /* @__PURE__ */ jsxRuntime.jsx(RenderContentStyles$1, {
2560
2591
  cssCode: useContent(props, state)?.data?.cssCode,
@@ -2568,25 +2599,21 @@ const RenderContent = /* @__PURE__ */ qwik.componentQrl(qwik.inlinedQrl((props)
2568
2599
  });
2569
2600
  }, "RenderContent_component_hEAI0ahViXM"));
2570
2601
  const RenderContent$1 = RenderContent;
2602
+ const contentToUse = function contentToUse2(props, state, builderContext) {
2603
+ return props.symbol?.content || state.fetchedContent;
2604
+ };
2571
2605
  const Symbol$1 = /* @__PURE__ */ qwik.componentQrl(qwik.inlinedQrl((props) => {
2572
2606
  const builderContext = qwik.useContext(BuilderContext);
2573
2607
  const state = qwik.useStore({
2574
2608
  className: "builder-symbol",
2575
- content: null
2609
+ fetchedContent: null
2576
2610
  });
2577
- qwik.useClientEffectQrl(qwik.inlinedQrl(() => {
2578
- const [props2, state2] = qwik.useLexicalScope();
2579
- state2.content = props2.symbol?.content;
2580
- }, "Symbol_component_useClientEffect_Kfc9q3nzeSQ", [
2581
- props,
2582
- state
2583
- ]));
2584
2611
  qwik.useWatchQrl(qwik.inlinedQrl(({ track: track2 }) => {
2585
2612
  const [builderContext2, props2, state2] = qwik.useLexicalScope();
2586
2613
  props2 && track2(props2, "symbol");
2587
- state2 && track2(state2, "content");
2614
+ state2 && track2(state2, "fetchedContent");
2588
2615
  const symbolToUse = props2.symbol;
2589
- if (symbolToUse && !symbolToUse.content && !state2.content && symbolToUse.model)
2616
+ if (symbolToUse && !symbolToUse.content && !state2.fetchedContent && symbolToUse.model)
2590
2617
  getContent({
2591
2618
  model: symbolToUse.model,
2592
2619
  apiKey: builderContext2.apiKey,
@@ -2594,7 +2621,7 @@ const Symbol$1 = /* @__PURE__ */ qwik.componentQrl(qwik.inlinedQrl((props) => {
2594
2621
  id: symbolToUse.entry
2595
2622
  }
2596
2623
  }).then((response) => {
2597
- state2.content = response;
2624
+ state2.fetchedContent = response;
2598
2625
  });
2599
2626
  }, "Symbol_component_useWatch_9HNT04zd0Dk", [
2600
2627
  builderContext,
@@ -2614,7 +2641,7 @@ const Symbol$1 = /* @__PURE__ */ qwik.componentQrl(qwik.inlinedQrl((props) => {
2614
2641
  ...props.symbol?.content?.data?.state
2615
2642
  }),
2616
2643
  model: props.symbol?.model,
2617
- content: markMutable(state.content)
2644
+ content: markMutable(contentToUse(props, state))
2618
2645
  })
2619
2646
  });
2620
2647
  }, "Symbol_component_WVvggdkUPdk"));
@@ -2654,3 +2681,4 @@ exports.normalizeSearchParams = normalizeSearchParams;
2654
2681
  exports.register = register;
2655
2682
  exports.registerComponent = registerComponent;
2656
2683
  exports.setEditorSettings = setEditorSettings;
2684
+ exports.track = track;