@builder.io/sdk-solid 3.0.6 → 4.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -39,7 +39,6 @@ interface BuilderBlock {
39
39
  large?: Partial<CSSStyleDeclaration>;
40
40
  medium?: Partial<CSSStyleDeclaration>;
41
41
  small?: Partial<CSSStyleDeclaration>;
42
- /** @deprecated */
43
42
  xsmall?: Partial<CSSStyleDeclaration>;
44
43
  };
45
44
  component?: {
@@ -243,6 +242,7 @@ type Dictionary<T> = {
243
242
  };
244
243
 
245
244
  interface Breakpoints {
245
+ xsmall?: number;
246
246
  small: number;
247
247
  medium: number;
248
248
  }
@@ -683,11 +683,11 @@ interface ContentVariantsPrps extends ExtraFrameworkProps {
683
683
  /**
684
684
  * The Builder content JSON to render (required).
685
685
  */
686
- content?: Nullable<BuilderContent>;
686
+ content: Nullable<BuilderContent>;
687
687
  /**
688
688
  * The Builder content `model` to render (required).
689
689
  */
690
- model?: string;
690
+ model: string;
691
691
  /**
692
692
  * Additional data to inject into your Builder content (optional).
693
693
  */
@@ -876,19 +876,19 @@ type EventProperties = Pick<Event, 'type'> & Pick<Event['data'], 'contentId' | '
876
876
  };
877
877
  declare const track: (args: EventProperties) => Promise<void | Response>;
878
878
 
879
- type SubscribeToEditor = (
880
- /**
881
- * The Builder `model` to subscribe to
882
- */
883
- model: string,
884
- /**
885
- * The callback function to call when the content is updated.
886
- */
887
- callback: (updatedContent: BuilderContent) => void,
888
- /**
889
- * Extra options for the listener.
890
- */
891
- options?: {
879
+ type SubscribeToEditor = ({ model, apiKey, callback, trustedHosts }: {
880
+ /**
881
+ * The Builder `model` to subscribe to
882
+ */
883
+ model: string;
884
+ /**
885
+ * Builder API Key to use for the editor.
886
+ */
887
+ apiKey: string;
888
+ /**
889
+ * The callback function to call when the content is updated.
890
+ */
891
+ callback: (updatedContent: BuilderContent) => void;
892
892
  /**
893
893
  * List of hosts to allow editing content from.
894
894
  */
@@ -1,4 +1,4 @@
1
- import { delegateEvents, createComponent, spread, mergeProps, insert, effect, setAttribute, className, style, template, Dynamic, memo, use } from 'solid-js/web';
1
+ import { delegateEvents, createComponent, spread, mergeProps, insert, effect, setAttribute, className, style, template, use, Dynamic, memo } from 'solid-js/web';
2
2
  import { createContext, useContext, Show, For, createMemo, createSignal, onMount, createEffect, on } from 'solid-js';
3
3
 
4
4
  // src/blocks/button/button.tsx
@@ -939,8 +939,13 @@ var provideBuilderContext = (block, context) => {
939
939
 
940
940
  // src/constants/device-sizes.ts
941
941
  var SIZES = {
942
+ xsmall: {
943
+ min: 0,
944
+ default: 160,
945
+ max: 320
946
+ },
942
947
  small: {
943
- min: 320,
948
+ min: 321,
944
949
  default: 321,
945
950
  max: 640
946
951
  },
@@ -956,15 +961,28 @@ var SIZES = {
956
961
  }
957
962
  };
958
963
  var getMaxWidthQueryForSize = (size, sizeValues = SIZES) => `@media (max-width: ${sizeValues[size].max}px)`;
959
- var getSizesForBreakpoints = ({
960
- small,
961
- medium
962
- }) => {
964
+ var getSizesForBreakpoints = (breakpoints) => {
963
965
  const newSizes = fastClone(SIZES);
966
+ if (!breakpoints) {
967
+ return newSizes;
968
+ }
969
+ const {
970
+ xsmall,
971
+ small,
972
+ medium
973
+ } = breakpoints;
974
+ if (xsmall) {
975
+ const xsmallMin = Math.floor(xsmall / 2);
976
+ newSizes.xsmall = {
977
+ max: xsmall,
978
+ min: xsmallMin,
979
+ default: xsmallMin + 1
980
+ };
981
+ }
964
982
  if (!small || !medium) {
965
983
  return newSizes;
966
984
  }
967
- const smallMin = Math.floor(small / 2);
985
+ const smallMin = xsmall ? newSizes.xsmall.max + 1 : Math.floor(small / 2);
968
986
  newSizes.small = {
969
987
  max: small,
970
988
  min: smallMin,
@@ -1022,9 +1040,11 @@ function BlockStyles(props) {
1022
1040
  const styles = processedBlock.responsiveStyles;
1023
1041
  const content = props.context.content;
1024
1042
  const sizesWithUpdatedBreakpoints = getSizesForBreakpoints(content?.meta?.breakpoints || {});
1043
+ const contentHasXSmallBreakpoint = Boolean(content?.meta?.breakpoints?.xsmall);
1025
1044
  const largeStyles = styles?.large;
1026
1045
  const mediumStyles = styles?.medium;
1027
1046
  const smallStyles = styles?.small;
1047
+ const xsmallStyles = styles?.xsmall;
1028
1048
  const className = processedBlock.id;
1029
1049
  if (!className) {
1030
1050
  return "";
@@ -1043,6 +1063,11 @@ function BlockStyles(props) {
1043
1063
  styles: smallStyles,
1044
1064
  mediaQuery: getMaxWidthQueryForSize("small", sizesWithUpdatedBreakpoints)
1045
1065
  }) : "";
1066
+ const xsmallStylesClass = xsmallStyles && contentHasXSmallBreakpoint ? createCssClass({
1067
+ className,
1068
+ styles: xsmallStyles,
1069
+ mediaQuery: getMaxWidthQueryForSize("xsmall", sizesWithUpdatedBreakpoints)
1070
+ }) : "";
1046
1071
  const hoverAnimation = processedBlock.animations && processedBlock.animations.find((item) => item.trigger === "hover");
1047
1072
  let hoverStylesClass = "";
1048
1073
  if (hoverAnimation) {
@@ -1056,7 +1081,7 @@ function BlockStyles(props) {
1056
1081
  }
1057
1082
  }) || "";
1058
1083
  }
1059
- return [largeStylesClass, mediumStylesClass, smallStylesClass, hoverStylesClass].join(" ");
1084
+ return [largeStylesClass, mediumStylesClass, smallStylesClass, xsmallStylesClass, hoverStylesClass].join(" ");
1060
1085
  });
1061
1086
  return createComponent(Show, {
1062
1087
  get when() {
@@ -5028,10 +5053,10 @@ var componentInfo20 = {
5028
5053
  builderBlock: true
5029
5054
  }
5030
5055
  };
5031
- var _tmpl$21 = /* @__PURE__ */ template(`<source type=video/mp4>`);
5032
- var _tmpl$29 = /* @__PURE__ */ template(`<div>`);
5033
- var _tmpl$35 = /* @__PURE__ */ template(`<div><video class=builder-video>`);
5056
+ var _tmpl$21 = /* @__PURE__ */ template(`<div>`);
5057
+ var _tmpl$29 = /* @__PURE__ */ template(`<div><video class=builder-video><source type=video/mp4>`);
5034
5058
  function Video(props) {
5059
+ const [lazyVideoObserver, setLazyVideoObserver] = createSignal(void 0);
5035
5060
  const videoProps = createMemo(() => {
5036
5061
  return {
5037
5062
  ...props.autoPlay === true ? {
@@ -5056,12 +5081,42 @@ function Video(props) {
5056
5081
  ...videoProps()
5057
5082
  };
5058
5083
  });
5084
+ let videoRef;
5085
+ onMount(() => {
5086
+ if (props.lazyLoad) {
5087
+ const oberver = new IntersectionObserver(function(entries) {
5088
+ entries.forEach(function(entry) {
5089
+ if (!entry.isIntersecting)
5090
+ return;
5091
+ const videoElement = entry.target;
5092
+ try {
5093
+ Array.from(videoElement.children).filter((child) => child instanceof HTMLElement && child.tagName === "SOURCE").forEach((source) => {
5094
+ const src = source.dataset.src;
5095
+ if (src) {
5096
+ source.src = src;
5097
+ }
5098
+ });
5099
+ videoElement.load();
5100
+ oberver.unobserve(videoElement);
5101
+ } catch (error) {
5102
+ console.error("Error loading lazy video:", error);
5103
+ }
5104
+ });
5105
+ });
5106
+ if (videoRef) {
5107
+ oberver.observe(videoRef);
5108
+ }
5109
+ setLazyVideoObserver(oberver);
5110
+ }
5111
+ });
5059
5112
  return (() => {
5060
- const _el$ = _tmpl$35(), _el$2 = _el$.firstChild;
5113
+ const _el$ = _tmpl$29(), _el$2 = _el$.firstChild, _el$3 = _el$2.firstChild;
5061
5114
  _el$.style.setProperty("position", "relative");
5115
+ const _ref$ = videoRef;
5116
+ typeof _ref$ === "function" ? use(_ref$, _el$2) : videoRef = _el$2;
5062
5117
  spread(_el$2, mergeProps(spreadProps, {
5063
5118
  get preload() {
5064
- return props.preload || "metadata";
5119
+ return props.lazyLoad ? "none" : props.preload || "metadata";
5065
5120
  },
5066
5121
  get style() {
5067
5122
  return {
@@ -5078,29 +5133,21 @@ function Video(props) {
5078
5133
  } : null
5079
5134
  };
5080
5135
  },
5081
- get src() {
5082
- return props.video || "no-src";
5083
- },
5084
5136
  get poster() {
5085
5137
  return props.posterImage;
5086
5138
  }
5087
5139
  }), false, true);
5088
- insert(_el$2, createComponent(Show, {
5089
- get when() {
5090
- return !props.lazyLoad;
5091
- },
5092
- get children() {
5093
- const _el$3 = _tmpl$21();
5094
- effect(() => setAttribute(_el$3, "src", props.video));
5095
- return _el$3;
5096
- }
5097
- }));
5140
+ spread(_el$3, mergeProps(() => props.lazyLoad ? {
5141
+ "data-src": props.video
5142
+ } : {
5143
+ src: props.video
5144
+ }), false, false);
5098
5145
  insert(_el$, createComponent(Show, {
5099
5146
  get when() {
5100
5147
  return props.aspectRatio && !(props.fitContent && props.builderBlock?.children?.length);
5101
5148
  },
5102
5149
  get children() {
5103
- const _el$4 = _tmpl$29();
5150
+ const _el$4 = _tmpl$21();
5104
5151
  _el$4.style.setProperty("width", "100%");
5105
5152
  _el$4.style.setProperty("pointer-events", "none");
5106
5153
  _el$4.style.setProperty("font-size", "0px");
@@ -5113,7 +5160,7 @@ function Video(props) {
5113
5160
  return props.builderBlock?.children?.length && props.fitContent;
5114
5161
  },
5115
5162
  get children() {
5116
- const _el$5 = _tmpl$29();
5163
+ const _el$5 = _tmpl$21();
5117
5164
  _el$5.style.setProperty("display", "flex");
5118
5165
  _el$5.style.setProperty("flex-direction", "column");
5119
5166
  _el$5.style.setProperty("align-items", "stretch");
@@ -5126,7 +5173,7 @@ function Video(props) {
5126
5173
  return props.builderBlock?.children?.length && !props.fitContent;
5127
5174
  },
5128
5175
  get children() {
5129
- const _el$6 = _tmpl$29();
5176
+ const _el$6 = _tmpl$21();
5130
5177
  _el$6.style.setProperty("pointer-events", "none");
5131
5178
  _el$6.style.setProperty("display", "flex");
5132
5179
  _el$6.style.setProperty("flex-direction", "column");
@@ -5283,7 +5330,7 @@ function getPreviewContent(_searchParams) {
5283
5330
  }
5284
5331
 
5285
5332
  // src/constants/sdk-version.ts
5286
- var SDK_VERSION = "3.0.6";
5333
+ var SDK_VERSION = "4.0.0";
5287
5334
 
5288
5335
  // src/helpers/sdk-headers.ts
5289
5336
  var getSdkHeaders = () => ({
@@ -5891,7 +5938,7 @@ var registerInsertMenu = () => {
5891
5938
  });
5892
5939
  };
5893
5940
  var isSetupForEditing = false;
5894
- var setupBrowserForEditing = (options = {}) => {
5941
+ var setupBrowserForEditing = (options) => {
5895
5942
  if (isSetupForEditing) {
5896
5943
  return;
5897
5944
  }
@@ -5907,6 +5954,9 @@ var setupBrowserForEditing = (options = {}) => {
5907
5954
  // scope our '+ add block' button styling
5908
5955
  supportsAddBlockScoping: true,
5909
5956
  supportsCustomBreakpoints: true,
5957
+ modelName: options.modelName,
5958
+ apiKey: options.apiKey,
5959
+ supportsXSmallBreakpoint: TARGET === "reactNative" ? false : true,
5910
5960
  blockLevelPersonalization: true
5911
5961
  }
5912
5962
  }, "*");
@@ -6011,13 +6061,21 @@ var createEditorListener = ({
6011
6061
  }
6012
6062
  };
6013
6063
  };
6014
- var subscribeToEditor = (model, callback, options) => {
6064
+ var subscribeToEditor = ({
6065
+ model,
6066
+ apiKey,
6067
+ callback,
6068
+ trustedHosts
6069
+ }) => {
6015
6070
  if (!isBrowser) {
6016
6071
  logger.warn("`subscribeToEditor` only works in the browser. It currently seems to be running on the server.");
6017
6072
  return () => {
6018
6073
  };
6019
6074
  }
6020
- setupBrowserForEditing();
6075
+ setupBrowserForEditing({
6076
+ modelName: model,
6077
+ apiKey
6078
+ });
6021
6079
  const listener = createEditorListener({
6022
6080
  callbacks: {
6023
6081
  contentUpdate: callback,
@@ -6027,7 +6085,7 @@ var subscribeToEditor = (model, callback, options) => {
6027
6085
  }
6028
6086
  },
6029
6087
  model,
6030
- trustedHosts: options?.trustedHosts
6088
+ trustedHosts
6031
6089
  });
6032
6090
  window.addEventListener("message", listener);
6033
6091
  return () => {
@@ -6273,10 +6331,12 @@ function EnableEditor(props) {
6273
6331
  } : {},
6274
6332
  ...props.trustedHosts ? {
6275
6333
  trustedHosts: props.trustedHosts
6276
- } : {}
6334
+ } : {},
6335
+ modelName: props.model ?? "",
6336
+ apiKey: props.apiKey
6277
6337
  });
6278
6338
  Object.values(props.builderContextSignal.componentInfos).forEach((registeredComponent) => {
6279
- if (!props.model || !registeredComponent.models?.length || registeredComponent.models.includes(props.model)) {
6339
+ if (!registeredComponent.models?.length || registeredComponent.models.includes(props.model)) {
6280
6340
  const message = createRegisterComponentMessage(registeredComponent);
6281
6341
  window.parent?.postMessage(message, "*");
6282
6342
  }
@@ -6304,7 +6364,7 @@ function EnableEditor(props) {
6304
6364
  const previewApiKey = searchParams.get("apiKey") || searchParams.get("builder.space");
6305
6365
  if (searchParamPreviewModel === "BUILDER_STUDIO" || searchParamPreviewModel === props.model && previewApiKey === props.apiKey && (!props.content || searchParamPreviewId === props.content.id)) {
6306
6366
  fetchOneEntry({
6307
- model: props.model || "",
6367
+ model: props.model,
6308
6368
  apiKey: props.apiKey,
6309
6369
  apiVersion: props.builderContextSignal.apiVersion,
6310
6370
  ...searchParamPreviewModel === "BUILDER_STUDIO" && props.context?.symbolId ? {
@@ -6498,7 +6558,7 @@ function ContentComponent(props) {
6498
6558
  BlocksWrapper: props.blocksWrapper || "div",
6499
6559
  BlocksWrapperProps: props.blocksWrapperProps || {},
6500
6560
  nonce: props.nonce || "",
6501
- model: props.model || ""
6561
+ model: props.model
6502
6562
  });
6503
6563
  function contentSetState(newRootState) {
6504
6564
  setBuilderContextSignal((PREVIOUS_VALUE) => ({
@@ -6939,7 +6999,7 @@ function Symbol(props) {
6939
6999
  return props.builderContext.canTrack;
6940
7000
  },
6941
7001
  get model() {
6942
- return props.symbol?.model;
7002
+ return props.symbol?.model ?? "";
6943
7003
  },
6944
7004
  get content() {
6945
7005
  return contentToUse();
@@ -935,8 +935,13 @@ import { Show as Show2, createMemo } from "solid-js";
935
935
 
936
936
  // src/constants/device-sizes.ts
937
937
  var SIZES = {
938
+ xsmall: {
939
+ min: 0,
940
+ default: 160,
941
+ max: 320
942
+ },
938
943
  small: {
939
- min: 320,
944
+ min: 321,
940
945
  default: 321,
941
946
  max: 640
942
947
  },
@@ -952,15 +957,28 @@ var SIZES = {
952
957
  }
953
958
  };
954
959
  var getMaxWidthQueryForSize = (size, sizeValues = SIZES) => `@media (max-width: ${sizeValues[size].max}px)`;
955
- var getSizesForBreakpoints = ({
956
- small,
957
- medium
958
- }) => {
960
+ var getSizesForBreakpoints = (breakpoints) => {
959
961
  const newSizes = fastClone(SIZES);
962
+ if (!breakpoints) {
963
+ return newSizes;
964
+ }
965
+ const {
966
+ xsmall,
967
+ small,
968
+ medium
969
+ } = breakpoints;
970
+ if (xsmall) {
971
+ const xsmallMin = Math.floor(xsmall / 2);
972
+ newSizes.xsmall = {
973
+ max: xsmall,
974
+ min: xsmallMin,
975
+ default: xsmallMin + 1
976
+ };
977
+ }
960
978
  if (!small || !medium) {
961
979
  return newSizes;
962
980
  }
963
- const smallMin = Math.floor(small / 2);
981
+ const smallMin = xsmall ? newSizes.xsmall.max + 1 : Math.floor(small / 2);
964
982
  newSizes.small = {
965
983
  max: small,
966
984
  min: smallMin,
@@ -1011,9 +1029,13 @@ function BlockStyles(props) {
1011
1029
  const sizesWithUpdatedBreakpoints = getSizesForBreakpoints(
1012
1030
  content?.meta?.breakpoints || {}
1013
1031
  );
1032
+ const contentHasXSmallBreakpoint = Boolean(
1033
+ content?.meta?.breakpoints?.xsmall
1034
+ );
1014
1035
  const largeStyles = styles?.large;
1015
1036
  const mediumStyles = styles?.medium;
1016
1037
  const smallStyles = styles?.small;
1038
+ const xsmallStyles = styles?.xsmall;
1017
1039
  const className = processedBlock.id;
1018
1040
  if (!className) {
1019
1041
  return "";
@@ -1038,6 +1060,14 @@ function BlockStyles(props) {
1038
1060
  sizesWithUpdatedBreakpoints
1039
1061
  )
1040
1062
  }) : "";
1063
+ const xsmallStylesClass = xsmallStyles && contentHasXSmallBreakpoint ? createCssClass({
1064
+ className,
1065
+ styles: xsmallStyles,
1066
+ mediaQuery: getMaxWidthQueryForSize(
1067
+ "xsmall",
1068
+ sizesWithUpdatedBreakpoints
1069
+ )
1070
+ }) : "";
1041
1071
  const hoverAnimation = processedBlock.animations && processedBlock.animations.find((item) => item.trigger === "hover");
1042
1072
  let hoverStylesClass = "";
1043
1073
  if (hoverAnimation) {
@@ -1057,6 +1087,7 @@ function BlockStyles(props) {
1057
1087
  largeStylesClass,
1058
1088
  mediumStylesClass,
1059
1089
  smallStylesClass,
1090
+ xsmallStylesClass,
1060
1091
  hoverStylesClass
1061
1092
  ].join(" ");
1062
1093
  });
@@ -1885,10 +1916,10 @@ function SectionComponent(props) {
1885
1916
  var section_default = SectionComponent;
1886
1917
 
1887
1918
  // src/blocks/symbol/symbol.tsx
1888
- import { onMount as onMount8, on as on4, createEffect as createEffect4, createMemo as createMemo20, createSignal as createSignal20 } from "solid-js";
1919
+ import { onMount as onMount9, on as on4, createEffect as createEffect4, createMemo as createMemo20, createSignal as createSignal20 } from "solid-js";
1889
1920
 
1890
1921
  // src/components/content-variants/content-variants.tsx
1891
- import { Show as Show16, For as For9, onMount as onMount7, createSignal as createSignal19, createMemo as createMemo19 } from "solid-js";
1922
+ import { Show as Show16, For as For9, onMount as onMount8, createSignal as createSignal19, createMemo as createMemo19 } from "solid-js";
1892
1923
 
1893
1924
  // src/helpers/url.ts
1894
1925
  var getTopLevelDomain = (host) => {
@@ -4534,8 +4565,9 @@ var componentInfo20 = {
4534
4565
  };
4535
4566
 
4536
4567
  // src/blocks/video/video.tsx
4537
- import { Show as Show13, createMemo as createMemo15 } from "solid-js";
4568
+ import { Show as Show13, onMount as onMount6, createSignal as createSignal15, createMemo as createMemo15 } from "solid-js";
4538
4569
  function Video(props) {
4570
+ const [lazyVideoObserver, setLazyVideoObserver] = createSignal15(void 0);
4539
4571
  const videoProps = createMemo15(() => {
4540
4572
  return {
4541
4573
  ...props.autoPlay === true ? {
@@ -4560,6 +4592,36 @@ function Video(props) {
4560
4592
  ...videoProps()
4561
4593
  };
4562
4594
  });
4595
+ let videoRef;
4596
+ onMount6(() => {
4597
+ if (props.lazyLoad) {
4598
+ const oberver = new IntersectionObserver(function(entries) {
4599
+ entries.forEach(function(entry) {
4600
+ if (!entry.isIntersecting)
4601
+ return;
4602
+ const videoElement = entry.target;
4603
+ try {
4604
+ Array.from(videoElement.children).filter(
4605
+ (child) => child instanceof HTMLElement && child.tagName === "SOURCE"
4606
+ ).forEach((source) => {
4607
+ const src = source.dataset.src;
4608
+ if (src) {
4609
+ source.src = src;
4610
+ }
4611
+ });
4612
+ videoElement.load();
4613
+ oberver.unobserve(videoElement);
4614
+ } catch (error) {
4615
+ console.error("Error loading lazy video:", error);
4616
+ }
4617
+ });
4618
+ });
4619
+ if (videoRef) {
4620
+ oberver.observe(videoRef);
4621
+ }
4622
+ setLazyVideoObserver(oberver);
4623
+ }
4624
+ });
4563
4625
  return <><div
4564
4626
  style={{
4565
4627
  position: "relative"
@@ -4568,7 +4630,8 @@ function Video(props) {
4568
4630
  <video
4569
4631
  class="builder-video"
4570
4632
  {...spreadProps()}
4571
- preload={props.preload || "metadata"}
4633
+ ref={videoRef}
4634
+ preload={props.lazyLoad ? "none" : props.preload || "metadata"}
4572
4635
  style={{
4573
4636
  width: "100%",
4574
4637
  height: "100%",
@@ -4582,9 +4645,15 @@ function Video(props) {
4582
4645
  position: "absolute"
4583
4646
  } : null
4584
4647
  }}
4585
- src={props.video || "no-src"}
4586
4648
  poster={props.posterImage}
4587
- ><Show13 when={!props.lazyLoad}><source type="video/mp4" src={props.video} /></Show13></video>
4649
+ ><source
4650
+ type="video/mp4"
4651
+ {...props.lazyLoad ? {
4652
+ "data-src": props.video
4653
+ } : {
4654
+ src: props.video
4655
+ }}
4656
+ /></video>
4588
4657
  <Show13
4589
4658
  when={props.aspectRatio && !(props.fitContent && props.builderBlock?.children?.length)}
4590
4659
  ><div
@@ -4754,7 +4823,7 @@ var getUpdateVariantVisibilityScript = ({
4754
4823
  // src/components/content/components/enable-editor.tsx
4755
4824
  import {
4756
4825
  Show as Show14,
4757
- onMount as onMount6,
4826
+ onMount as onMount7,
4758
4827
  on as on3,
4759
4828
  createEffect as createEffect3,
4760
4829
  createMemo as createMemo16,
@@ -4768,7 +4837,7 @@ function getPreviewContent(_searchParams) {
4768
4837
  }
4769
4838
 
4770
4839
  // src/constants/sdk-version.ts
4771
- var SDK_VERSION = "3.0.6";
4840
+ var SDK_VERSION = "4.0.0";
4772
4841
 
4773
4842
  // src/helpers/sdk-headers.ts
4774
4843
  var getSdkHeaders = () => ({
@@ -5376,7 +5445,7 @@ var registerInsertMenu = () => {
5376
5445
  });
5377
5446
  };
5378
5447
  var isSetupForEditing = false;
5379
- var setupBrowserForEditing = (options = {}) => {
5448
+ var setupBrowserForEditing = (options) => {
5380
5449
  if (isSetupForEditing) {
5381
5450
  return;
5382
5451
  }
@@ -5392,6 +5461,9 @@ var setupBrowserForEditing = (options = {}) => {
5392
5461
  // scope our '+ add block' button styling
5393
5462
  supportsAddBlockScoping: true,
5394
5463
  supportsCustomBreakpoints: true,
5464
+ modelName: options.modelName,
5465
+ apiKey: options.apiKey,
5466
+ supportsXSmallBreakpoint: TARGET === "reactNative" ? false : true,
5395
5467
  blockLevelPersonalization: true
5396
5468
  }
5397
5469
  }, "*");
@@ -5496,13 +5568,21 @@ var createEditorListener = ({
5496
5568
  }
5497
5569
  };
5498
5570
  };
5499
- var subscribeToEditor = (model, callback, options) => {
5571
+ var subscribeToEditor = ({
5572
+ model,
5573
+ apiKey,
5574
+ callback,
5575
+ trustedHosts
5576
+ }) => {
5500
5577
  if (!isBrowser) {
5501
5578
  logger.warn("`subscribeToEditor` only works in the browser. It currently seems to be running on the server.");
5502
5579
  return () => {
5503
5580
  };
5504
5581
  }
5505
- setupBrowserForEditing();
5582
+ setupBrowserForEditing({
5583
+ modelName: model,
5584
+ apiKey
5585
+ });
5506
5586
  const listener = createEditorListener({
5507
5587
  callbacks: {
5508
5588
  contentUpdate: callback,
@@ -5512,7 +5592,7 @@ var subscribeToEditor = (model, callback, options) => {
5512
5592
  }
5513
5593
  },
5514
5594
  model,
5515
- trustedHosts: options?.trustedHosts
5595
+ trustedHosts
5516
5596
  });
5517
5597
  window.addEventListener("message", listener);
5518
5598
  return () => {
@@ -5753,7 +5833,7 @@ function EnableEditor(props) {
5753
5833
  let elementRef;
5754
5834
  runHttpRequests();
5755
5835
  emitStateUpdate();
5756
- onMount6(() => {
5836
+ onMount7(() => {
5757
5837
  if (isBrowser()) {
5758
5838
  if (isEditing() && !props.isNestedRender) {
5759
5839
  window.addEventListener("message", processMessage);
@@ -5767,12 +5847,14 @@ function EnableEditor(props) {
5767
5847
  } : {},
5768
5848
  ...props.trustedHosts ? {
5769
5849
  trustedHosts: props.trustedHosts
5770
- } : {}
5850
+ } : {},
5851
+ modelName: props.model ?? "",
5852
+ apiKey: props.apiKey
5771
5853
  });
5772
5854
  Object.values(
5773
5855
  props.builderContextSignal.componentInfos
5774
5856
  ).forEach((registeredComponent) => {
5775
- if (!props.model || !registeredComponent.models?.length || registeredComponent.models.includes(props.model)) {
5857
+ if (!registeredComponent.models?.length || registeredComponent.models.includes(props.model)) {
5776
5858
  const message = createRegisterComponentMessage(registeredComponent);
5777
5859
  window.parent?.postMessage(message, "*");
5778
5860
  }
@@ -5805,7 +5887,7 @@ function EnableEditor(props) {
5805
5887
  const previewApiKey = searchParams.get("apiKey") || searchParams.get("builder.space");
5806
5888
  if (searchParamPreviewModel === "BUILDER_STUDIO" || searchParamPreviewModel === props.model && previewApiKey === props.apiKey && (!props.content || searchParamPreviewId === props.content.id)) {
5807
5889
  fetchOneEntry({
5808
- model: props.model || "",
5890
+ model: props.model,
5809
5891
  apiKey: props.apiKey,
5810
5892
  apiVersion: props.builderContextSignal.apiVersion,
5811
5893
  ...searchParamPreviewModel === "BUILDER_STUDIO" && props.context?.symbolId ? {
@@ -5993,7 +6075,7 @@ function ContentComponent(props) {
5993
6075
  BlocksWrapper: props.blocksWrapper || "div",
5994
6076
  BlocksWrapperProps: props.blocksWrapperProps || {},
5995
6077
  nonce: props.nonce || "",
5996
- model: props.model || ""
6078
+ model: props.model
5997
6079
  });
5998
6080
  function contentSetState(newRootState) {
5999
6081
  setBuilderContextSignal((PREVIOUS_VALUE) => ({
@@ -6098,7 +6180,7 @@ function ContentVariants(props) {
6098
6180
  canTrack: getDefaultCanTrack(props.canTrack)
6099
6181
  });
6100
6182
  });
6101
- onMount7(() => {
6183
+ onMount8(() => {
6102
6184
  setShouldRenderVariants(false);
6103
6185
  });
6104
6186
  return <><>
@@ -6228,7 +6310,7 @@ function Symbol(props) {
6228
6310
  }
6229
6311
  });
6230
6312
  }
6231
- onMount8(() => {
6313
+ onMount9(() => {
6232
6314
  });
6233
6315
  const onUpdateFn_0_props_symbol = createMemo20(() => props.symbol);
6234
6316
  function onUpdateFn_0() {
@@ -6251,7 +6333,7 @@ function Symbol(props) {
6251
6333
  ...contentToUse()?.data?.state
6252
6334
  }}
6253
6335
  canTrack={props.builderContext.canTrack}
6254
- model={props.symbol?.model}
6336
+ model={props.symbol?.model ?? ""}
6255
6337
  content={contentToUse()}
6256
6338
  linkComponent={props.builderLinkComponent}
6257
6339
  blocksWrapper={blocksWrapper()}