@builder.io/sdk-solid 3.0.7 → 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.
@@ -2079,10 +2079,10 @@ function SectionComponent(props) {
2079
2079
  var section_default = SectionComponent;
2080
2080
 
2081
2081
  // src/blocks/symbol/symbol.tsx
2082
- import { onMount as onMount8, on as on4, createEffect as createEffect4, createMemo as createMemo20, createSignal as createSignal20 } from "solid-js";
2082
+ import { onMount as onMount9, on as on4, createEffect as createEffect4, createMemo as createMemo20, createSignal as createSignal20 } from "solid-js";
2083
2083
 
2084
2084
  // src/components/content-variants/content-variants.tsx
2085
- import { Show as Show16, For as For9, onMount as onMount7, createSignal as createSignal19, createMemo as createMemo19 } from "solid-js";
2085
+ import { Show as Show16, For as For9, onMount as onMount8, createSignal as createSignal19, createMemo as createMemo19 } from "solid-js";
2086
2086
 
2087
2087
  // src/helpers/url.ts
2088
2088
  var getTopLevelDomain = (host) => {
@@ -4725,8 +4725,9 @@ var componentInfo20 = {
4725
4725
  };
4726
4726
 
4727
4727
  // src/blocks/video/video.tsx
4728
- import { Show as Show13, createMemo as createMemo15 } from "solid-js";
4728
+ import { Show as Show13, onMount as onMount6, createSignal as createSignal15, createMemo as createMemo15 } from "solid-js";
4729
4729
  function Video(props) {
4730
+ const [lazyVideoObserver, setLazyVideoObserver] = createSignal15(void 0);
4730
4731
  const videoProps = createMemo15(() => {
4731
4732
  return {
4732
4733
  ...props.autoPlay === true ? {
@@ -4751,6 +4752,35 @@ function Video(props) {
4751
4752
  ...videoProps()
4752
4753
  };
4753
4754
  });
4755
+ let videoRef;
4756
+ onMount6(() => {
4757
+ if (props.lazyLoad) {
4758
+ const oberver = new IntersectionObserver(function(entries) {
4759
+ entries.forEach(function(entry) {
4760
+ if (!entry.isIntersecting)
4761
+ return;
4762
+ const videoElement = entry.target;
4763
+ try {
4764
+ Array.from(videoElement.children).filter(
4765
+ (child) => child instanceof HTMLElement && child.tagName === "SOURCE"
4766
+ ).forEach((source) => {
4767
+ const src = source.dataset.src;
4768
+ if (src) {
4769
+ source.src = src;
4770
+ }
4771
+ });
4772
+ videoElement.load();
4773
+ oberver.unobserve(videoElement);
4774
+ } catch (error2) {
4775
+ }
4776
+ });
4777
+ });
4778
+ if (videoRef) {
4779
+ oberver.observe(videoRef);
4780
+ }
4781
+ setLazyVideoObserver(oberver);
4782
+ }
4783
+ });
4754
4784
  return <><div
4755
4785
  style={{
4756
4786
  position: "relative"
@@ -4759,7 +4789,8 @@ function Video(props) {
4759
4789
  <video
4760
4790
  class="builder-video"
4761
4791
  {...spreadProps()}
4762
- preload={props.preload || "metadata"}
4792
+ ref={videoRef}
4793
+ preload={props.lazyLoad ? "none" : props.preload || "metadata"}
4763
4794
  style={{
4764
4795
  width: "100%",
4765
4796
  height: "100%",
@@ -4773,9 +4804,15 @@ function Video(props) {
4773
4804
  position: "absolute"
4774
4805
  } : null
4775
4806
  }}
4776
- src={props.video || "no-src"}
4777
4807
  poster={props.posterImage}
4778
- ><Show13 when={!props.lazyLoad}><source type="video/mp4" src={props.video} /></Show13></video>
4808
+ ><source
4809
+ type="video/mp4"
4810
+ {...props.lazyLoad ? {
4811
+ "data-src": props.video
4812
+ } : {
4813
+ src: props.video
4814
+ }}
4815
+ /></video>
4779
4816
  <Show13
4780
4817
  when={props.aspectRatio && !(props.fitContent && props.builderBlock?.children?.length)}
4781
4818
  ><div
@@ -4945,7 +4982,7 @@ var getUpdateVariantVisibilityScript = ({
4945
4982
  // src/components/content/components/enable-editor.tsx
4946
4983
  import {
4947
4984
  Show as Show14,
4948
- onMount as onMount6,
4985
+ onMount as onMount7,
4949
4986
  on as on3,
4950
4987
  createEffect as createEffect3,
4951
4988
  createMemo as createMemo16,
@@ -4959,7 +4996,7 @@ function getPreviewContent(_searchParams) {
4959
4996
  }
4960
4997
 
4961
4998
  // src/constants/sdk-version.ts
4962
- var SDK_VERSION = "3.0.7";
4999
+ var SDK_VERSION = "4.0.0";
4963
5000
 
4964
5001
  // src/helpers/sdk-headers.ts
4965
5002
  var getSdkHeaders = () => ({
@@ -5561,7 +5598,7 @@ var registerInsertMenu = () => {
5561
5598
  });
5562
5599
  };
5563
5600
  var isSetupForEditing = false;
5564
- var setupBrowserForEditing = (options = {}) => {
5601
+ var setupBrowserForEditing = (options) => {
5565
5602
  if (isSetupForEditing) {
5566
5603
  return;
5567
5604
  }
@@ -5577,6 +5614,8 @@ var setupBrowserForEditing = (options = {}) => {
5577
5614
  // scope our '+ add block' button styling
5578
5615
  supportsAddBlockScoping: true,
5579
5616
  supportsCustomBreakpoints: true,
5617
+ modelName: options.modelName,
5618
+ apiKey: options.apiKey,
5580
5619
  supportsXSmallBreakpoint: TARGET === "reactNative" ? false : true,
5581
5620
  blockLevelPersonalization: true
5582
5621
  }
@@ -5682,13 +5721,21 @@ var createEditorListener = ({
5682
5721
  }
5683
5722
  };
5684
5723
  };
5685
- var subscribeToEditor = (model, callback, options) => {
5724
+ var subscribeToEditor = ({
5725
+ model,
5726
+ apiKey,
5727
+ callback,
5728
+ trustedHosts
5729
+ }) => {
5686
5730
  if (!isBrowser) {
5687
5731
  logger.warn("`subscribeToEditor` only works in the browser. It currently seems to be running on the server.");
5688
5732
  return () => {
5689
5733
  };
5690
5734
  }
5691
- setupBrowserForEditing();
5735
+ setupBrowserForEditing({
5736
+ modelName: model,
5737
+ apiKey
5738
+ });
5692
5739
  const listener = createEditorListener({
5693
5740
  callbacks: {
5694
5741
  contentUpdate: callback,
@@ -5698,7 +5745,7 @@ var subscribeToEditor = (model, callback, options) => {
5698
5745
  }
5699
5746
  },
5700
5747
  model,
5701
- trustedHosts: options?.trustedHosts
5748
+ trustedHosts
5702
5749
  });
5703
5750
  window.addEventListener("message", listener);
5704
5751
  return () => {
@@ -5938,7 +5985,7 @@ function EnableEditor(props) {
5938
5985
  let elementRef;
5939
5986
  runHttpRequests();
5940
5987
  emitStateUpdate();
5941
- onMount6(() => {
5988
+ onMount7(() => {
5942
5989
  if (isBrowser()) {
5943
5990
  if (isEditing() && !props.isNestedRender) {
5944
5991
  window.addEventListener("message", processMessage);
@@ -5952,12 +5999,14 @@ function EnableEditor(props) {
5952
5999
  } : {},
5953
6000
  ...props.trustedHosts ? {
5954
6001
  trustedHosts: props.trustedHosts
5955
- } : {}
6002
+ } : {},
6003
+ modelName: props.model ?? "",
6004
+ apiKey: props.apiKey
5956
6005
  });
5957
6006
  Object.values(
5958
6007
  props.builderContextSignal.componentInfos
5959
6008
  ).forEach((registeredComponent) => {
5960
- if (!props.model || !registeredComponent.models?.length || registeredComponent.models.includes(props.model)) {
6009
+ if (!registeredComponent.models?.length || registeredComponent.models.includes(props.model)) {
5961
6010
  const message = createRegisterComponentMessage(registeredComponent);
5962
6011
  window.parent?.postMessage(message, "*");
5963
6012
  }
@@ -5990,7 +6039,7 @@ function EnableEditor(props) {
5990
6039
  const previewApiKey = searchParams.get("apiKey") || searchParams.get("builder.space");
5991
6040
  if (searchParamPreviewModel === "BUILDER_STUDIO" || searchParamPreviewModel === props.model && previewApiKey === props.apiKey && (!props.content || searchParamPreviewId === props.content.id)) {
5992
6041
  fetchOneEntry({
5993
- model: props.model || "",
6042
+ model: props.model,
5994
6043
  apiKey: props.apiKey,
5995
6044
  apiVersion: props.builderContextSignal.apiVersion,
5996
6045
  ...searchParamPreviewModel === "BUILDER_STUDIO" && props.context?.symbolId ? {
@@ -6178,7 +6227,7 @@ function ContentComponent(props) {
6178
6227
  BlocksWrapper: props.blocksWrapper || "div",
6179
6228
  BlocksWrapperProps: props.blocksWrapperProps || {},
6180
6229
  nonce: props.nonce || "",
6181
- model: props.model || ""
6230
+ model: props.model
6182
6231
  });
6183
6232
  function contentSetState(newRootState) {
6184
6233
  setBuilderContextSignal((PREVIOUS_VALUE) => ({
@@ -6283,7 +6332,7 @@ function ContentVariants(props) {
6283
6332
  canTrack: getDefaultCanTrack(props.canTrack)
6284
6333
  });
6285
6334
  });
6286
- onMount7(() => {
6335
+ onMount8(() => {
6287
6336
  setShouldRenderVariants(false);
6288
6337
  });
6289
6338
  return <><>
@@ -6413,7 +6462,7 @@ function Symbol(props) {
6413
6462
  }
6414
6463
  });
6415
6464
  }
6416
- onMount8(() => {
6465
+ onMount9(() => {
6417
6466
  });
6418
6467
  const onUpdateFn_0_props_symbol = createMemo20(() => props.symbol);
6419
6468
  function onUpdateFn_0() {
@@ -6436,7 +6485,7 @@ function Symbol(props) {
6436
6485
  ...contentToUse()?.data?.state
6437
6486
  }}
6438
6487
  canTrack={props.builderContext.canTrack}
6439
- model={props.symbol?.model}
6488
+ model={props.symbol?.model ?? ""}
6440
6489
  content={contentToUse()}
6441
6490
  linkComponent={props.builderLinkComponent}
6442
6491
  blocksWrapper={blocksWrapper()}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@builder.io/sdk-solid",
3
- "version": "3.0.7",
3
+ "version": "4.0.0",
4
4
  "description": "",
5
5
  "files": [
6
6
  "dist",