@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
@@ -50,7 +50,7 @@ const registerInsertMenu = ()=>{
50
50
  {
51
51
  name: 'Columns'
52
52
  },
53
- ...TARGET === 'reactNative' ? [] : [
53
+ ...[
54
54
  {
55
55
  name: 'Core:Section'
56
56
  },
@@ -68,7 +68,7 @@ const registerInsertMenu = ()=>{
68
68
  });
69
69
  };
70
70
  let isSetupForEditing = false;
71
- const setupBrowserForEditing = ()=>{
71
+ const setupBrowserForEditing = (options = {})=>{
72
72
  if (isSetupForEditing) return;
73
73
  isSetupForEditing = true;
74
74
  if (isBrowser()) {
@@ -86,6 +86,12 @@ const setupBrowserForEditing = ()=>{
86
86
  supportsCustomBreakpoints: true
87
87
  }
88
88
  }, '*');
89
+ window.parent?.postMessage({
90
+ type: 'builder.updateContent',
91
+ data: {
92
+ options
93
+ }
94
+ }, '*');
89
95
  window.addEventListener('message', ({ data })=>{
90
96
  if (!data?.type) return;
91
97
  switch(data.type){
@@ -190,7 +196,7 @@ const getSizesForBreakpoints = ({ small , medium })=>{
190
196
  return newSizes;
191
197
  };
192
198
 
193
- function evaluate({ code , context , state , event }) {
199
+ function evaluate({ code , context , state , event , isExpression =true }) {
194
200
  if (code === '') {
195
201
  console.warn('Skipping evaluation of empty code block.');
196
202
  return;
@@ -202,12 +208,13 @@ function evaluate({ code , context , state , event }) {
202
208
  };
203
209
  // Be able to handle simple expressions like "state.foo" or "1 + 1"
204
210
  // as well as full blocks like "var foo = "bar"; return foo"
205
- const useReturn = !(code.includes(';') || code.includes(' return ') || code.trim().startsWith('return '));
211
+ const useReturn = // we disable this for cases where we definitely don't want a return
212
+ isExpression && !(code.includes(';') || code.includes(' return ') || code.trim().startsWith('return '));
206
213
  const useCode = useReturn ? `return (${code});` : code;
207
214
  try {
208
215
  return new Function('builder', 'Builder' /* <- legacy */ , 'state', 'context', 'event', useCode)(builder, builder, state, context, event);
209
216
  } catch (e) {
210
- console.warn('Builder custom code error: \n While Evaluating: \n ', useCode, '\n', e.message || e);
217
+ console.warn('Builder custom code error: \n While Evaluating: \n ', useCode, '\n', e);
211
218
  }
212
219
  }
213
220
 
@@ -263,15 +270,19 @@ function getProcessedBlock({ block , context , shouldEvaluateBindings , state }
263
270
 
264
271
  const camelToKebabCase = (string)=>string.replace(/([a-z0-9]|(?=[A-Z]))([A-Z])/g, '$1-$2').toLowerCase();
265
272
 
266
- const convertStyleMaptoCSS = (style)=>{
273
+ const checkIsDefined = (maybeT)=>maybeT !== null && maybeT !== undefined;
274
+
275
+ const convertStyleMapToCSSArray = (style)=>{
267
276
  const cssProps = Object.entries(style).map(([key, value])=>{
268
277
  if (typeof value === 'string') return `${camelToKebabCase(key)}: ${value};`;
278
+ else return undefined;
269
279
  });
270
- return cssProps.join('\n');
280
+ return cssProps.filter(checkIsDefined);
271
281
  };
282
+ const convertStyleMapToCSS = (style)=>convertStyleMapToCSSArray(style).join('\n');
272
283
  const createCssClass = ({ mediaQuery , className , styles })=>{
273
284
  const cssClass = `.${className} {
274
- ${convertStyleMaptoCSS(styles)}
285
+ ${convertStyleMapToCSS(styles)}
275
286
  }`;
276
287
  if (mediaQuery) return `${mediaQuery} {
277
288
  ${cssClass}
@@ -335,7 +346,7 @@ const css = function css(props, state) {
335
346
  };
336
347
  const BlockStyles = (props)=>{
337
348
  return /*#__PURE__*/ jsxRuntime.jsx(jsxRuntime.Fragment, {
338
- children: TARGET !== "reactNative" && css(props) ? /*#__PURE__*/ jsxRuntime.jsx(RenderInlinedStyles$1, {
349
+ children: css(props) ? /*#__PURE__*/ jsxRuntime.jsx(RenderInlinedStyles$1, {
339
350
  styles: css(props)
340
351
  }) : null
341
352
  });
@@ -347,7 +358,7 @@ function capitalizeFirstLetter(string) {
347
358
  }
348
359
  const getEventHandlerName = (key)=>`on${capitalizeFirstLetter(key)}$`;
349
360
 
350
- function crateEventHandler(value, options) {
361
+ function createEventHandler(value, options) {
351
362
  return qwik.inlinedQrl((event)=>{
352
363
  const [options, value] = qwik.useLexicalScope();
353
364
  return evaluate({
@@ -356,7 +367,7 @@ function crateEventHandler(value, options) {
356
367
  state: options.state,
357
368
  event
358
369
  });
359
- }, "crateEventHandler_wgxT8Hlq4s8", [
370
+ }, "createEventHandler_7wCAiJVliNE", [
360
371
  options,
361
372
  value
362
373
  ]);
@@ -369,33 +380,11 @@ function getBlockActions(options) {
369
380
  // eslint-disable-next-line no-prototype-builtins
370
381
  if (!optionActions.hasOwnProperty(key)) continue;
371
382
  const value = optionActions[key];
372
- obj[getEventHandlerName(key)] = crateEventHandler(value, options);
383
+ obj[getEventHandlerName(key)] = createEventHandler(value, options);
373
384
  }
374
385
  return obj;
375
386
  }
376
387
 
377
- function getBlockBindings(state, block) {
378
- const props = {};
379
- const bindings = block.bindings;
380
- if (bindings) for(const key in bindings){
381
- if (key.startsWith('component.')) ;
382
- else if (key.startsWith('style.')) {
383
- const styleKey = key.substring(6);
384
- const style = props.style || (props.style = {});
385
- style[styleKey] = evaluate({
386
- code: bindings[key],
387
- state,
388
- context: {}
389
- });
390
- } else props[key] = evaluate({
391
- code: bindings[key],
392
- state,
393
- context: {}
394
- });
395
- }
396
- return props;
397
- }
398
-
399
388
  function getBlockComponentOptions(block) {
400
389
  return {
401
390
  ...block.component?.options,
@@ -406,10 +395,15 @@ function getBlockComponentOptions(block) {
406
395
  };
407
396
  }
408
397
 
398
+ function transformBlockProperties(properties) {
399
+ return properties;
400
+ }
401
+
409
402
  function getBlockProperties(block) {
410
- return {
403
+ const properties = {
411
404
  ...block.properties,
412
405
  'builder-id': block.id,
406
+ style: getStyleAttribute(block.style),
413
407
  class: [
414
408
  block.id,
415
409
  'builder-block',
@@ -417,6 +411,25 @@ function getBlockProperties(block) {
417
411
  block.properties?.class
418
412
  ].filter(Boolean).join(' ')
419
413
  };
414
+ return transformBlockProperties(properties);
415
+ }
416
+ /**
417
+ * Svelte does not support style attribute as an object so we need to flatten it.
418
+ *
419
+ * Additionally, Svelte, Vue and other frameworks use kebab-case styles, so we need to convert them.
420
+ */ function getStyleAttribute(style) {
421
+ if (!style) return undefined;
422
+ switch(TARGET){
423
+ case 'svelte':
424
+ case 'vue2':
425
+ case 'vue3':
426
+ case 'solid':
427
+ return convertStyleMapToCSSArray(style).join(' ');
428
+ case 'qwik':
429
+ case 'reactNative':
430
+ case 'react':
431
+ return style;
432
+ }
420
433
  }
421
434
 
422
435
  function getBlockTag(block) {
@@ -480,51 +493,6 @@ const RenderComponent = (props)=>{
480
493
  };
481
494
  const RenderComponent$1 = RenderComponent;
482
495
 
483
- // GENERATED BY MITOSIS
484
- const RenderComponentWithContext = /*#__PURE__*/ qwik.componentQrl(qwik.inlinedQrl((props)=>{
485
- qwik.useContextProvider(BuilderContext, qwik.useStore({
486
- content: (()=>{
487
- return props.context.content;
488
- })(),
489
- state: (()=>{
490
- return props.context.state;
491
- })(),
492
- context: (()=>{
493
- return props.context.context;
494
- })(),
495
- apiKey: (()=>{
496
- return props.context.apiKey;
497
- })(),
498
- registeredComponents: (()=>{
499
- return props.context.registeredComponents;
500
- })(),
501
- inheritedStyles: (()=>{
502
- return props.context.inheritedStyles;
503
- })()
504
- }));
505
- return /*#__PURE__*/ jsxRuntime.jsx(RenderComponent$1, {
506
- get componentRef () {
507
- return props.componentRef;
508
- },
509
- get componentOptions () {
510
- return props.componentOptions;
511
- },
512
- get blockChildren () {
513
- return props.blockChildren;
514
- },
515
- get context () {
516
- return props.context;
517
- },
518
- [qwik._IMMUTABLE]: {
519
- componentRef: qwik._wrapSignal(props, "componentRef"),
520
- componentOptions: qwik._wrapSignal(props, "componentOptions"),
521
- blockChildren: qwik._wrapSignal(props, "blockChildren"),
522
- context: qwik._wrapSignal(props, "context")
523
- }
524
- });
525
- }, "RenderComponentWithContext_component_nXOUbUnjTAo"));
526
- const RenderComponentWithContext$1 = RenderComponentWithContext;
527
-
528
496
  // GENERATED BY MITOSIS
529
497
  /**
530
498
  * We can't make this a generic `ProvideContext` function because Vue 2 won't support root slots, e.g.
@@ -599,15 +567,17 @@ const useBlock = function useBlock(props, state) {
599
567
  shouldEvaluateBindings: true
600
568
  });
601
569
  };
570
+ const actions = function actions(props, state) {
571
+ return getBlockActions({
572
+ block: useBlock(props),
573
+ state: props.context.state,
574
+ context: props.context.context
575
+ });
576
+ };
602
577
  const attributes = function attributes(props, state) {
578
+ const blockProperties = getBlockProperties(useBlock(props));
603
579
  return {
604
- ...getBlockProperties(useBlock(props)),
605
- ...getBlockBindings(props.context.state, useBlock(props)),
606
- ...getBlockActions({
607
- block: useBlock(props),
608
- state: props.context.state,
609
- context: props.context.context
610
- }),
580
+ ...blockProperties,
611
581
  ...{}
612
582
  };
613
583
  };
@@ -624,8 +594,12 @@ const renderComponentProps = function renderComponentProps(props, state) {
624
594
  * These attributes are passed to the wrapper element when there is one. If `noWrap` is set to true, then
625
595
  * they are provided to the component itself directly.
626
596
  */ ...shouldWrap(props) ? {} : {
627
- attributes: attributes(props)
628
- }
597
+ attributes: {
598
+ ...attributes(props),
599
+ ...actions(props)
600
+ }
601
+ },
602
+ customBreakpoints: childrenContext(props)?.content?.meta?.breakpoints
629
603
  },
630
604
  context: childrenContext(props)
631
605
  };
@@ -689,8 +663,7 @@ const childrenContext = function childrenContext(props, state) {
689
663
  };
690
664
  };
691
665
  const renderComponentTag = function renderComponentTag(props, state) {
692
- if (TARGET === "reactNative") return RenderComponentWithContext$1;
693
- else return RenderComponent$1;
666
+ return RenderComponent$1;
694
667
  };
695
668
  const RenderBlock = (props)=>{
696
669
  const state = {};
@@ -700,7 +673,8 @@ const RenderBlock = (props)=>{
700
673
  children: shouldWrap(props) ? /*#__PURE__*/ jsxRuntime.jsxs(jsxRuntime.Fragment, {
701
674
  children: [
702
675
  isEmptyHtmlElement(tag(props)) ? /*#__PURE__*/ jsxRuntime.jsx(state.tag, {
703
- ...attributes(props)
676
+ ...attributes(props),
677
+ ...actions(props)
704
678
  }) : null,
705
679
  !isEmptyHtmlElement(tag(props)) && repeatItemData(props) ? (repeatItemData(props) || []).map(function(data, index) {
706
680
  return /*#__PURE__*/ jsxRuntime.jsx(RenderRepeatedBlock$1, {
@@ -718,6 +692,7 @@ const RenderBlock = (props)=>{
718
692
  }) : null,
719
693
  !isEmptyHtmlElement(tag(props)) && !repeatItemData(props) ? /*#__PURE__*/ jsxRuntime.jsxs(state.tag, {
720
694
  ...attributes(props),
695
+ ...actions(props),
721
696
  children: [
722
697
  /*#__PURE__*/ jsxRuntime.jsx(state.renderComponentTag, {
723
698
  ...renderComponentProps(props)
@@ -745,7 +720,7 @@ const RenderBlock = (props)=>{
745
720
  const RenderBlock$1 = RenderBlock;
746
721
 
747
722
  // GENERATED BY MITOSIS
748
- const className = function className(props, state, builderContext) {
723
+ const className$1 = function className(props, state, builderContext) {
749
724
  return "builder-blocks" + (!props.blocks?.length ? " no-blocks" : "");
750
725
  };
751
726
  const onClick$1 = function onClick(props, state, builderContext) {
@@ -771,7 +746,7 @@ const RenderBlocks = /*#__PURE__*/ qwik.componentQrl(qwik.inlinedQrl((props)=>{
771
746
  const builderContext = qwik.useContext(BuilderContext);
772
747
  const state = {};
773
748
  return /*#__PURE__*/ jsxRuntime.jsxs("div", {
774
- class: className(props) + " div-RenderBlocks",
749
+ class: className$1(props) + " div-RenderBlocks",
775
750
  get "builder-path" () {
776
751
  return props.path;
777
752
  },
@@ -862,54 +837,113 @@ const columnCssVars = function columnCssVars(props, state) {
862
837
  "--column-margin-left-tablet": maybeApplyForTablet(props, state, marginLeft)
863
838
  };
864
839
  };
840
+ const getWidthForBreakpointSize = function getWidthForBreakpointSize(props, state, size) {
841
+ const breakpointSizes = getSizesForBreakpoints(props.customBreakpoints || {});
842
+ return breakpointSizes[size].max;
843
+ };
844
+ const columnStyleObjects = function columnStyleObjects(props, state) {
845
+ return {
846
+ columns: {
847
+ small: {
848
+ flexDirection: "var(--flex-dir)",
849
+ alignItems: "stretch"
850
+ },
851
+ medium: {
852
+ flexDirection: "var(--flex-dir-tablet)",
853
+ alignItems: "stretch"
854
+ }
855
+ },
856
+ column: {
857
+ small: {
858
+ width: "var(--column-width) !important",
859
+ marginLeft: "var(--column-margin-left) !important"
860
+ },
861
+ medium: {
862
+ width: "var(--column-width-tablet) !important",
863
+ marginLeft: "var(--column-margin-left-tablet) !important"
864
+ }
865
+ }
866
+ };
867
+ };
868
+ const columnsStyles = function columnsStyles(props, state) {
869
+ return `
870
+ @media (max-width: ${getWidthForBreakpointSize(props, state, "medium")}px) {
871
+ .${props.builderBlock.id}-breakpoints {
872
+ ${convertStyleMapToCSS(columnStyleObjects().columns.medium)}
873
+ }
874
+
875
+ .${props.builderBlock.id}-breakpoints > .builder-column {
876
+ ${convertStyleMapToCSS(columnStyleObjects().column.medium)}
877
+ }
878
+ }
879
+
880
+ @media (max-width: ${getWidthForBreakpointSize(props, state, "small")}px) {
881
+ .${props.builderBlock.id}-breakpoints {
882
+ ${convertStyleMapToCSS(columnStyleObjects().columns.small)}
883
+ }
884
+
885
+ .${props.builderBlock.id}-breakpoints > .builder-column {
886
+ ${convertStyleMapToCSS(columnStyleObjects().column.small)}
887
+ }
888
+ },
889
+ `;
890
+ };
891
+ const reactNativeColumnsStyles = function reactNativeColumnsStyles(props, state) {
892
+ return columnStyleObjects().columns.small;
893
+ };
894
+ const reactNativeColumnStyles = function reactNativeColumnStyles(props, state) {
895
+ return columnStyleObjects().column.small;
896
+ };
865
897
  const Columns = /*#__PURE__*/ qwik.componentQrl(qwik.inlinedQrl((props)=>{
866
898
  qwik.useStylesScopedQrl(qwik.inlinedQrl(STYLES$2, "Columns_component_useStylesScoped_s7JLZz7MCCQ"));
867
899
  const state = {};
868
- return /*#__PURE__*/ jsxRuntime.jsx("div", {
869
- class: "builder-columns div-Columns",
870
- style: columnsCssVars(props, state),
871
- children: (props.columns || []).map(function(column, index) {
872
- return /*#__PURE__*/ jsxRuntime.jsx("div", {
873
- class: "builder-column div-Columns-2",
874
- style: {
875
- width: getColumnCssWidth(props, state, index),
876
- marginLeft: `${index === 0 ? 0 : getGutterSize(props)}px`,
877
- ...columnCssVars(props, state)
878
- },
879
- children: /*#__PURE__*/ jsxRuntime.jsx(RenderBlocks$1, {
880
- get blocks () {
881
- return column.blocks;
882
- },
883
- path: `component.options.columns.${index}.blocks`,
884
- get parent () {
885
- return props.builderBlock.id;
886
- },
887
- styleProp: {
888
- flexGrow: "1"
900
+ return /*#__PURE__*/ jsxRuntime.jsxs("div", {
901
+ class: `builder-columns ${props.builderBlock.id}-breakpoints` + " div-Columns",
902
+ style: {
903
+ ...TARGET === "reactNative" ? reactNativeColumnsStyles() : {},
904
+ ...columnsCssVars(props, state)
905
+ },
906
+ children: [
907
+ TARGET !== "reactNative" ? /*#__PURE__*/ jsxRuntime.jsx(RenderInlinedStyles$1, {
908
+ styles: columnsStyles(props, state)
909
+ }) : null,
910
+ (props.columns || []).map(function(column, index) {
911
+ return /*#__PURE__*/ jsxRuntime.jsx("div", {
912
+ class: "builder-column div-Columns-2",
913
+ style: {
914
+ width: getColumnCssWidth(props, state, index),
915
+ marginLeft: `${index === 0 ? 0 : getGutterSize(props)}px`,
916
+ ...TARGET === "reactNative" ? reactNativeColumnStyles() : {},
917
+ ...columnCssVars(props, state)
889
918
  },
890
- [qwik._IMMUTABLE]: {
891
- blocks: qwik._wrapSignal(column, "blocks"),
892
- parent: qwik._wrapSignal(props.builderBlock, "id")
893
- }
894
- })
895
- }, index);
896
- })
919
+ children: /*#__PURE__*/ jsxRuntime.jsx(RenderBlocks$1, {
920
+ get blocks () {
921
+ return column.blocks;
922
+ },
923
+ path: `component.options.columns.${index}.blocks`,
924
+ get parent () {
925
+ return props.builderBlock.id;
926
+ },
927
+ styleProp: {
928
+ flexGrow: "1"
929
+ },
930
+ [qwik._IMMUTABLE]: {
931
+ blocks: qwik._wrapSignal(column, "blocks"),
932
+ parent: qwik._wrapSignal(props.builderBlock, "id")
933
+ }
934
+ })
935
+ }, index);
936
+ })
937
+ ]
897
938
  });
898
939
  }, "Columns_component_7yLj4bxdI6c"));
899
940
  const Columns$1 = Columns;
900
941
  const STYLES$2 = `.div-Columns {
901
942
  display: flex;
902
- align-items: stretch;
903
- line-height: normal; }@media (max-width: 991px) { .div-Columns {
904
- flex-direction: var(--flex-dir-tablet); } }@media (max-width: 639px) { .div-Columns {
905
- flex-direction: var(--flex-dir); } }.div-Columns-2 {
943
+ line-height: normal; }.div-Columns-2 {
906
944
  display: flex;
907
945
  flex-direction: column;
908
- align-items: stretch; }@media (max-width: 991px) { .div-Columns-2 {
909
- width: var(--column-width-tablet) !important;
910
- margin-left: var(--column-margin-left-tablet) !important; } }@media (max-width: 639px) { .div-Columns-2 {
911
- width: var(--column-width) !important;
912
- margin-left: var(--column-margin-left) !important; } }`;
946
+ align-items: stretch; }`;
913
947
 
914
948
  // Taken from (and modified) the shopify theme script repo
915
949
  // https://github.com/Shopify/theme-scripts/blob/bcfb471f2a57d439e2f964a1bb65b67708cc90c3/packages/theme-images/images.js#L59
@@ -981,6 +1015,17 @@ const webpSrcSet = function webpSrcSet(props, state) {
981
1015
  if (srcSetToUse(props)?.match(/builder\.io/) && !props.noWebp) return srcSetToUse(props).replace(/\?/g, "?format=webp&");
982
1016
  else return "";
983
1017
  };
1018
+ const aspectRatioCss = function aspectRatioCss(props, state) {
1019
+ const aspectRatioStyles = {
1020
+ position: "absolute",
1021
+ height: "100%",
1022
+ width: "100%",
1023
+ left: "0px",
1024
+ top: "0px"
1025
+ };
1026
+ const out = props.aspectRatio ? aspectRatioStyles : undefined;
1027
+ return out;
1028
+ };
984
1029
  const Image = /*#__PURE__*/ qwik.componentQrl(qwik.inlinedQrl((props)=>{
985
1030
  qwik.useStylesScopedQrl(qwik.inlinedQrl(STYLES$1, "Image_component_useStylesScoped_fBMYiVf9fuU"));
986
1031
  return /*#__PURE__*/ jsxRuntime.jsxs(qwik.Fragment, {
@@ -998,8 +1043,9 @@ const Image = /*#__PURE__*/ qwik.componentQrl(qwik.inlinedQrl((props)=>{
998
1043
  },
999
1044
  role: props.altText ? "presentation" : undefined,
1000
1045
  style: {
1001
- objectPosition: props.backgroundSize || "center",
1002
- objectFit: props.backgroundSize || "cover"
1046
+ objectPosition: props.backgroundPosition || "center",
1047
+ objectFit: props.backgroundSize || "cover",
1048
+ ...aspectRatioCss(props)
1003
1049
  },
1004
1050
  class: "builder-image" + (props.className ? " " + props.className : "") + " img-Image",
1005
1051
  get src () {
@@ -1023,8 +1069,8 @@ const Image = /*#__PURE__*/ qwik.componentQrl(qwik.inlinedQrl((props)=>{
1023
1069
  props.aspectRatio && !(props.builderBlock?.children?.length && props.fitContent) ? /*#__PURE__*/ jsxRuntime.jsx("div", {
1024
1070
  class: "builder-image-sizer div-Image",
1025
1071
  style: {
1026
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
1027
- paddingTop: props.aspectRatio * 100 + "%"
1072
+ paddingTop: // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
1073
+ props.aspectRatio * 100 + "%"
1028
1074
  }
1029
1075
  }) : null,
1030
1076
  props.builderBlock?.children?.length && props.fitContent ? /*#__PURE__*/ jsxRuntime.jsx(qwik.Slot, {}) : null,
@@ -1038,12 +1084,7 @@ const Image = /*#__PURE__*/ qwik.componentQrl(qwik.inlinedQrl((props)=>{
1038
1084
  const Image$1 = Image;
1039
1085
  const STYLES$1 = `.img-Image {
1040
1086
  opacity: 1;
1041
- transition: opacity 0.2s ease-in-out;
1042
- position: absolute;
1043
- height: 100%;
1044
- width: 100%;
1045
- top: 0px;
1046
- left: 0px; }.div-Image {
1087
+ transition: opacity 0.2s ease-in-out; }.div-Image {
1047
1088
  width: 100%;
1048
1089
  pointer-events: none;
1049
1090
  font-size: 0; }.div-Image-2 {
@@ -2154,6 +2195,7 @@ const componentInfo = {
2154
2195
  }
2155
2196
 
2156
2197
  const BUILDER_SEARCHPARAMS_PREFIX = 'builder.';
2198
+ const BUILDER_OPTIONS_PREFIX = 'options.';
2157
2199
  const convertSearchParamsToQueryObject = (searchParams)=>{
2158
2200
  const options = {};
2159
2201
  searchParams.forEach((value, key)=>{
@@ -2167,7 +2209,7 @@ const getBuilderSearchParams = (_options)=>{
2167
2209
  const newOptions = {};
2168
2210
  Object.keys(options).forEach((key)=>{
2169
2211
  if (key.startsWith(BUILDER_SEARCHPARAMS_PREFIX)) {
2170
- const trimmedKey = key.replace(BUILDER_SEARCHPARAMS_PREFIX, '');
2212
+ const trimmedKey = key.replace(BUILDER_SEARCHPARAMS_PREFIX, '').replace(BUILDER_OPTIONS_PREFIX, '');
2171
2213
  newOptions[trimmedKey] = options[key];
2172
2214
  }
2173
2215
  });
@@ -2289,8 +2331,6 @@ const setContentVariationCookie = ({ contentId , canTrack , value })=>setCookie
2289
2331
  canTrack
2290
2332
  });
2291
2333
 
2292
- const checkIsDefined = (maybeT)=>maybeT !== null && maybeT !== undefined;
2293
-
2294
2334
  const checkIsBuilderContentWithVariations = (item)=>checkIsDefined(item.id) && checkIsDefined(item.variations) && Object.keys(item.variations).length > 0;
2295
2335
  /**
2296
2336
  * Randomly assign a variation to this user and store it in cookies/storage
@@ -2368,9 +2408,9 @@ async function getContent(options) {
2368
2408
  })).results[0] || null;
2369
2409
  }
2370
2410
  const generateContentUrl = (options)=>{
2371
- const { limit =30 , userAttributes , query , noTraverse =false , model , apiKey , includeRefs =true , } = options;
2411
+ const { limit =30 , userAttributes , query , noTraverse =false , model , apiKey , includeRefs =true , locale , } = options;
2372
2412
  if (!apiKey) throw new Error('Missing API key');
2373
- const url = new URL(`https://cdn.builder.io/api/v2/content/${model}?apiKey=${apiKey}&limit=${limit}&noTraverse=${noTraverse}&includeRefs=${includeRefs}`);
2413
+ const url = new URL(`https://cdn.builder.io/api/v2/content/${model}?apiKey=${apiKey}&limit=${limit}&noTraverse=${noTraverse}&includeRefs=${includeRefs}${locale ? `&locale=${locale}` : ''}`);
2374
2414
  const queryOptions = {
2375
2415
  ...getBuilderSearchParamsFromWindow(),
2376
2416
  ...normalizeSearchParams(options.options || {})
@@ -2391,7 +2431,8 @@ async function getAllContent(options) {
2391
2431
  const fetch = await getFetch();
2392
2432
  const content = await fetch(url.href).then((res)=>res.json());
2393
2433
  const canTrack = options.canTrack !== false;
2394
- if (canTrack) for (const item of content.results)await handleABTesting({
2434
+ if (canTrack && // This makes sure we have a non-error response with the results array.
2435
+ Array.isArray(content.results)) for (const item of content.results)await handleABTesting({
2395
2436
  item,
2396
2437
  canTrack
2397
2438
  });
@@ -2535,6 +2576,10 @@ const createEvent = async ({ type: eventType , canTrack , apiKey , metadata , ..
2535
2576
  }
2536
2577
  });
2537
2578
  async function _track(eventProps) {
2579
+ if (!eventProps.apiKey) {
2580
+ console.error('[Builder.io]: Missing API key for track call. Please provide your API key.');
2581
+ return;
2582
+ }
2538
2583
  if (!eventProps.canTrack) return;
2539
2584
  if (isEditing()) return;
2540
2585
  if (!(isBrowser() || TARGET === 'reactNative')) return;
@@ -2576,7 +2621,7 @@ const getCssFromFont = function getCssFromFont(props, state, font) {
2576
2621
  if (font.files) for(const weight in font.files){
2577
2622
  const isNumber = String(Number(weight)) === weight;
2578
2623
  if (!isNumber) continue;
2579
- // TODO: maybe limit number loaded
2624
+ // TODO: maybe limit number loaded
2580
2625
  const weightUrl = font.files[weight];
2581
2626
  if (weightUrl && weightUrl !== url) str += `
2582
2627
  @font-face {
@@ -2622,6 +2667,11 @@ const useContent = function useContent(props, state, elementRef) {
2622
2667
  ...props.content?.data,
2623
2668
  ...props.data,
2624
2669
  ...state.overrideContent?.data
2670
+ },
2671
+ meta: {
2672
+ ...props.content?.meta,
2673
+ ...state.overrideContent?.meta,
2674
+ breakpoints: state.useBreakpoints || state.overrideContent?.meta?.breakpoints || props.content?.meta?.breakpoints
2625
2675
  }
2626
2676
  };
2627
2677
  return mergedContent;
@@ -2633,6 +2683,9 @@ const contentState = function contentState(props, state, elementRef) {
2633
2683
  return {
2634
2684
  ...props.content?.data?.state,
2635
2685
  ...props.data,
2686
+ ...props.locale ? {
2687
+ locale: props.locale
2688
+ } : {},
2636
2689
  ...state.overrideState
2637
2690
  };
2638
2691
  };
@@ -2642,6 +2695,7 @@ const contextContext = function contextContext(props, state, elementRef) {
2642
2695
  const allRegisteredComponents = function allRegisteredComponents(props, state, elementRef) {
2643
2696
  const allComponentsArray = [
2644
2697
  ...getDefaultRegisteredComponents(),
2698
+ // While this `components` object is deprecated, we must maintain support for it.
2645
2699
  // Since users are able to override our default components, we need to make sure that we do not break such
2646
2700
  // existing usage.
2647
2701
  // This is why we spread `components` after the default Builder.io components, but before the `props.customComponents`,
@@ -2658,11 +2712,20 @@ const allRegisteredComponents = function allRegisteredComponents(props, state, e
2658
2712
  const processMessage = function processMessage(props, state, elementRef, event) {
2659
2713
  const { data } = event;
2660
2714
  if (data) switch(data.type){
2661
- case "builder.contentUpdate":
2715
+ case "builder.configureSdk":
2662
2716
  {
2663
2717
  const messageContent = data.data;
2664
- const key = messageContent.key || messageContent.alias || messageContent.entry || messageContent.modelName;
2665
- const contentData = messageContent.data;
2718
+ const { breakpoints , contentId } = messageContent;
2719
+ if (!contentId || contentId !== useContent(props, state)?.id) return;
2720
+ state.useBreakpoints = breakpoints;
2721
+ state.forceReRenderCount = state.forceReRenderCount + 1; // This is a hack to force Qwik to re-render.
2722
+ break;
2723
+ }
2724
+ case "builder.contentUpdate":
2725
+ {
2726
+ const messageContent1 = data.data;
2727
+ const key = messageContent1.key || messageContent1.alias || messageContent1.entry || messageContent1.modelName;
2728
+ const contentData = messageContent1.data;
2666
2729
  if (key === props.model) {
2667
2730
  state.overrideContent = contentData;
2668
2731
  state.forceReRenderCount = state.forceReRenderCount + 1; // This is a hack to force Qwik to re-render.
@@ -2745,7 +2808,8 @@ const RenderContent = /*#__PURE__*/ qwik.componentQrl(qwik.inlinedQrl((props)=>{
2745
2808
  forceReRenderCount: 0,
2746
2809
  overrideContent: null,
2747
2810
  overrideState: {},
2748
- update: 0
2811
+ update: 0,
2812
+ useBreakpoints: null
2749
2813
  });
2750
2814
  qwik.useContextProvider(BuilderContext, qwik.useStore({
2751
2815
  content: (()=>{
@@ -2766,11 +2830,19 @@ const RenderContent = /*#__PURE__*/ qwik.componentQrl(qwik.inlinedQrl((props)=>{
2766
2830
  }));
2767
2831
  qwik.useClientEffectQrl(qwik.inlinedQrl(()=>{
2768
2832
  const [elementRef, props, state] = qwik.useLexicalScope();
2833
+ 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.");
2769
2834
  if (isBrowser()) {
2770
2835
  if (isEditing()) {
2771
2836
  state.forceReRenderCount = state.forceReRenderCount + 1;
2772
2837
  registerInsertMenu();
2773
- setupBrowserForEditing();
2838
+ setupBrowserForEditing({
2839
+ ...props.locale ? {
2840
+ locale: props.locale
2841
+ } : {},
2842
+ ...props.includeRefs ? {
2843
+ includeRefs: props.includeRefs
2844
+ } : {}
2845
+ });
2774
2846
  Object.values(allRegisteredComponents(props)).forEach((registeredComponent)=>{
2775
2847
  const message = createRegisterComponentMessage(registeredComponent);
2776
2848
  window.parent?.postMessage(message, "*");
@@ -2788,7 +2860,8 @@ const RenderContent = /*#__PURE__*/ qwik.componentQrl(qwik.inlinedQrl((props)=>{
2788
2860
  apiKey: props.apiKey,
2789
2861
  variationId: variationId !== contentId ? variationId : undefined
2790
2862
  });
2791
- } // override normal content in preview mode
2863
+ }
2864
+ // override normal content in preview mode
2792
2865
  if (isPreviewing()) {
2793
2866
  const searchParams = new URL(location.href).searchParams;
2794
2867
  if (props.model && searchParams.get("builder.preview") === props.model) {
@@ -2813,6 +2886,7 @@ const RenderContent = /*#__PURE__*/ qwik.componentQrl(qwik.inlinedQrl((props)=>{
2813
2886
  qwik.useWatchQrl(qwik.inlinedQrl(({ track })=>{
2814
2887
  const [elementRef, props, state] = qwik.useLexicalScope();
2815
2888
  state.useContent?.data && track(state.useContent?.data, "jsCode");
2889
+ state && track(state, "contentState");
2816
2890
  evaluateJsCode(props, state);
2817
2891
  }, "RenderContent_component_useWatch_OIBatobA0hE", [
2818
2892
  elementRef,
@@ -2881,13 +2955,22 @@ const RenderContent = /*#__PURE__*/ qwik.componentQrl(qwik.inlinedQrl((props)=>{
2881
2955
  const RenderContent$1 = RenderContent;
2882
2956
 
2883
2957
  // GENERATED BY MITOSIS
2958
+ const className = function className(props, state, builderContext) {
2959
+ return [
2960
+ ...[
2961
+ props.attributes.class
2962
+ ],
2963
+ "builder-symbol",
2964
+ props.symbol?.inline ? "builder-inline-symbol" : undefined,
2965
+ props.symbol?.dynamic || props.dynamic ? "builder-dynamic-symbol" : undefined
2966
+ ].filter(Boolean).join(" ");
2967
+ };
2884
2968
  const contentToUse = function contentToUse(props, state, builderContext) {
2885
2969
  return props.symbol?.content || state.fetchedContent;
2886
2970
  };
2887
2971
  const Symbol$1 = /*#__PURE__*/ qwik.componentQrl(qwik.inlinedQrl((props)=>{
2888
2972
  const builderContext = qwik.useContext(BuilderContext);
2889
2973
  const state = qwik.useStore({
2890
- className: "builder-symbol",
2891
2974
  fetchedContent: null
2892
2975
  });
2893
2976
  qwik.useWatchQrl(qwik.inlinedQrl(({ track })=>{
@@ -2919,9 +3002,7 @@ const Symbol$1 = /*#__PURE__*/ qwik.componentQrl(qwik.inlinedQrl((props)=>{
2919
3002
  ]));
2920
3003
  return /*#__PURE__*/ jsxRuntime.jsx("div", {
2921
3004
  ...props.attributes,
2922
- get class () {
2923
- return state.className;
2924
- },
3005
+ class: className(props),
2925
3006
  children: /*#__PURE__*/ jsxRuntime.jsx(RenderContent$1, {
2926
3007
  get apiKey () {
2927
3008
  return builderContext.apiKey;
@@ -2941,10 +3022,7 @@ const Symbol$1 = /*#__PURE__*/ qwik.componentQrl(qwik.inlinedQrl((props)=>{
2941
3022
  apiKey: qwik._wrapSignal(builderContext, "apiKey"),
2942
3023
  context: qwik._wrapSignal(builderContext, "context")
2943
3024
  }
2944
- }),
2945
- [qwik._IMMUTABLE]: {
2946
- class: qwik._wrapSignal(state, "className")
2947
- }
3025
+ })
2948
3026
  });
2949
3027
  }, "Symbol_component_WVvggdkUPdk"));
2950
3028
  const Symbol$2 = Symbol$1;