@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.
@@ -1,12 +1,10 @@
1
1
  // src/blocks/button/button.tsx
2
2
  import { Show } from "solid-js";
3
- import { css } from "solid-styled-components";
4
3
  function Button(props) {
5
4
  return <Show
6
5
  fallback={<button
7
- class={props.attributes.class + " " + css({
8
- all: "unset"
9
- })}
6
+ class={`builder-button ${props.attributes.class}`}
7
+ role="button"
10
8
  {...{}}
11
9
  {...props.attributes}
12
10
  style={props.attributes.style}
@@ -24,7 +22,7 @@ var button_default = Button;
24
22
 
25
23
  // src/blocks/columns/columns.tsx
26
24
  import { Show as Show7, For as For4, createSignal as createSignal5 } from "solid-js";
27
- import { css as css3 } from "solid-styled-components";
25
+ import { css as css2 } from "solid-styled-components";
28
26
 
29
27
  // src/components/blocks/blocks.tsx
30
28
  import { useContext, Show as Show6, For as For3 } from "solid-js";
@@ -448,10 +446,6 @@ function getProcessedBlock({
448
446
  }
449
447
 
450
448
  // src/components/block/block.helpers.ts
451
- var EMPTY_HTML_ELEMENTS = ["area", "base", "br", "col", "embed", "hr", "img", "input", "keygen", "link", "meta", "param", "source", "track", "wbr"];
452
- var isEmptyHtmlElement = (tagName) => {
453
- return typeof tagName === "string" && EMPTY_HTML_ELEMENTS.includes(tagName.toLowerCase());
454
- };
455
449
  var getComponent = ({
456
450
  block,
457
451
  context,
@@ -626,7 +620,7 @@ function BlockStyles(props) {
626
620
  }
627
621
  return true;
628
622
  }
629
- function css5() {
623
+ function css4() {
630
624
  const processedBlock = getProcessedBlock({
631
625
  block: props.block,
632
626
  localState: props.context.localState,
@@ -669,14 +663,10 @@ function BlockStyles(props) {
669
663
  }) : "";
670
664
  return [largeStylesClass, mediumStylesClass, smallStylesClass].join(" ");
671
665
  }
672
- return <Show2 when={TARGET !== "reactNative" && css5() && canShowBlock()}><Inlined_styles_default styles={css5()} /></Show2>;
666
+ return <Show2 when={TARGET !== "reactNative" && css4() && canShowBlock()}><Inlined_styles_default styles={css4()} /></Show2>;
673
667
  }
674
668
  var Block_styles_default = BlockStyles;
675
669
 
676
- // src/components/block/components/block-wrapper.tsx
677
- import { Show as Show3 } from "solid-js";
678
- import { Dynamic } from "solid-js/web";
679
-
680
670
  // src/functions/event-handler-name.ts
681
671
  function capitalizeFirstLetter(string) {
682
672
  return string.charAt(0).toUpperCase() + string.slice(1);
@@ -763,31 +753,49 @@ function getStyleAttribute(style) {
763
753
  }
764
754
  }
765
755
 
766
- // src/components/block/components/block-wrapper.tsx
767
- function BlockWrapper(props) {
756
+ // src/components/dynamic-renderer/dynamic-renderer.tsx
757
+ import { Show as Show3 } from "solid-js";
758
+ import { Dynamic } from "solid-js/web";
759
+
760
+ // src/components/dynamic-renderer/dynamic-renderer.helpers.ts
761
+ var EMPTY_HTML_ELEMENTS = /* @__PURE__ */ new Set(["area", "base", "br", "col", "embed", "hr", "img", "input", "keygen", "link", "meta", "param", "source", "track", "wbr"]);
762
+ var isEmptyElement = (tagName) => {
763
+ return typeof tagName === "string" && EMPTY_HTML_ELEMENTS.has(tagName.toLowerCase());
764
+ };
765
+
766
+ // src/components/dynamic-renderer/dynamic-renderer.tsx
767
+ function DynamicRenderer(props) {
768
768
  return <Show3
769
769
  fallback={<Dynamic
770
- {...getBlockProperties({
771
- block: props.block,
772
- context: props.context
773
- })}
774
- {...getBlockActions({
775
- block: props.block,
776
- rootState: props.context.rootState,
777
- rootSetState: props.context.rootSetState,
778
- localState: props.context.localState,
779
- context: props.context.context,
780
- stripPrefix: true
781
- })}
782
- component={props.Wrapper}
770
+ {...props.attributes}
771
+ {...props.actionAttributes}
772
+ component={props.TagName}
783
773
  />}
784
- when={props.hasChildren}
774
+ when={!isEmptyElement(props.TagName)}
775
+ ><Show3
776
+ fallback={<Dynamic
777
+ {...props.attributes}
778
+ {...props.actionAttributes}
779
+ component={props.TagName}
780
+ >{props.children}</Dynamic>}
781
+ when={typeof props.TagName === "string"}
785
782
  ><Dynamic
786
- {...getBlockProperties({
783
+ {...props.attributes}
784
+ {...props.actionAttributes}
785
+ component={props.TagName}
786
+ >{props.children}</Dynamic></Show3></Show3>;
787
+ }
788
+ var Dynamic_renderer_default = DynamicRenderer;
789
+
790
+ // src/components/block/components/block-wrapper.tsx
791
+ function BlockWrapper(props) {
792
+ return <Dynamic_renderer_default
793
+ TagName={props.Wrapper}
794
+ attributes={getBlockProperties({
787
795
  block: props.block,
788
796
  context: props.context
789
797
  })}
790
- {...getBlockActions({
798
+ actionAttributes={getBlockActions({
791
799
  block: props.block,
792
800
  rootState: props.context.rootState,
793
801
  rootSetState: props.context.rootSetState,
@@ -795,8 +803,7 @@ function BlockWrapper(props) {
795
803
  context: props.context.context,
796
804
  stripPrefix: true
797
805
  })}
798
- component={props.Wrapper}
799
- >{props.children}</Dynamic></Show3>;
806
+ >{props.children}</Dynamic_renderer_default>;
800
807
  }
801
808
  var Block_wrapper_default = BlockWrapper;
802
809
 
@@ -975,14 +982,8 @@ function Block(props) {
975
982
  isInteractive={componentRefProps().isInteractive}
976
983
  />}
977
984
  when={!blockComponent()?.noWrap}
978
- >
979
- <Show5 when={isEmptyHtmlElement(Tag())}><Block_wrapper_default
980
- Wrapper={Tag()}
981
- block={processedBlock()}
982
- context={props.context}
983
- hasChildren={false}
984
- /></Show5>
985
- <Show5 when={!isEmptyHtmlElement(Tag()) && repeatItem()}><For2 each={repeatItem()}>{(data, _index) => {
985
+ ><Show5
986
+ fallback={<For2 each={repeatItem()}>{(data, _index) => {
986
987
  const index = _index();
987
988
  return <Repeated_block_default
988
989
  key={index}
@@ -990,41 +991,40 @@ function Block(props) {
990
991
  block={data.block}
991
992
  registeredComponents={props.registeredComponents}
992
993
  />;
993
- }}</For2></Show5>
994
- <Show5 when={!isEmptyHtmlElement(Tag()) && !repeatItem()}><Block_wrapper_default
995
- Wrapper={Tag()}
996
- block={processedBlock()}
997
- context={props.context}
998
- hasChildren={true}
999
- >
1000
- <Component_ref_default
1001
- componentRef={componentRefProps().componentRef}
1002
- componentOptions={componentRefProps().componentOptions}
1003
- blockChildren={componentRefProps().blockChildren}
1004
- context={componentRefProps().context}
1005
- registeredComponents={componentRefProps().registeredComponents}
1006
- builderBlock={componentRefProps().builderBlock}
1007
- includeBlockProps={componentRefProps().includeBlockProps}
1008
- isInteractive={componentRefProps().isInteractive}
1009
- />
1010
- <For2 each={childrenWithoutParentComponent()}>{(child, _index) => {
1011
- const index = _index();
1012
- return <Block
1013
- key={child.id}
1014
- block={child}
1015
- context={childrenContext()}
1016
- registeredComponents={props.registeredComponents}
1017
- />;
1018
- }}</For2>
1019
- </Block_wrapper_default></Show5>
1020
- </Show5>
994
+ }}</For2>}
995
+ when={!repeatItem()}
996
+ ><Block_wrapper_default
997
+ Wrapper={Tag()}
998
+ block={processedBlock()}
999
+ context={props.context}
1000
+ >
1001
+ <Component_ref_default
1002
+ componentRef={componentRefProps().componentRef}
1003
+ componentOptions={componentRefProps().componentOptions}
1004
+ blockChildren={componentRefProps().blockChildren}
1005
+ context={componentRefProps().context}
1006
+ registeredComponents={componentRefProps().registeredComponents}
1007
+ builderBlock={componentRefProps().builderBlock}
1008
+ includeBlockProps={componentRefProps().includeBlockProps}
1009
+ isInteractive={componentRefProps().isInteractive}
1010
+ />
1011
+ <For2 each={childrenWithoutParentComponent()}>{(child, _index) => {
1012
+ const index = _index();
1013
+ return <Block
1014
+ key={child.id}
1015
+ block={child}
1016
+ context={childrenContext()}
1017
+ registeredComponents={props.registeredComponents}
1018
+ />;
1019
+ }}</For2>
1020
+ </Block_wrapper_default></Show5></Show5>
1021
1021
  </Show5>;
1022
1022
  }
1023
1023
  var Block_default = Block;
1024
1024
 
1025
1025
  // src/components/blocks/blocks-wrapper.tsx
1026
1026
  import { Dynamic as Dynamic4 } from "solid-js/web";
1027
- import { css as css2 } from "solid-styled-components";
1027
+ import { css } from "solid-styled-components";
1028
1028
  function BlocksWrapper(props) {
1029
1029
  function className() {
1030
1030
  return "builder-blocks" + (!props.blocks?.length ? " no-blocks" : "");
@@ -1058,7 +1058,7 @@ function BlocksWrapper(props) {
1058
1058
  }
1059
1059
  }
1060
1060
  return <Dynamic4
1061
- class={className() + " " + css2({
1061
+ class={className() + " " + css({
1062
1062
  display: "flex",
1063
1063
  flexDirection: "column",
1064
1064
  alignItems: "stretch"
@@ -1199,7 +1199,7 @@ function Columns(props) {
1199
1199
  `;
1200
1200
  }
1201
1201
  return <div
1202
- class={`builder-columns ${props.builderBlock.id}-breakpoints ` + css3({
1202
+ class={`builder-columns ${props.builderBlock.id}-breakpoints ` + css2({
1203
1203
  display: "flex",
1204
1204
  lineHeight: "normal"
1205
1205
  })}
@@ -1210,7 +1210,7 @@ function Columns(props) {
1210
1210
  <For4 each={props.columns}>{(column, _index) => {
1211
1211
  const index = _index();
1212
1212
  return <div
1213
- class={"builder-column " + css3({
1213
+ class={"builder-column " + css2({
1214
1214
  display: "flex",
1215
1215
  flexDirection: "column",
1216
1216
  alignItems: "stretch"
@@ -1241,7 +1241,7 @@ var fragment_default = FragmentComponent;
1241
1241
 
1242
1242
  // src/blocks/image/image.tsx
1243
1243
  import { Show as Show8 } from "solid-js";
1244
- import { css as css4 } from "solid-styled-components";
1244
+ import { css as css3 } from "solid-styled-components";
1245
1245
 
1246
1246
  // src/blocks/image/image.helpers.ts
1247
1247
  function removeProtocol(path) {
@@ -1331,7 +1331,7 @@ function Image(props) {
1331
1331
  <picture>
1332
1332
  <Show8 when={webpSrcSet()}><source type="image/webp" srcset={webpSrcSet()} /></Show8>
1333
1333
  <img
1334
- class={"builder-image" + (props.className ? " " + props.className : "") + " " + css4({
1334
+ class={"builder-image" + (props.className ? " " + props.className : "") + " " + css3({
1335
1335
  opacity: "1",
1336
1336
  transition: "opacity 0.2s ease-in-out"
1337
1337
  })}
@@ -1351,7 +1351,7 @@ function Image(props) {
1351
1351
  <Show8
1352
1352
  when={props.aspectRatio && !(props.builderBlock?.children?.length && props.fitContent)}
1353
1353
  ><div
1354
- class={"builder-image-sizer " + css4({
1354
+ class={"builder-image-sizer " + css3({
1355
1355
  width: "100%",
1356
1356
  pointerEvents: "none",
1357
1357
  fontSize: "0"
@@ -1362,7 +1362,7 @@ function Image(props) {
1362
1362
  /></Show8>
1363
1363
  <Show8 when={props.builderBlock?.children?.length && props.fitContent}>{props.children}</Show8>
1364
1364
  <Show8 when={!props.fitContent && props.children}><div
1365
- class={css4({
1365
+ class={css3({
1366
1366
  display: "flex",
1367
1367
  flexDirection: "column",
1368
1368
  alignItems: "stretch",
@@ -2838,6 +2838,13 @@ async function fetchEntries(options) {
2838
2838
  }
2839
2839
  var getAllContent = fetchEntries;
2840
2840
 
2841
+ // src/functions/is-from-trusted-host.ts
2842
+ var DEFAULT_TRUSTED_HOSTS = ["*.beta.builder.io", "beta.builder.io", "builder.io", "localhost", "qa.builder.io"];
2843
+ function isFromTrustedHost(trustedHosts, e) {
2844
+ const url = new URL(e.origin), hostname = url.hostname;
2845
+ return (trustedHosts || DEFAULT_TRUSTED_HOSTS).findIndex((trustedHost) => trustedHost.startsWith("*.") ? hostname.endsWith(trustedHost.slice(1)) : trustedHost === hostname) > -1;
2846
+ }
2847
+
2841
2848
  // src/functions/is-previewing.ts
2842
2849
  function isPreviewing() {
2843
2850
  if (!isBrowser()) {
@@ -3086,7 +3093,7 @@ var getInteractionPropertiesForEvent = (event) => {
3086
3093
  };
3087
3094
 
3088
3095
  // src/constants/sdk-version.ts
3089
- var SDK_VERSION = "0.12.1";
3096
+ var SDK_VERSION = "0.12.3";
3090
3097
 
3091
3098
  // src/functions/register.ts
3092
3099
  var registry = {};
@@ -3163,9 +3170,13 @@ var setupBrowserForEditing = (options = {}) => {
3163
3170
  options
3164
3171
  }
3165
3172
  }, "*");
3166
- window.addEventListener("message", ({
3167
- data
3168
- }) => {
3173
+ window.addEventListener("message", (event) => {
3174
+ if (!isFromTrustedHost(options.trustedHosts, event)) {
3175
+ return;
3176
+ }
3177
+ const {
3178
+ data
3179
+ } = event;
3169
3180
  if (!data?.type) {
3170
3181
  return;
3171
3182
  }
@@ -3263,6 +3274,9 @@ function EnableEditor(props) {
3263
3274
  }));
3264
3275
  }
3265
3276
  function processMessage(event) {
3277
+ if (!isFromTrustedHost(props.trustedHosts, event)) {
3278
+ return;
3279
+ }
3266
3280
  const { data } = event;
3267
3281
  if (data) {
3268
3282
  switch (data.type) {
@@ -3393,6 +3407,9 @@ function EnableEditor(props) {
3393
3407
  } : {},
3394
3408
  ...props.enrich ? {
3395
3409
  enrich: props.enrich
3410
+ } : {},
3411
+ ...props.trustedHosts ? {
3412
+ trustedHosts: props.trustedHosts
3396
3413
  } : {}
3397
3414
  });
3398
3415
  Object.values(
@@ -3587,6 +3604,10 @@ ${getFontCss({
3587
3604
  customFonts: props.customFonts
3588
3605
  })}
3589
3606
 
3607
+ .builder-button {
3608
+ all: unset;
3609
+ }
3610
+
3590
3611
  .builder-text > p:first-of-type, .builder-text > .builder-paragraph:first-of-type {
3591
3612
  margin: 0;
3592
3613
  }
@@ -3731,6 +3752,7 @@ function ContentComponent(props) {
3731
3752
  builderContextSignal={builderContextSignal()}
3732
3753
  contentWrapper={props.contentWrapper}
3733
3754
  contentWrapperProps={props.contentWrapperProps}
3755
+ trustedHosts={props.trustedHosts}
3734
3756
  {...{
3735
3757
  setBuilderContextSignal
3736
3758
  }}
@@ -3813,6 +3835,7 @@ function ContentVariants(props) {
3813
3835
  blocksWrapperProps={props.blocksWrapperProps}
3814
3836
  contentWrapper={props.contentWrapper}
3815
3837
  contentWrapperProps={props.contentWrapperProps}
3838
+ trustedHosts={props.trustedHosts}
3816
3839
  />;
3817
3840
  }}</For5>
3818
3841
  </Show12>
@@ -3835,6 +3858,7 @@ function ContentVariants(props) {
3835
3858
  blocksWrapperProps={props.blocksWrapperProps}
3836
3859
  contentWrapper={props.contentWrapper}
3837
3860
  contentWrapperProps={props.contentWrapperProps}
3861
+ trustedHosts={props.trustedHosts}
3838
3862
  />
3839
3863
  </>;
3840
3864
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@builder.io/sdk-solid",
3
- "version": "0.12.1",
3
+ "version": "0.12.3",
4
4
  "description": "",
5
5
  "files": [
6
6
  "dist",