@builder.io/sdk-qwik 0.0.36 → 0.0.38

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 (31) hide show
  1. package/lib/index.qwik.cjs +240 -162
  2. package/lib/index.qwik.mjs +240 -162
  3. package/package.json +6 -3
  4. package/types/blocks/columns/columns.d.ts +36 -1
  5. package/types/blocks/image/image.d.ts +8 -1
  6. package/types/blocks/symbol/symbol.d.ts +1 -0
  7. package/types/components/render-block/render-block.d.ts +4 -1
  8. package/types/components/render-block/render-component.d.ts +2 -0
  9. package/types/components/render-content/render-content.d.ts +2 -0
  10. package/types/functions/evaluate.d.ts +2 -1
  11. package/types/functions/get-block-actions-handler.d.ts +1 -1
  12. package/types/functions/get-block-properties.d.ts +1 -0
  13. package/types/functions/get-block-styles.d.ts +5 -1
  14. package/types/functions/get-builder-search-params/index.d.ts +1 -1
  15. package/types/functions/get-content/index.d.ts +3 -0
  16. package/types/functions/get-content/types.d.ts +4 -0
  17. package/types/functions/get-react-native-block-styles.d.ts +2 -1
  18. package/types/functions/mark-mutable.d.ts +2 -2
  19. package/types/functions/track.d.ts +6 -1
  20. package/types/functions/transform-block-properties.d.ts +1 -0
  21. package/types/helpers/css.d.ts +2 -0
  22. package/types/scripts/init-editing.d.ts +4 -1
  23. package/types/talk/generators-updated.d.ts +1 -0
  24. package/types/talk/generators.d.ts +6 -0
  25. package/types/types/builder-block.d.ts +1 -0
  26. package/types/types/builder-content.d.ts +6 -4
  27. package/types/types/targets.d.ts +1 -1
  28. package/types-hacks.d.ts +13 -0
  29. package/types/blocks/avatar/avatar.d.ts +0 -267
  30. package/types/blocks/avatar/avatar.model.d.ts +0 -19
  31. package/types/functions/get-block-bindings.d.ts +0 -2
