@builder.io/sdk-solid 0.12.0 → 0.12.2

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.
@@ -323,10 +323,6 @@ function getProcessedBlock({
323
323
  }
324
324
 
325
325
  // src/components/block/block.helpers.ts
326
- var EMPTY_HTML_ELEMENTS = ["area", "base", "br", "col", "embed", "hr", "img", "input", "keygen", "link", "meta", "param", "source", "track", "wbr"];
327
- var isEmptyHtmlElement = (tagName) => {
328
- return typeof tagName === "string" && EMPTY_HTML_ELEMENTS.includes(tagName.toLowerCase());
329
- };
330
326
  var getComponent = ({
331
327
  block,
332
328
  context,
@@ -548,10 +544,6 @@ function BlockStyles(props) {
548
544
  }
549
545
  var Block_styles_default = BlockStyles;
550
546
 
551
- // src/components/block/components/block-wrapper.tsx
552
- import { Show as Show3 } from "solid-js";
553
- import { Dynamic } from "solid-js/web";
554
-
555
547
  // src/functions/event-handler-name.ts
556
548
  function capitalizeFirstLetter(string) {
557
549
  return string.charAt(0).toUpperCase() + string.slice(1);
@@ -638,31 +630,49 @@ function getStyleAttribute(style) {
638
630
  }
639
631
  }
640
632
 
641
- // src/components/block/components/block-wrapper.tsx
642
- function BlockWrapper(props) {
633
+ // src/components/dynamic-renderer/dynamic-renderer.tsx
634
+ import { Show as Show3 } from "solid-js";
635
+ import { Dynamic } from "solid-js/web";
636
+
637
+ // src/components/dynamic-renderer/dynamic-renderer.helpers.ts
638
+ var EMPTY_HTML_ELEMENTS = /* @__PURE__ */ new Set(["area", "base", "br", "col", "embed", "hr", "img", "input", "keygen", "link", "meta", "param", "source", "track", "wbr"]);
639
+ var isEmptyElement = (tagName) => {
640
+ return typeof tagName === "string" && EMPTY_HTML_ELEMENTS.has(tagName.toLowerCase());
641
+ };
642
+
643
+ // src/components/dynamic-renderer/dynamic-renderer.tsx
644
+ function DynamicRenderer(props) {
643
645
  return <Show3
644
646
  fallback={<Dynamic
645
- {...getBlockProperties({
646
- block: props.block,
647
- context: props.context
648
- })}
649
- {...getBlockActions({
650
- block: props.block,
651
- rootState: props.context.rootState,
652
- rootSetState: props.context.rootSetState,
653
- localState: props.context.localState,
654
- context: props.context.context,
655
- stripPrefix: true
656
- })}
657
- component={props.Wrapper}
647
+ {...props.attributes}
648
+ {...props.actionAttributes}
649
+ component={props.TagName}
658
650
  />}
659
- when={props.hasChildren}
651
+ when={!isEmptyElement(props.TagName)}
652
+ ><Show3
653
+ fallback={<Dynamic
654
+ {...props.attributes}
655
+ {...props.actionAttributes}
656
+ component={props.TagName}
657
+ >{props.children}</Dynamic>}
658
+ when={typeof props.TagName === "string"}
660
659
  ><Dynamic
661
- {...getBlockProperties({
660
+ {...props.attributes}
661
+ {...props.actionAttributes}
662
+ component={props.TagName}
663
+ >{props.children}</Dynamic></Show3></Show3>;
664
+ }
665
+ var Dynamic_renderer_default = DynamicRenderer;
666
+
667
+ // src/components/block/components/block-wrapper.tsx
668
+ function BlockWrapper(props) {
669
+ return <Dynamic_renderer_default
670
+ TagName={props.Wrapper}
671
+ attributes={getBlockProperties({
662
672
  block: props.block,
663
673
  context: props.context
664
674
  })}
665
- {...getBlockActions({
675
+ actionAttributes={getBlockActions({
666
676
  block: props.block,
667
677
  rootState: props.context.rootState,
668
678
  rootSetState: props.context.rootSetState,
@@ -670,8 +680,7 @@ function BlockWrapper(props) {
670
680
  context: props.context.context,
671
681
  stripPrefix: true
672
682
  })}
673
- component={props.Wrapper}
674
- >{props.children}</Dynamic></Show3>;
683
+ >{props.children}</Dynamic_renderer_default>;
675
684
  }
676
685
  var Block_wrapper_default = BlockWrapper;
677
686
 
@@ -850,14 +859,8 @@ function Block(props) {
850
859
  isInteractive={componentRefProps().isInteractive}
851
860
  />}
852
861
  when={!blockComponent()?.noWrap}
853
- >
854
- <Show5 when={isEmptyHtmlElement(Tag())}><Block_wrapper_default
855
- Wrapper={Tag()}
856
- block={processedBlock()}
857
- context={props.context}
858
- hasChildren={false}
859
- /></Show5>
860
- <Show5 when={!isEmptyHtmlElement(Tag()) && repeatItem()}><For2 each={repeatItem()}>{(data, _index) => {
862
+ ><Show5
863
+ fallback={<For2 each={repeatItem()}>{(data, _index) => {
861
864
  const index = _index();
862
865
  return <Repeated_block_default
863
866
  key={index}
@@ -865,34 +868,33 @@ function Block(props) {
865
868
  block={data.block}
866
869
  registeredComponents={props.registeredComponents}
867
870
  />;
868
- }}</For2></Show5>
869
- <Show5 when={!isEmptyHtmlElement(Tag()) && !repeatItem()}><Block_wrapper_default
870
- Wrapper={Tag()}
871
- block={processedBlock()}
872
- context={props.context}
873
- hasChildren={true}
874
- >
875
- <Component_ref_default
876
- componentRef={componentRefProps().componentRef}
877
- componentOptions={componentRefProps().componentOptions}
878
- blockChildren={componentRefProps().blockChildren}
879
- context={componentRefProps().context}
880
- registeredComponents={componentRefProps().registeredComponents}
881
- builderBlock={componentRefProps().builderBlock}
882
- includeBlockProps={componentRefProps().includeBlockProps}
883
- isInteractive={componentRefProps().isInteractive}
884
- />
885
- <For2 each={childrenWithoutParentComponent()}>{(child, _index) => {
886
- const index = _index();
887
- return <Block
888
- key={child.id}
889
- block={child}
890
- context={childrenContext()}
891
- registeredComponents={props.registeredComponents}
892
- />;
893
- }}</For2>
894
- </Block_wrapper_default></Show5>
895
- </Show5>
871
+ }}</For2>}
872
+ when={!repeatItem()}
873
+ ><Block_wrapper_default
874
+ Wrapper={Tag()}
875
+ block={processedBlock()}
876
+ context={props.context}
877
+ >
878
+ <Component_ref_default
879
+ componentRef={componentRefProps().componentRef}
880
+ componentOptions={componentRefProps().componentOptions}
881
+ blockChildren={componentRefProps().blockChildren}
882
+ context={componentRefProps().context}
883
+ registeredComponents={componentRefProps().registeredComponents}
884
+ builderBlock={componentRefProps().builderBlock}
885
+ includeBlockProps={componentRefProps().includeBlockProps}
886
+ isInteractive={componentRefProps().isInteractive}
887
+ />
888
+ <For2 each={childrenWithoutParentComponent()}>{(child, _index) => {
889
+ const index = _index();
890
+ return <Block
891
+ key={child.id}
892
+ block={child}
893
+ context={childrenContext()}
894
+ registeredComponents={props.registeredComponents}
895
+ />;
896
+ }}</For2>
897
+ </Block_wrapper_default></Show5></Show5>
896
898
  </Show5>;
897
899
  }
898
900
  var Block_default = Block;
@@ -2089,8 +2091,42 @@ var componentInfo8 = {
2089
2091
  }]
2090
2092
  };
2091
2093
 
2092
- // src/blocks/symbol/component-info.ts
2094
+ // src/blocks/slot/component-info.ts
2093
2095
  var componentInfo9 = {
2096
+ name: "Slot",
2097
+ isRSC: true,
2098
+ description: "Allow child blocks to be inserted into this content when used as a Symbol",
2099
+ docsLink: "https://www.builder.io/c/docs/symbols-with-blocks",
2100
+ image: "https://cdn.builder.io/api/v1/image/assets%2FYJIGb4i01jvw0SRdL5Bt%2F3aad6de36eae43b59b52c85190fdef56",
2101
+ // Maybe wrap this for canHaveChildren so bind children to this hm
2102
+ inputs: [{
2103
+ name: "name",
2104
+ type: "string",
2105
+ required: true,
2106
+ defaultValue: "children"
2107
+ }]
2108
+ };
2109
+
2110
+ // src/blocks/slot/slot.tsx
2111
+ function Slot(props) {
2112
+ return <div
2113
+ style={{
2114
+ "pointer-events": "auto"
2115
+ }}
2116
+ {...!props.builderContext.context?.symbolId && {
2117
+ "builder-slot": props.name
2118
+ }}
2119
+ ><Blocks_default
2120
+ parent={props.builderContext.context?.symbolId}
2121
+ path={`symbol.data.${props.name}`}
2122
+ context={props.builderContext}
2123
+ blocks={props.builderContext.rootState?.[props.name]}
2124
+ /></div>;
2125
+ }
2126
+ var slot_default = Slot;
2127
+
2128
+ // src/blocks/symbol/component-info.ts
2129
+ var componentInfo10 = {
2094
2130
  name: "Symbol",
2095
2131
  noWrap: true,
2096
2132
  static: true,
@@ -2126,7 +2162,7 @@ var componentInfo9 = {
2126
2162
  };
2127
2163
 
2128
2164
  // src/blocks/text/component-info.ts
2129
- var componentInfo10 = {
2165
+ var componentInfo11 = {
2130
2166
  name: "Text",
2131
2167
  static: true,
2132
2168
  isRSC: true,
@@ -2159,7 +2195,7 @@ function Text(props) {
2159
2195
  var text_default = Text;
2160
2196
 
2161
2197
  // src/blocks/video/component-info.ts
2162
- var componentInfo11 = {
2198
+ var componentInfo12 = {
2163
2199
  name: "Video",
2164
2200
  canHaveChildren: true,
2165
2201
  defaultStyles: {
@@ -2356,13 +2392,16 @@ var getDefaultRegisteredComponents = () => [{
2356
2392
  ...componentInfo8
2357
2393
  }, {
2358
2394
  component: symbol_default,
2359
- ...componentInfo9
2395
+ ...componentInfo10
2360
2396
  }, {
2361
2397
  component: text_default,
2362
- ...componentInfo10
2398
+ ...componentInfo11
2363
2399
  }, {
2364
2400
  component: video_default,
2365
- ...componentInfo11
2401
+ ...componentInfo12
2402
+ }, {
2403
+ component: slot_default,
2404
+ ...componentInfo9
2366
2405
  }];
2367
2406
 
2368
2407
  // src/functions/register-component.ts
@@ -2676,6 +2715,13 @@ async function fetchEntries(options) {
2676
2715
  }
2677
2716
  var getAllContent = fetchEntries;
2678
2717
 
2718
+ // src/functions/is-from-trusted-host.ts
2719
+ var DEFAULT_TRUSTED_HOSTS = ["*.beta.builder.io", "beta.builder.io", "builder.io", "localhost", "qa.builder.io"];
2720
+ function isFromTrustedHost(trustedHosts, e) {
2721
+ const url = new URL(e.origin), hostname = url.hostname;
2722
+ return (trustedHosts || DEFAULT_TRUSTED_HOSTS).findIndex((trustedHost) => trustedHost.startsWith("*.") ? hostname.endsWith(trustedHost.slice(1)) : trustedHost === hostname) > -1;
2723
+ }
2724
+
2679
2725
  // src/functions/is-previewing.ts
2680
2726
  function isPreviewing() {
2681
2727
  if (!isBrowser()) {
@@ -2924,7 +2970,7 @@ var getInteractionPropertiesForEvent = (event) => {
2924
2970
  };
2925
2971
 
2926
2972
  // src/constants/sdk-version.ts
2927
- var SDK_VERSION = "0.12.0";
2973
+ var SDK_VERSION = "0.12.2";
2928
2974
 
2929
2975
  // src/functions/register.ts
2930
2976
  var registry = {};
@@ -3001,9 +3047,13 @@ var setupBrowserForEditing = (options = {}) => {
3001
3047
  options
3002
3048
  }
3003
3049
  }, "*");
3004
- window.addEventListener("message", ({
3005
- data
3006
- }) => {
3050
+ window.addEventListener("message", (event) => {
3051
+ if (!isFromTrustedHost(options.trustedHosts, event)) {
3052
+ return;
3053
+ }
3054
+ const {
3055
+ data
3056
+ } = event;
3007
3057
  if (!data?.type) {
3008
3058
  return;
3009
3059
  }
@@ -3101,6 +3151,9 @@ function EnableEditor(props) {
3101
3151
  }));
3102
3152
  }
3103
3153
  function processMessage(event) {
3154
+ if (!isFromTrustedHost(props.trustedHosts, event)) {
3155
+ return;
3156
+ }
3104
3157
  const { data } = event;
3105
3158
  if (data) {
3106
3159
  switch (data.type) {
@@ -3231,6 +3284,9 @@ function EnableEditor(props) {
3231
3284
  } : {},
3232
3285
  ...props.enrich ? {
3233
3286
  enrich: props.enrich
3287
+ } : {},
3288
+ ...props.trustedHosts ? {
3289
+ trustedHosts: props.trustedHosts
3234
3290
  } : {}
3235
3291
  });
3236
3292
  Object.values(
@@ -3569,6 +3625,7 @@ function ContentComponent(props) {
3569
3625
  builderContextSignal={builderContextSignal()}
3570
3626
  contentWrapper={props.contentWrapper}
3571
3627
  contentWrapperProps={props.contentWrapperProps}
3628
+ trustedHosts={props.trustedHosts}
3572
3629
  {...{
3573
3630
  setBuilderContextSignal
3574
3631
  }}
@@ -3651,6 +3708,7 @@ function ContentVariants(props) {
3651
3708
  blocksWrapperProps={props.blocksWrapperProps}
3652
3709
  contentWrapper={props.contentWrapper}
3653
3710
  contentWrapperProps={props.contentWrapperProps}
3711
+ trustedHosts={props.trustedHosts}
3654
3712
  />;
3655
3713
  }}</For5>
3656
3714
  </Show12>
@@ -3673,6 +3731,7 @@ function ContentVariants(props) {
3673
3731
  blocksWrapperProps={props.blocksWrapperProps}
3674
3732
  contentWrapper={props.contentWrapper}
3675
3733
  contentWrapperProps={props.contentWrapperProps}
3734
+ trustedHosts={props.trustedHosts}
3676
3735
  />
3677
3736
  </>;
3678
3737
  }
@@ -3736,7 +3795,10 @@ function Symbol(props) {
3736
3795
  __isNestedRender={true}
3737
3796
  apiVersion={props.builderContext.apiVersion}
3738
3797
  apiKey={props.builderContext.apiKey}
3739
- context={props.builderContext.context}
3798
+ context={{
3799
+ ...props.builderContext.context,
3800
+ symbolId: props.builderBlock?.id
3801
+ }}
3740
3802
  customComponents={Object.values(props.builderComponents)}
3741
3803
  data={{
3742
3804
  ...props.symbol?.data,