@builder.io/sdk-solid 0.12.1 → 0.12.3

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/lib/edge/dev.jsx CHANGED
@@ -8,13 +8,11 @@ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require
8
8
 
9
9
  // src/blocks/button/button.tsx
10
10
  import { Show } from "solid-js";
11
- import { css } from "solid-styled-components";
12
11
  function Button(props) {
13
12
  return <Show
14
13
  fallback={<button
15
- class={props.attributes.class + " " + css({
16
- all: "unset"
17
- })}
14
+ class={`builder-button ${props.attributes.class}`}
15
+ role="button"
18
16
  {...{}}
19
17
  {...props.attributes}
20
18
  style={props.attributes.style}
@@ -32,7 +30,7 @@ var button_default = Button;
32
30
 
33
31
  // src/blocks/columns/columns.tsx
34
32
  import { Show as Show7, For as For4, createSignal as createSignal5 } from "solid-js";
35
- import { css as css3 } from "solid-styled-components";
33
+ import { css as css2 } from "solid-styled-components";
36
34
 
37
35
  // src/components/blocks/blocks.tsx
38
36
  import { useContext, Show as Show6, For as For3 } from "solid-js";
@@ -3480,10 +3478,6 @@ function getProcessedBlock({
3480
3478
  }
3481
3479
 
3482
3480
  // src/components/block/block.helpers.ts
3483
- var EMPTY_HTML_ELEMENTS = ["area", "base", "br", "col", "embed", "hr", "img", "input", "keygen", "link", "meta", "param", "source", "track", "wbr"];
3484
- var isEmptyHtmlElement = (tagName) => {
3485
- return typeof tagName === "string" && EMPTY_HTML_ELEMENTS.includes(tagName.toLowerCase());
3486
- };
3487
3481
  var getComponent = ({
3488
3482
  block,
3489
3483
  context,
@@ -3661,7 +3655,7 @@ function BlockStyles(props) {
3661
3655
  }
3662
3656
  return true;
3663
3657
  }
3664
- function css5() {
3658
+ function css4() {
3665
3659
  const processedBlock = getProcessedBlock({
3666
3660
  block: props.block,
3667
3661
  localState: props.context.localState,
@@ -3704,14 +3698,10 @@ function BlockStyles(props) {
3704
3698
  }) : "";
3705
3699
  return [largeStylesClass, mediumStylesClass, smallStylesClass].join(" ");
3706
3700
  }
3707
- return <Show2 when={TARGET !== "reactNative" && css5() && canShowBlock()}><Inlined_styles_default styles={css5()} /></Show2>;
3701
+ return <Show2 when={TARGET !== "reactNative" && css4() && canShowBlock()}><Inlined_styles_default styles={css4()} /></Show2>;
3708
3702
  }
3709
3703
  var Block_styles_default = BlockStyles;
3710
3704
 
3711
- // src/components/block/components/block-wrapper.tsx
3712
- import { Show as Show3 } from "solid-js";
3713
- import { Dynamic } from "solid-js/web";
3714
-
3715
3705
  // src/functions/event-handler-name.ts
3716
3706
  function capitalizeFirstLetter(string) {
3717
3707
  return string.charAt(0).toUpperCase() + string.slice(1);
@@ -3798,31 +3788,49 @@ function getStyleAttribute(style) {
3798
3788
  }
3799
3789
  }
3800
3790
 
3801
- // src/components/block/components/block-wrapper.tsx
3802
- function BlockWrapper(props) {
3791
+ // src/components/dynamic-renderer/dynamic-renderer.tsx
3792
+ import { Show as Show3 } from "solid-js";
3793
+ import { Dynamic } from "solid-js/web";
3794
+
3795
+ // src/components/dynamic-renderer/dynamic-renderer.helpers.ts
3796
+ var EMPTY_HTML_ELEMENTS = /* @__PURE__ */ new Set(["area", "base", "br", "col", "embed", "hr", "img", "input", "keygen", "link", "meta", "param", "source", "track", "wbr"]);
3797
+ var isEmptyElement = (tagName) => {
3798
+ return typeof tagName === "string" && EMPTY_HTML_ELEMENTS.has(tagName.toLowerCase());
3799
+ };
3800
+
3801
+ // src/components/dynamic-renderer/dynamic-renderer.tsx
3802
+ function DynamicRenderer(props) {
3803
3803
  return <Show3
3804
3804
  fallback={<Dynamic
3805
- {...getBlockProperties({
3806
- block: props.block,
3807
- context: props.context
3808
- })}
3809
- {...getBlockActions({
3810
- block: props.block,
3811
- rootState: props.context.rootState,
3812
- rootSetState: props.context.rootSetState,
3813
- localState: props.context.localState,
3814
- context: props.context.context,
3815
- stripPrefix: true
3816
- })}
3817
- component={props.Wrapper}
3805
+ {...props.attributes}
3806
+ {...props.actionAttributes}
3807
+ component={props.TagName}
3818
3808
  />}
3819
- when={props.hasChildren}
3809
+ when={!isEmptyElement(props.TagName)}
3810
+ ><Show3
3811
+ fallback={<Dynamic
3812
+ {...props.attributes}
3813
+ {...props.actionAttributes}
3814
+ component={props.TagName}
3815
+ >{props.children}</Dynamic>}
3816
+ when={typeof props.TagName === "string"}
3820
3817
  ><Dynamic
3821
- {...getBlockProperties({
3818
+ {...props.attributes}
3819
+ {...props.actionAttributes}
3820
+ component={props.TagName}
3821
+ >{props.children}</Dynamic></Show3></Show3>;
3822
+ }
3823
+ var Dynamic_renderer_default = DynamicRenderer;
3824
+
3825
+ // src/components/block/components/block-wrapper.tsx
3826
+ function BlockWrapper(props) {
3827
+ return <Dynamic_renderer_default
3828
+ TagName={props.Wrapper}
3829
+ attributes={getBlockProperties({
3822
3830
  block: props.block,
3823
3831
  context: props.context
3824
3832
  })}
3825
- {...getBlockActions({
3833
+ actionAttributes={getBlockActions({
3826
3834
  block: props.block,
3827
3835
  rootState: props.context.rootState,
3828
3836
  rootSetState: props.context.rootSetState,
@@ -3830,8 +3838,7 @@ function BlockWrapper(props) {
3830
3838
  context: props.context.context,
3831
3839
  stripPrefix: true
3832
3840
  })}
3833
- component={props.Wrapper}
3834
- >{props.children}</Dynamic></Show3>;
3841
+ >{props.children}</Dynamic_renderer_default>;
3835
3842
  }
3836
3843
  var Block_wrapper_default = BlockWrapper;
3837
3844
 
@@ -4010,14 +4017,8 @@ function Block(props) {
4010
4017
  isInteractive={componentRefProps().isInteractive}
4011
4018
  />}
4012
4019
  when={!blockComponent()?.noWrap}
4013
- >
4014
- <Show5 when={isEmptyHtmlElement(Tag())}><Block_wrapper_default
4015
- Wrapper={Tag()}
4016
- block={processedBlock()}
4017
- context={props.context}
4018
- hasChildren={false}
4019
- /></Show5>
4020
- <Show5 when={!isEmptyHtmlElement(Tag()) && repeatItem()}><For2 each={repeatItem()}>{(data, _index) => {
4020
+ ><Show5
4021
+ fallback={<For2 each={repeatItem()}>{(data, _index) => {
4021
4022
  const index = _index();
4022
4023
  return <Repeated_block_default
4023
4024
  key={index}
@@ -4025,41 +4026,40 @@ function Block(props) {
4025
4026
  block={data.block}
4026
4027
  registeredComponents={props.registeredComponents}
4027
4028
  />;
4028
- }}</For2></Show5>
4029
- <Show5 when={!isEmptyHtmlElement(Tag()) && !repeatItem()}><Block_wrapper_default
4030
- Wrapper={Tag()}
4031
- block={processedBlock()}
4032
- context={props.context}
4033
- hasChildren={true}
4034
- >
4035
- <Component_ref_default
4036
- componentRef={componentRefProps().componentRef}
4037
- componentOptions={componentRefProps().componentOptions}
4038
- blockChildren={componentRefProps().blockChildren}
4039
- context={componentRefProps().context}
4040
- registeredComponents={componentRefProps().registeredComponents}
4041
- builderBlock={componentRefProps().builderBlock}
4042
- includeBlockProps={componentRefProps().includeBlockProps}
4043
- isInteractive={componentRefProps().isInteractive}
4044
- />
4045
- <For2 each={childrenWithoutParentComponent()}>{(child, _index) => {
4046
- const index = _index();
4047
- return <Block
4048
- key={child.id}
4049
- block={child}
4050
- context={childrenContext()}
4051
- registeredComponents={props.registeredComponents}
4052
- />;
4053
- }}</For2>
4054
- </Block_wrapper_default></Show5>
4055
- </Show5>
4029
+ }}</For2>}
4030
+ when={!repeatItem()}
4031
+ ><Block_wrapper_default
4032
+ Wrapper={Tag()}
4033
+ block={processedBlock()}
4034
+ context={props.context}
4035
+ >
4036
+ <Component_ref_default
4037
+ componentRef={componentRefProps().componentRef}
4038
+ componentOptions={componentRefProps().componentOptions}
4039
+ blockChildren={componentRefProps().blockChildren}
4040
+ context={componentRefProps().context}
4041
+ registeredComponents={componentRefProps().registeredComponents}
4042
+ builderBlock={componentRefProps().builderBlock}
4043
+ includeBlockProps={componentRefProps().includeBlockProps}
4044
+ isInteractive={componentRefProps().isInteractive}
4045
+ />
4046
+ <For2 each={childrenWithoutParentComponent()}>{(child, _index) => {
4047
+ const index = _index();
4048
+ return <Block
4049
+ key={child.id}
4050
+ block={child}
4051
+ context={childrenContext()}
4052
+ registeredComponents={props.registeredComponents}
4053
+ />;
4054
+ }}</For2>
4055
+ </Block_wrapper_default></Show5></Show5>
4056
4056
  </Show5>;
4057
4057
  }
4058
4058
  var Block_default = Block;
4059
4059
 
4060
4060
  // src/components/blocks/blocks-wrapper.tsx
4061
4061
  import { Dynamic as Dynamic4 } from "solid-js/web";
4062
- import { css as css2 } from "solid-styled-components";
4062
+ import { css } from "solid-styled-components";
4063
4063
  function BlocksWrapper(props) {
4064
4064
  function className() {
4065
4065
  return "builder-blocks" + (!props.blocks?.length ? " no-blocks" : "");
@@ -4093,7 +4093,7 @@ function BlocksWrapper(props) {
4093
4093
  }
4094
4094
  }
4095
4095
  return <Dynamic4
4096
- class={className() + " " + css2({
4096
+ class={className() + " " + css({
4097
4097
  display: "flex",
4098
4098
  flexDirection: "column",
4099
4099
  alignItems: "stretch"
@@ -4234,7 +4234,7 @@ function Columns(props) {
4234
4234
  `;
4235
4235
  }
4236
4236
  return <div
4237
- class={`builder-columns ${props.builderBlock.id}-breakpoints ` + css3({
4237
+ class={`builder-columns ${props.builderBlock.id}-breakpoints ` + css2({
4238
4238
  display: "flex",
4239
4239
  lineHeight: "normal"
4240
4240
  })}
@@ -4245,7 +4245,7 @@ function Columns(props) {
4245
4245
  <For4 each={props.columns}>{(column, _index) => {
4246
4246
  const index = _index();
4247
4247
  return <div
4248
- class={"builder-column " + css3({
4248
+ class={"builder-column " + css2({
4249
4249
  display: "flex",
4250
4250
  flexDirection: "column",
4251
4251
  alignItems: "stretch"
@@ -4276,7 +4276,7 @@ var fragment_default = FragmentComponent;
4276
4276
 
4277
4277
  // src/blocks/image/image.tsx
4278
4278
  import { Show as Show8 } from "solid-js";
4279
- import { css as css4 } from "solid-styled-components";
4279
+ import { css as css3 } from "solid-styled-components";
4280
4280
 
4281
4281
  // src/blocks/image/image.helpers.ts
4282
4282
  function removeProtocol(path) {
@@ -4367,7 +4367,7 @@ function Image(props) {
4367
4367
  <picture>
4368
4368
  <Show8 when={webpSrcSet()}><source type="image/webp" srcset={webpSrcSet()} /></Show8>
4369
4369
  <img
4370
- class={"builder-image" + (props.className ? " " + props.className : "") + " " + css4({
4370
+ class={"builder-image" + (props.className ? " " + props.className : "") + " " + css3({
4371
4371
  opacity: "1",
4372
4372
  transition: "opacity 0.2s ease-in-out"
4373
4373
  })}
@@ -4387,7 +4387,7 @@ function Image(props) {
4387
4387
  <Show8
4388
4388
  when={props.aspectRatio && !(props.builderBlock?.children?.length && props.fitContent)}
4389
4389
  ><div
4390
- class={"builder-image-sizer " + css4({
4390
+ class={"builder-image-sizer " + css3({
4391
4391
  width: "100%",
4392
4392
  pointerEvents: "none",
4393
4393
  fontSize: "0"
@@ -4398,7 +4398,7 @@ function Image(props) {
4398
4398
  /></Show8>
4399
4399
  <Show8 when={props.builderBlock?.children?.length && props.fitContent}>{props.children}</Show8>
4400
4400
  <Show8 when={!props.fitContent && props.children}><div
4401
- class={css4({
4401
+ class={css3({
4402
4402
  display: "flex",
4403
4403
  flexDirection: "column",
4404
4404
  alignItems: "stretch",
@@ -5879,6 +5879,13 @@ async function fetchEntries(options) {
5879
5879
  }
5880
5880
  var getAllContent = fetchEntries;
5881
5881
 
5882
+ // src/functions/is-from-trusted-host.ts
5883
+ var DEFAULT_TRUSTED_HOSTS = ["*.beta.builder.io", "beta.builder.io", "builder.io", "localhost", "qa.builder.io"];
5884
+ function isFromTrustedHost(trustedHosts, e) {
5885
+ const url = new URL(e.origin), hostname = url.hostname;
5886
+ return (trustedHosts || DEFAULT_TRUSTED_HOSTS).findIndex((trustedHost) => trustedHost.startsWith("*.") ? hostname.endsWith(trustedHost.slice(1)) : trustedHost === hostname) > -1;
5887
+ }
5888
+
5882
5889
  // src/functions/is-previewing.ts
5883
5890
  function isPreviewing() {
5884
5891
  if (!isBrowser()) {
@@ -6130,7 +6137,7 @@ var getInteractionPropertiesForEvent = (event) => {
6130
6137
  };
6131
6138
 
6132
6139
  // src/constants/sdk-version.ts
6133
- var SDK_VERSION = "0.12.1";
6140
+ var SDK_VERSION = "0.12.3";
6134
6141
 
6135
6142
  // src/functions/register.ts
6136
6143
  var registry = {};
@@ -6208,9 +6215,13 @@ var setupBrowserForEditing = (options = {}) => {
6208
6215
  options
6209
6216
  }
6210
6217
  }, "*");
6211
- window.addEventListener("message", ({
6212
- data
6213
- }) => {
6218
+ window.addEventListener("message", (event) => {
6219
+ if (!isFromTrustedHost(options.trustedHosts, event)) {
6220
+ return;
6221
+ }
6222
+ const {
6223
+ data
6224
+ } = event;
6214
6225
  if (!data?.type) {
6215
6226
  return;
6216
6227
  }
@@ -6308,6 +6319,9 @@ function EnableEditor(props) {
6308
6319
  }));
6309
6320
  }
6310
6321
  function processMessage(event) {
6322
+ if (!isFromTrustedHost(props.trustedHosts, event)) {
6323
+ return;
6324
+ }
6311
6325
  const { data } = event;
6312
6326
  if (data) {
6313
6327
  switch (data.type) {
@@ -6439,6 +6453,9 @@ function EnableEditor(props) {
6439
6453
  } : {},
6440
6454
  ...props.enrich ? {
6441
6455
  enrich: props.enrich
6456
+ } : {},
6457
+ ...props.trustedHosts ? {
6458
+ trustedHosts: props.trustedHosts
6442
6459
  } : {}
6443
6460
  });
6444
6461
  Object.values(
@@ -6633,6 +6650,10 @@ ${getFontCss({
6633
6650
  customFonts: props.customFonts
6634
6651
  })}
6635
6652
 
6653
+ .builder-button {
6654
+ all: unset;
6655
+ }
6656
+
6636
6657
  .builder-text > p:first-of-type, .builder-text > .builder-paragraph:first-of-type {
6637
6658
  margin: 0;
6638
6659
  }
@@ -6777,6 +6798,7 @@ function ContentComponent(props) {
6777
6798
  builderContextSignal={builderContextSignal()}
6778
6799
  contentWrapper={props.contentWrapper}
6779
6800
  contentWrapperProps={props.contentWrapperProps}
6801
+ trustedHosts={props.trustedHosts}
6780
6802
  {...{
6781
6803
  setBuilderContextSignal
6782
6804
  }}
@@ -6859,6 +6881,7 @@ function ContentVariants(props) {
6859
6881
  blocksWrapperProps={props.blocksWrapperProps}
6860
6882
  contentWrapper={props.contentWrapper}
6861
6883
  contentWrapperProps={props.contentWrapperProps}
6884
+ trustedHosts={props.trustedHosts}
6862
6885
  />;
6863
6886
  }}</For5>
6864
6887
  </Show12>
@@ -6881,6 +6904,7 @@ function ContentVariants(props) {
6881
6904
  blocksWrapperProps={props.blocksWrapperProps}
6882
6905
  contentWrapper={props.contentWrapper}
6883
6906
  contentWrapperProps={props.contentWrapperProps}
6907
+ trustedHosts={props.trustedHosts}
6884
6908
  />
6885
6909
  </>;
6886
6910
  }