@@ -46,7 +46,7 @@ const registerInsertMenu = ()=>{
46
46
  {
47
47
  name: 'Columns'
48
48
  },
49
- ...TARGET === 'reactNative' ? [] : [
49
+ ...[
50
50
  {
51
51
  name: 'Core:Section'
52
52
  },
@@ -64,7 +64,7 @@ const registerInsertMenu = ()=>{
64
64
  });
65
65
  };
66
66
  let isSetupForEditing = false;
67
- const setupBrowserForEditing = ()=>{
67
+ const setupBrowserForEditing = (options = {})=>{
68
68
  if (isSetupForEditing) return;
69
69
  isSetupForEditing = true;
70
70
  if (isBrowser()) {
@@ -82,6 +82,12 @@ const setupBrowserForEditing = ()=>{
82
82
  supportsCustomBreakpoints: true
83
83
  }
84
84
  }, '*');
85
+ window.parent?.postMessage({
86
+ type: 'builder.updateContent',
87
+ data: {
88
+ options
89
+ }
90
+ }, '*');
85
91
  window.addEventListener('message', ({ data })=>{
86
92
  if (!data?.type) return;
87
93
  switch(data.type){
@@ -186,7 +192,7 @@ const getSizesForBreakpoints = ({ small , medium })=>{
186
192
  return newSizes;
187
193
  };
188
194
 
189
- function evaluate({ code , context , state , event }) {
195
+ function evaluate({ code , context , state , event , isExpression =true }) {
190
196
  if (code === '') {
191
197
  console.warn('Skipping evaluation of empty code block.');
192
198
  return;
@@ -198,12 +204,13 @@ function evaluate({ code , context , state , event }) {
198
204
  };
199
205
  // Be able to handle simple expressions like "state.foo" or "1 + 1"
200
206
  // as well as full blocks like "var foo = "bar"; return foo"
201
- const useReturn = !(code.includes(';') || code.includes(' return ') || code.trim().startsWith('return '));
207
+ const useReturn = // we disable this for cases where we definitely don't want a return
208
+ isExpression && !(code.includes(';') || code.includes(' return ') || code.trim().startsWith('return '));
202
209
  const useCode = useReturn ? `return (${code});` : code;
203
210
  try {
204
211
  return new Function('builder', 'Builder' /* <- legacy */ , 'state', 'context', 'event', useCode)(builder, builder, state, context, event);
205
212
  } catch (e) {
206
- console.warn('Builder custom code error: \n While Evaluating: \n ', useCode, '\n', e.message || e);
213
+ console.warn('Builder custom code error: \n While Evaluating: \n ', useCode, '\n', e);
207
214
  }
208
215
  }
209
216
 
@@ -259,15 +266,19 @@ function getProcessedBlock({ block , context , shouldEvaluateBindings , state }
259
266
 
260
267
  const camelToKebabCase = (string)=>string.replace(/([a-z0-9]|(?=[A-Z]))([A-Z])/g, '$1-$2').toLowerCase();
261
268
 
262
- const convertStyleMaptoCSS = (style)=>{
269
+ const checkIsDefined = (maybeT)=>maybeT !== null && maybeT !== undefined;
270
+
271
+ const convertStyleMapToCSSArray = (style)=>{
263
272
  const cssProps = Object.entries(style).map(([key, value])=>{
264
273
  if (typeof value === 'string') return `${camelToKebabCase(key)}: ${value};`;
274
+ else return undefined;
265
275
  });
266
- return cssProps.join('\n');
276
+ return cssProps.filter(checkIsDefined);
267
277
  };
278
+ const convertStyleMapToCSS = (style)=>convertStyleMapToCSSArray(style).join('\n');
268
279
  const createCssClass = ({ mediaQuery , className , styles })=>{
269
280
  const cssClass = `.${className} {
270
- ${convertStyleMaptoCSS(styles)}
281
+ ${convertStyleMapToCSS(styles)}
271
282
  }`;
272
283
  if (mediaQuery) return `${mediaQuery} {
273
284
  ${cssClass}
@@ -331,7 +342,7 @@ const css = function css(props, state) {
331
342
  };
332
343
  const BlockStyles = (props)=>{
333
344
  return /*#__PURE__*/ jsx(Fragment$1, {
334
- children: TARGET !== "reactNative" && css(props) ? /*#__PURE__*/ jsx(RenderInlinedStyles$1, {
345
+ children: css(props) ? /*#__PURE__*/ jsx(RenderInlinedStyles$1, {
335
346
  styles: css(props)
336
347
  }) : null
337
348
  });
@@ -343,7 +354,7 @@ function capitalizeFirstLetter(string) {
343
354
  }
344
355
  const getEventHandlerName = (key)=>`on${capitalizeFirstLetter(key)}$`;
345
356
 
346
- function crateEventHandler(value, options) {
357
+ function createEventHandler(value, options) {
347
358
  return inlinedQrl((event)=>{
348
359
  const [options, value] = useLexicalScope();
349
360
  return evaluate({
@@ -352,7 +363,7 @@ function crateEventHandler(value, options) {
352
363
  state: options.state,
353
364
  event
354
365
  });
355
- }, "crateEventHandler_wgxT8Hlq4s8", [
366
+ }, "createEventHandler_7wCAiJVliNE", [
356
367
  options,
357
368
  value
358
369
  ]);
@@ -365,33 +376,11 @@ function getBlockActions(options) {
365
376
  // eslint-disable-next-line no-prototype-builtins
366
377
  if (!optionActions.hasOwnProperty(key)) continue;
367
378
  const value = optionActions[key];
368
- obj[getEventHandlerName(key)] = crateEventHandler(value, options);
379
+ obj[getEventHandlerName(key)] = createEventHandler(value, options);
369
380
  }
370
381
  return obj;
371
382
  }
372
383
 
373
- function getBlockBindings(state, block) {
374
- const props = {};
375
- const bindings = block.bindings;
376
- if (bindings) for(const key in bindings){
377
- if (key.startsWith('component.')) ;
378
- else if (key.startsWith('style.')) {
379
- const styleKey = key.substring(6);
380
- const style = props.style || (props.style = {});
381
- style[styleKey] = evaluate({
382
- code: bindings[key],
383
- state,
384
- context: {}
385
- });
386
- } else props[key] = evaluate({
387
- code: bindings[key],
388
- state,
389
- context: {}
390
- });
391
- }
392
- return props;
393
- }
394
-
395
384
  function getBlockComponentOptions(block) {
396
385
  return {
397
386
  ...block.component?.options,
@@ -402,10 +391,15 @@ function getBlockComponentOptions(block) {
402
391
  };
403
392
  }
404
393
 
394
+ function transformBlockProperties(properties) {
395
+ return properties;
396
+ }
397
+
405
398
  function getBlockProperties(block) {
406
- return {
399
+ const properties = {
407
400
  ...block.properties,
408
401
  'builder-id': block.id,
402
+ style: getStyleAttribute(block.style),
409
403
  class: [
410
404
  block.id,
411
405
  'builder-block',
@@ -413,6 +407,25 @@ function getBlockProperties(block) {
413
407
  block.properties?.class
414
408
  ].filter(Boolean).join(' ')
415
409
  };
410
+ return transformBlockProperties(properties);
411
+ }
412
+ /**
413
+ * Svelte does not support style attribute as an object so we need to flatten it.
414
+ *
415
+ * Additionally, Svelte, Vue and other frameworks use kebab-case styles, so we need to convert them.
416
+ */ function getStyleAttribute(style) {
417
+ if (!style) return undefined;
418
+ switch(TARGET){
419
+ case 'svelte':
420
+ case 'vue2':
421
+ case 'vue3':
422
+ case 'solid':
423
+ return convertStyleMapToCSSArray(style).join(' ');
424
+ case 'qwik':
425
+ case 'reactNative':
426
+ case 'react':
427
+ return style;
428
+ }
416
429
  }
417
430
 
418
431
  function getBlockTag(block) {
@@ -476,51 +489,6 @@ const RenderComponent = (props)=>{
476
489
  };
477
490
  const RenderComponent$1 = RenderComponent;
478
491
 
479
- // GENERATED BY MITOSIS
480
- const RenderComponentWithContext = /*#__PURE__*/ componentQrl(inlinedQrl((props)=>{
481
- useContextProvider(BuilderContext, useStore({
482
- content: (()=>{
483
- return props.context.content;
484
- })(),
485
- state: (()=>{
486
- return props.context.state;
487
- })(),
488
- context: (()=>{
489
- return props.context.context;
490
- })(),
491
- apiKey: (()=>{
492
- return props.context.apiKey;
493
- })(),
494
- registeredComponents: (()=>{
495
- return props.context.registeredComponents;
496
- })(),
497
- inheritedStyles: (()=>{
498
- return props.context.inheritedStyles;
499
- })()
500
- }));
501
- return /*#__PURE__*/ jsx(RenderComponent$1, {
502
- get componentRef () {
503
- return props.componentRef;
504
- },
505
- get componentOptions () {
506
- return props.componentOptions;
507
- },
508
- get blockChildren () {
509
- return props.blockChildren;
510
- },
511
- get context () {
512
- return props.context;
513
- },
514
- [_IMMUTABLE]: {
515
- componentRef: _wrapSignal(props, "componentRef"),
516
- componentOptions: _wrapSignal(props, "componentOptions"),
517
- blockChildren: _wrapSignal(props, "blockChildren"),
518
- context: _wrapSignal(props, "context")
519
- }
520
- });
521
- }, "RenderComponentWithContext_component_nXOUbUnjTAo"));
522
- const RenderComponentWithContext$1 = RenderComponentWithContext;
523
-
524
492
  // GENERATED BY MITOSIS
525
493
  /**
526
494
  * We can't make this a generic `ProvideContext` function because Vue 2 won't support root slots, e.g.
@@ -595,15 +563,17 @@ const useBlock = function useBlock(props, state) {
595
563
  shouldEvaluateBindings: true
596
564
  });
597
565
  };
566
+ const actions = function actions(props, state) {
567
+ return getBlockActions({
568
+ block: useBlock(props),
569
+ state: props.context.state,
570
+ context: props.context.context
571
+ });
572
+ };
598
573
  const attributes = function attributes(props, state) {
574
+ const blockProperties = getBlockProperties(useBlock(props));
599
575
  return {
600
- ...getBlockProperties(useBlock(props)),
601
- ...getBlockBindings(props.context.state, useBlock(props)),
602
- ...getBlockActions({
603
- block: useBlock(props),
604
- state: props.context.state,
605
- context: props.context.context
606
- }),
576
+ ...blockProperties,
607
577
  ...{}
608
578
  };
609
579
  };
@@ -620,8 +590,12 @@ const renderComponentProps = function renderComponentProps(props, state) {
620
590
  * These attributes are passed to the wrapper element when there is one. If `noWrap` is set to true, then
621
591
  * they are provided to the component itself directly.
622
592
  */ ...shouldWrap(props) ? {} : {
623
- attributes: attributes(props)
624
- }
593
+ attributes: {
594
+ ...attributes(props),
595
+ ...actions(props)
596
+ }
597
+ },
598
+ customBreakpoints: childrenContext(props)?.content?.meta?.breakpoints
625
599
  },
626
600
  context: childrenContext(props)
627
601
  };
@@ -685,8 +659,7 @@ const childrenContext = function childrenContext(props, state) {
685
659
  };
686
660
  };
687
661
  const renderComponentTag = function renderComponentTag(props, state) {
688
- if (TARGET === "reactNative") return RenderComponentWithContext$1;
689
- else return RenderComponent$1;
662
+ return RenderComponent$1;
690
663
  };
691
664
  const RenderBlock = (props)=>{
692
665
  const state = {};
@@ -696,7 +669,8 @@ const RenderBlock = (props)=>{
696
669
  children: shouldWrap(props) ? /*#__PURE__*/ jsxs(Fragment$1, {
697
670
  children: [
698
671
  isEmptyHtmlElement(tag(props)) ? /*#__PURE__*/ jsx(state.tag, {
699
- ...attributes(props)
672
+ ...attributes(props),
673
+ ...actions(props)
700
674
  }) : null,
701
675
  !isEmptyHtmlElement(tag(props)) && repeatItemData(props) ? (repeatItemData(props) || []).map(function(data, index) {
702
676
  return /*#__PURE__*/ jsx(RenderRepeatedBlock$1, {
@@ -714,6 +688,7 @@ const RenderBlock = (props)=>{
714
688
  }) : null,
715
689
  !isEmptyHtmlElement(tag(props)) && !repeatItemData(props) ? /*#__PURE__*/ jsxs(state.tag, {
716
690
  ...attributes(props),
691
+ ...actions(props),
717
692
  children: [
718
693
  /*#__PURE__*/ jsx(state.renderComponentTag, {
719
694
  ...renderComponentProps(props)
@@ -741,7 +716,7 @@ const RenderBlock = (props)=>{
741
716
  const RenderBlock$1 = RenderBlock;
742
717
 
743
718
  // GENERATED BY MITOSIS
744
- const className = function className(props, state, builderContext) {
719
+ const className$1 = function className(props, state, builderContext) {
745
720
  return "builder-blocks" + (!props.blocks?.length ? " no-blocks" : "");
746
721
  };
747
722
  const onClick$1 = function onClick(props, state, builderContext) {
@@ -767,7 +742,7 @@ const RenderBlocks = /*#__PURE__*/ componentQrl(inlinedQrl((props)=>{
767
742
  const builderContext = useContext(BuilderContext);
768
743
  const state = {};
769
744
  return /*#__PURE__*/ jsxs("div", {
770
- class: className(props) + " div-RenderBlocks",
745
+ class: className$1(props) + " div-RenderBlocks",
771
746
  get "builder-path" () {
772
747
  return props.path;
773
748
  },
@@ -858,54 +833,113 @@ const columnCssVars = function columnCssVars(props, state) {
858
833
  "--column-margin-left-tablet": maybeApplyForTablet(props, state, marginLeft)
859
834
  };
860
835
  };
836
+ const getWidthForBreakpointSize = function getWidthForBreakpointSize(props, state, size) {
837
+ const breakpointSizes = getSizesForBreakpoints(props.customBreakpoints || {});
838
+ return breakpointSizes[size].max;
839
+ };
840
+ const columnStyleObjects = function columnStyleObjects(props, state) {
841
+ return {
842
+ columns: {
843
+ small: {
844
+ flexDirection: "var(--flex-dir)",
845
+ alignItems: "stretch"
846
+ },
847
+ medium: {
848
+ flexDirection: "var(--flex-dir-tablet)",
849
+ alignItems: "stretch"
850
+ }
851
+ },
852
+ column: {
853
+ small: {
854
+ width: "var(--column-width) !important",
855
+ marginLeft: "var(--column-margin-left) !important"
856
+ },
857
+ medium: {
858
+ width: "var(--column-width-tablet) !important",
859
+ marginLeft: "var(--column-margin-left-tablet) !important"
860
+ }
861
+ }
862
+ };
863
+ };
864
+ const columnsStyles = function columnsStyles(props, state) {
865
+ return `
866
+ @media (max-width: ${getWidthForBreakpointSize(props, state, "medium")}px) {
867
+ .${props.builderBlock.id}-breakpoints {
868
+ ${convertStyleMapToCSS(columnStyleObjects().columns.medium)}
869
+ }
870
+
871
+ .${props.builderBlock.id}-breakpoints > .builder-column {
872
+ ${convertStyleMapToCSS(columnStyleObjects().column.medium)}
873
+ }
874
+ }
875
+
876
+ @media (max-width: ${getWidthForBreakpointSize(props, state, "small")}px) {
877
+ .${props.builderBlock.id}-breakpoints {
878
+ ${convertStyleMapToCSS(columnStyleObjects().columns.small)}
879
+ }
880
+
881
+ .${props.builderBlock.id}-breakpoints > .builder-column {
882
+ ${convertStyleMapToCSS(columnStyleObjects().column.small)}
883
+ }
884
+ },
885
+ `;
886
+ };
887
+ const reactNativeColumnsStyles = function reactNativeColumnsStyles(props, state) {
888
+ return columnStyleObjects().columns.small;
889
+ };
890
+ const reactNativeColumnStyles = function reactNativeColumnStyles(props, state) {
891
+ return columnStyleObjects().column.small;
892
+ };
861
893
  const Columns = /*#__PURE__*/ componentQrl(inlinedQrl((props)=>{
862
894
  useStylesScopedQrl(inlinedQrl(STYLES$2, "Columns_component_useStylesScoped_s7JLZz7MCCQ"));
863
895
  const state = {};
864
- return /*#__PURE__*/ jsx("div", {
865
- class: "builder-columns div-Columns",
866
- style: columnsCssVars(props, state),
867
- children: (props.columns || []).map(function(column, index) {
868
- return /*#__PURE__*/ jsx("div", {
869
- class: "builder-column div-Columns-2",
870
- style: {
871
- width: getColumnCssWidth(props, state, index),
872
- marginLeft: `${index === 0 ? 0 : getGutterSize(props)}px`,
873
- ...columnCssVars(props, state)
874
- },
875
- children: /*#__PURE__*/ jsx(RenderBlocks$1, {
876
- get blocks () {
877
- return column.blocks;
878
- },
879
- path: `component.options.columns.${index}.blocks`,
880
- get parent () {
881
- return props.builderBlock.id;
882
- },
883
- styleProp: {
884
- flexGrow: "1"
896
+ return /*#__PURE__*/ jsxs("div", {
897
+ class: `builder-columns ${props.builderBlock.id}-breakpoints` + " div-Columns",
898
+ style: {
899
+ ...TARGET === "reactNative" ? reactNativeColumnsStyles() : {},
900
+ ...columnsCssVars(props, state)
901
+ },
902
+ children: [
903
+ TARGET !== "reactNative" ? /*#__PURE__*/ jsx(RenderInlinedStyles$1, {
904
+ styles: columnsStyles(props, state)
905
+ }) : null,
906
+ (props.columns || []).map(function(column, index) {
907
+ return /*#__PURE__*/ jsx("div", {
908
+ class: "builder-column div-Columns-2",
909
+ style: {
910
+ width: getColumnCssWidth(props, state, index),
911
+ marginLeft: `${index === 0 ? 0 : getGutterSize(props)}px`,
912
+ ...TARGET === "reactNative" ? reactNativeColumnStyles() : {},
913
+ ...columnCssVars(props, state)
885
914
  },
886
- [_IMMUTABLE]: {
887
- blocks: _wrapSignal(column, "blocks"),
888
- parent: _wrapSignal(props.builderBlock, "id")
889
- }
890
- })
891
- }, index);
892
- })
915
+ children: /*#__PURE__*/ jsx(RenderBlocks$1, {
916
+ get blocks () {
917
+ return column.blocks;
918
+ },
919
+ path: `component.options.columns.${index}.blocks`,
920
+ get parent () {
921
+ return props.builderBlock.id;
922
+ },
923
+ styleProp: {
924
+ flexGrow: "1"
925
+ },
926
+ [_IMMUTABLE]: {
927
+ blocks: _wrapSignal(column, "blocks"),
928
+ parent: _wrapSignal(props.builderBlock, "id")
929
+ }
930
+ })
931
+ }, index);
932
+ })
933
+ ]
893
934
  });
894
935
  }, "Columns_component_7yLj4bxdI6c"));
895
936
  const Columns$1 = Columns;
896
937
  const STYLES$2 = `.div-Columns {
897
938
  display: flex;
898
- align-items: stretch;
899
- line-height: normal; }@media (max-width: 991px) { .div-Columns {
900
- flex-direction: var(--flex-dir-tablet); } }@media (max-width: 639px) { .div-Columns {
901
- flex-direction: var(--flex-dir); } }.div-Columns-2 {
939
+ line-height: normal; }.div-Columns-2 {
902
940
  display: flex;
903
941
  flex-direction: column;
904
- align-items: stretch; }@media (max-width: 991px) { .div-Columns-2 {
905
- width: var(--column-width-tablet) !important;
906
- margin-left: var(--column-margin-left-tablet) !important; } }@media (max-width: 639px) { .div-Columns-2 {
907
- width: var(--column-width) !important;
908
- margin-left: var(--column-margin-left) !important; } }`;
942
+ align-items: stretch; }`;
909
943
 
910
944
  // Taken from (and modified) the shopify theme script repo
911
945
  // https://github.com/Shopify/theme-scripts/blob/bcfb471f2a57d439e2f964a1bb65b67708cc90c3/packages/theme-images/images.js#L59
@@ -977,6 +1011,17 @@ const webpSrcSet = function webpSrcSet(props, state) {
977
1011
  if (srcSetToUse(props)?.match(/builder\.io/) && !props.noWebp) return srcSetToUse(props).replace(/\?/g, "?format=webp&");
978
1012
  else return "";
979
1013
  };
1014
+ const aspectRatioCss = function aspectRatioCss(props, state) {
1015
+ const aspectRatioStyles = {
1016
+ position: "absolute",
1017
+ height: "100%",
1018
+ width: "100%",
1019
+ left: "0px",
1020
+ top: "0px"
1021
+ };
1022
+ const out = props.aspectRatio ? aspectRatioStyles : undefined;
1023
+ return out;
1024
+ };
980
1025
  const Image = /*#__PURE__*/ componentQrl(inlinedQrl((props)=>{
981
1026
  useStylesScopedQrl(inlinedQrl(STYLES$1, "Image_component_useStylesScoped_fBMYiVf9fuU"));
982
1027
  return /*#__PURE__*/ jsxs(Fragment$2, {
@@ -994,8 +1039,9 @@ const Image = /*#__PURE__*/ componentQrl(inlinedQrl((props)=>{
994
1039
  },
995
1040
  role: props.altText ? "presentation" : undefined,
996
1041
  style: {
997
- objectPosition: props.backgroundSize || "center",
998
- objectFit: props.backgroundSize || "cover"
1042
+ objectPosition: props.backgroundPosition || "center",
1043
+ objectFit: props.backgroundSize || "cover",
1044
+ ...aspectRatioCss(props)
999
1045
  },
1000
1046
  class: "builder-image" + (props.className ? " " + props.className : "") + " img-Image",
1001
1047
  get src () {
@@ -1019,8 +1065,8 @@ const Image = /*#__PURE__*/ componentQrl(inlinedQrl((props)=>{
1019
1065
  props.aspectRatio && !(props.builderBlock?.children?.length && props.fitContent) ? /*#__PURE__*/ jsx("div", {
1020
1066
  class: "builder-image-sizer div-Image",
1021
1067
  style: {
1022
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
1023
- paddingTop: props.aspectRatio * 100 + "%"
1068
+ paddingTop: // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
1069
+ props.aspectRatio * 100 + "%"
1024
1070
  }
1025
1071
  }) : null,
1026
1072
  props.builderBlock?.children?.length && props.fitContent ? /*#__PURE__*/ jsx(Slot, {}) : null,
@@ -1034,12 +1080,7 @@ const Image = /*#__PURE__*/ componentQrl(inlinedQrl((props)=>{
1034
1080
  const Image$1 = Image;
1035
1081
  const STYLES$1 = `.img-Image {
1036
1082
  opacity: 1;
1037
- transition: opacity 0.2s ease-in-out;
1038
- position: absolute;
1039
- height: 100%;
1040
- width: 100%;
1041
- top: 0px;
1042
- left: 0px; }.div-Image {
1083
+ transition: opacity 0.2s ease-in-out; }.div-Image {
1043
1084
  width: 100%;
1044
1085
  pointer-events: none;
1045
1086
  font-size: 0; }.div-Image-2 {
@@ -2150,6 +2191,7 @@ const componentInfo = {
2150
2191
  }
2151
2192
 
2152
2193
  const BUILDER_SEARCHPARAMS_PREFIX = 'builder.';
2194
+ const BUILDER_OPTIONS_PREFIX = 'options.';
2153
2195
  const convertSearchParamsToQueryObject = (searchParams)=>{
2154
2196
  const options = {};
2155
2197
  searchParams.forEach((value, key)=>{
@@ -2163,7 +2205,7 @@ const getBuilderSearchParams = (_options)=>{
2163
2205
  const newOptions = {};
2164
2206
  Object.keys(options).forEach((key)=>{
2165
2207
  if (key.startsWith(BUILDER_SEARCHPARAMS_PREFIX)) {
2166
- const trimmedKey = key.replace(BUILDER_SEARCHPARAMS_PREFIX, '');
2208
+ const trimmedKey = key.replace(BUILDER_SEARCHPARAMS_PREFIX, '').replace(BUILDER_OPTIONS_PREFIX, '');
2167
2209
  newOptions[trimmedKey] = options[key];
2168
2210
  }
2169
2211
  });
@@ -2285,8 +2327,6 @@ const setContentVariationCookie = ({ contentId , canTrack , value })=>setCookie
2285
2327
  canTrack
2286
2328
  });
2287
2329
 
2288
- const checkIsDefined = (maybeT)=>maybeT !== null && maybeT !== undefined;
2289
-
2290
2330
  const checkIsBuilderContentWithVariations = (item)=>checkIsDefined(item.id) && checkIsDefined(item.variations) && Object.keys(item.variations).length > 0;
2291
2331
  /**
2292
2332
  * Randomly assign a variation to this user and store it in cookies/storage
@@ -2364,9 +2404,9 @@ async function getContent(options) {
2364
2404
  })).results[0] || null;
2365
2405
  }
2366
2406
  const generateContentUrl = (options)=>{
2367
- const { limit =30 , userAttributes , query , noTraverse =false , model , apiKey , includeRefs =true , } = options;
2407
+ const { limit =30 , userAttributes , query , noTraverse =false , model , apiKey , includeRefs =true , locale , } = options;
2368
2408
  if (!apiKey) throw new Error('Missing API key');
2369
- const url = new URL(`https://cdn.builder.io/api/v2/content/${model}?apiKey=${apiKey}&limit=${limit}&noTraverse=${noTraverse}&includeRefs=${includeRefs}`);
2409
+ const url = new URL(`https://cdn.builder.io/api/v2/content/${model}?apiKey=${apiKey}&limit=${limit}&noTraverse=${noTraverse}&includeRefs=${includeRefs}${locale ? `&locale=${locale}` : ''}`);
2370
2410
  const queryOptions = {
2371
2411
  ...getBuilderSearchParamsFromWindow(),
2372
2412
  ...normalizeSearchParams(options.options || {})
@@ -2387,7 +2427,8 @@ async function getAllContent(options) {
2387
2427
  const fetch = await getFetch();
2388
2428
  const content = await fetch(url.href).then((res)=>res.json());
2389
2429
  const canTrack = options.canTrack !== false;
2390
- if (canTrack) for (const item of content.results)await handleABTesting({
2430
+ if (canTrack && // This makes sure we have a non-error response with the results array.
2431
+ Array.isArray(content.results)) for (const item of content.results)await handleABTesting({
2391
2432
  item,
2392
2433
  canTrack
2393
2434
  });
@@ -2531,6 +2572,10 @@ const createEvent = async ({ type: eventType , canTrack , apiKey , metadata , ..
2531
2572
  }
2532
2573
  });
2533
2574
  async function _track(eventProps) {
2575
+ if (!eventProps.apiKey) {
2576
+ console.error('[Builder.io]: Missing API key for track call. Please provide your API key.');
2577
+ return;
2578
+ }
2534
2579
  if (!eventProps.canTrack) return;
2535
2580
  if (isEditing()) return;
2536
2581
  if (!(isBrowser() || TARGET === 'reactNative')) return;
@@ -2572,7 +2617,7 @@ const getCssFromFont = function getCssFromFont(props, state, font) {
2572
2617
  if (font.files) for(const weight in font.files){
2573
2618
  const isNumber = String(Number(weight)) === weight;
2574
2619
  if (!isNumber) continue;
2575
- // TODO: maybe limit number loaded
2620
+ // TODO: maybe limit number loaded
2576
2621
  const weightUrl = font.files[weight];
2577
2622
  if (weightUrl && weightUrl !== url) str += `
2578
2623
  @font-face {
@@ -2618,6 +2663,11 @@ const useContent = function useContent(props, state, elementRef) {
2618
2663
  ...props.content?.data,
2619
2664
  ...props.data,
2620
2665
  ...state.overrideContent?.data
2666
+ },
2667
+ meta: {
2668
+ ...props.content?.meta,
2669
+ ...state.overrideContent?.meta,
2670
+ breakpoints: state.useBreakpoints || state.overrideContent?.meta?.breakpoints || props.content?.meta?.breakpoints
2621
2671
  }
2622
2672
  };
2623
2673
  return mergedContent;
@@ -2629,6 +2679,9 @@ const contentState = function contentState(props, state, elementRef) {
2629
2679
  return {
2630
2680
  ...props.content?.data?.state,
2631
2681
  ...props.data,
2682
+ ...props.locale ? {
2683
+ locale: props.locale
2684
+ } : {},
2632
2685
  ...state.overrideState
2633
2686
  };
2634
2687
  };
@@ -2638,6 +2691,7 @@ const contextContext = function contextContext(props, state, elementRef) {
2638
2691
  const allRegisteredComponents = function allRegisteredComponents(props, state, elementRef) {
2639
2692
  const allComponentsArray = [
2640
2693
  ...getDefaultRegisteredComponents(),
2694
+ // While this `components` object is deprecated, we must maintain support for it.
2641
2695
  // Since users are able to override our default components, we need to make sure that we do not break such
2642
2696
  // existing usage.
2643
2697
  // This is why we spread `components` after the default Builder.io components, but before the `props.customComponents`,
@@ -2654,11 +2708,20 @@ const allRegisteredComponents = function allRegisteredComponents(props, state, e
2654
2708
  const processMessage = function processMessage(props, state, elementRef, event) {
2655
2709
  const { data } = event;
2656
2710
  if (data) switch(data.type){
2657
- case "builder.contentUpdate":
2711
+ case "builder.configureSdk":
2658
2712
  {
2659
2713
  const messageContent = data.data;
2660
- const key = messageContent.key || messageContent.alias || messageContent.entry || messageContent.modelName;
2661
- const contentData = messageContent.data;
2714
+ const { breakpoints , contentId } = messageContent;
2715
+ if (!contentId || contentId !== useContent(props, state)?.id) return;
2716
+ state.useBreakpoints = breakpoints;
2717
+ state.forceReRenderCount = state.forceReRenderCount + 1; // This is a hack to force Qwik to re-render.
2718
+ break;
2719
+ }
2720
+ case "builder.contentUpdate":
2721
+ {
2722
+ const messageContent1 = data.data;
2723
+ const key = messageContent1.key || messageContent1.alias || messageContent1.entry || messageContent1.modelName;
2724
+ const contentData = messageContent1.data;
2662
2725
  if (key === props.model) {
2663
2726
  state.overrideContent = contentData;
2664
2727
  state.forceReRenderCount = state.forceReRenderCount + 1; // This is a hack to force Qwik to re-render.
@@ -2741,7 +2804,8 @@ const RenderContent = /*#__PURE__*/ componentQrl(inlinedQrl((props)=>{
2741
2804
  forceReRenderCount: 0,
2742
2805
  overrideContent: null,
2743
2806
  overrideState: {},
2744
- update: 0
2807
+ update: 0,
2808
+ useBreakpoints: null
2745
2809
  });
2746
2810
  useContextProvider(BuilderContext, useStore({
2747
2811
  content: (()=>{
@@ -2762,11 +2826,19 @@ const RenderContent = /*#__PURE__*/ componentQrl(inlinedQrl((props)=>{
2762
2826
  }));
2763
2827
  useClientEffectQrl(inlinedQrl(()=>{
2764
2828
  const [elementRef, props, state] = useLexicalScope();
2829
+ if (!props.apiKey) console.error("[Builder.io]: No API key provided to `RenderContent` component. This can cause issues. Please provide an API key using the `apiKey` prop.");
2765
2830
  if (isBrowser()) {
2766
2831
  if (isEditing()) {
2767
2832
  state.forceReRenderCount = state.forceReRenderCount + 1;
2768
2833
  registerInsertMenu();
2769
- setupBrowserForEditing();
2834
+ setupBrowserForEditing({
2835
+ ...props.locale ? {
2836
+ locale: props.locale
2837
+ } : {},
2838
+ ...props.includeRefs ? {
2839
+ includeRefs: props.includeRefs
2840
+ } : {}
2841
+ });
2770
2842
  Object.values(allRegisteredComponents(props)).forEach((registeredComponent)=>{
2771
2843
  const message = createRegisterComponentMessage(registeredComponent);
2772
2844
  window.parent?.postMessage(message, "*");
@@ -2784,7 +2856,8 @@ const RenderContent = /*#__PURE__*/ componentQrl(inlinedQrl((props)=>{
2784
2856
  apiKey: props.apiKey,
2785
2857
  variationId: variationId !== contentId ? variationId : undefined
2786
2858
  });
2787
- } // override normal content in preview mode
2859
+ }
2860
+ // override normal content in preview mode
2788
2861
  if (isPreviewing()) {
2789
2862
  const searchParams = new URL(location.href).searchParams;
2790
2863
  if (props.model && searchParams.get("builder.preview") === props.model) {
@@ -2809,6 +2882,7 @@ const RenderContent = /*#__PURE__*/ componentQrl(inlinedQrl((props)=>{
2809
2882
  useWatchQrl(inlinedQrl(({ track })=>{
2810
2883
  const [elementRef, props, state] = useLexicalScope();
2811
2884
  state.useContent?.data && track(state.useContent?.data, "jsCode");
2885
+ state && track(state, "contentState");
2812
2886
  evaluateJsCode(props, state);
2813
2887
  }, "RenderContent_component_useWatch_OIBatobA0hE", [
2814
2888
  elementRef,
@@ -2877,13 +2951,22 @@ const RenderContent = /*#__PURE__*/ componentQrl(inlinedQrl((props)=>{
2877
2951
  const RenderContent$1 = RenderContent;
2878
2952
 
2879
2953
  // GENERATED BY MITOSIS
2954
+ const className = function className(props, state, builderContext) {
2955
+ return [
2956
+ ...[
2957
+ props.attributes.class
2958
+ ],
2959
+ "builder-symbol",
2960
+ props.symbol?.inline ? "builder-inline-symbol" : undefined,
2961
+ props.symbol?.dynamic || props.dynamic ? "builder-dynamic-symbol" : undefined
2962
+ ].filter(Boolean).join(" ");
2963
+ };
2880
2964
  const contentToUse = function contentToUse(props, state, builderContext) {
2881
2965
  return props.symbol?.content || state.fetchedContent;
2882
2966
  };
2883
2967
  const Symbol$1 = /*#__PURE__*/ componentQrl(inlinedQrl((props)=>{
2884
2968
  const builderContext = useContext(BuilderContext);
2885
2969
  const state = useStore({
2886
- className: "builder-symbol",
2887
2970
  fetchedContent: null
2888
2971
  });
2889
2972
  useWatchQrl(inlinedQrl(({ track })=>{
@@ -2915,9 +2998,7 @@ const Symbol$1 = /*#__PURE__*/ componentQrl(inlinedQrl((props)=>{
2915
2998
  ]));
2916
2999
  return /*#__PURE__*/ jsx("div", {
2917
3000
  ...props.attributes,
2918
- get class () {
2919
- return state.className;
2920
- },
3001
+ class: className(props),
2921
3002
  children: /*#__PURE__*/ jsx(RenderContent$1, {
2922
3003
  get apiKey () {
2923
3004
  return builderContext.apiKey;
@@ -2937,10 +3018,7 @@ const Symbol$1 = /*#__PURE__*/ componentQrl(inlinedQrl((props)=>{
2937
3018
  apiKey: _wrapSignal(builderContext, "apiKey"),
2938
3019
  context: _wrapSignal(builderContext, "context")
2939
3020
  }
2940
- }),
2941
- [_IMMUTABLE]: {
2942
- class: _wrapSignal(state, "className")
2943
- }
3021
+ })
2944
3022
  });
2945
3023
  }, "Symbol_component_WVvggdkUPdk"));
2946
3024
  const Symbol$2 = Symbol$1;