@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.
@@ -325,10 +325,6 @@ function getProcessedBlock({
325
325
  }
326
326
 
327
327
  // src/components/block/block.helpers.ts
328
- var EMPTY_HTML_ELEMENTS = ["area", "base", "br", "col", "embed", "hr", "img", "input", "keygen", "link", "meta", "param", "source", "track", "wbr"];
329
- var isEmptyHtmlElement = (tagName) => {
330
- return typeof tagName === "string" && EMPTY_HTML_ELEMENTS.includes(tagName.toLowerCase());
331
- };
332
328
  var getComponent = ({
333
329
  block,
334
330
  context,
@@ -553,10 +549,6 @@ function BlockStyles(props) {
553
549
  }
554
550
  var Block_styles_default = BlockStyles;
555
551
 
556
- // src/components/block/components/block-wrapper.tsx
557
- import { Show as Show3 } from "solid-js";
558
- import { Dynamic } from "solid-js/web";
559
-
560
552
  // src/functions/event-handler-name.ts
561
553
  function capitalizeFirstLetter(string) {
562
554
  return string.charAt(0).toUpperCase() + string.slice(1);
@@ -643,31 +635,49 @@ function getStyleAttribute(style) {
643
635
  }
644
636
  }
645
637
 
646
- // src/components/block/components/block-wrapper.tsx
647
- function BlockWrapper(props) {
638
+ // src/components/dynamic-renderer/dynamic-renderer.tsx
639
+ import { Show as Show3 } from "solid-js";
640
+ import { Dynamic } from "solid-js/web";
641
+
642
+ // src/components/dynamic-renderer/dynamic-renderer.helpers.ts
643
+ var EMPTY_HTML_ELEMENTS = /* @__PURE__ */ new Set(["area", "base", "br", "col", "embed", "hr", "img", "input", "keygen", "link", "meta", "param", "source", "track", "wbr"]);
644
+ var isEmptyElement = (tagName) => {
645
+ return typeof tagName === "string" && EMPTY_HTML_ELEMENTS.has(tagName.toLowerCase());
646
+ };
647
+
648
+ // src/components/dynamic-renderer/dynamic-renderer.tsx
649
+ function DynamicRenderer(props) {
648
650
  return <Show3
649
651
  fallback={<Dynamic
650
- {...getBlockProperties({
651
- block: props.block,
652
- context: props.context
653
- })}
654
- {...getBlockActions({
655
- block: props.block,
656
- rootState: props.context.rootState,
657
- rootSetState: props.context.rootSetState,
658
- localState: props.context.localState,
659
- context: props.context.context,
660
- stripPrefix: true
661
- })}
662
- component={props.Wrapper}
652
+ {...props.attributes}
653
+ {...props.actionAttributes}
654
+ component={props.TagName}
663
655
  />}
664
- when={props.hasChildren}
656
+ when={!isEmptyElement(props.TagName)}
657
+ ><Show3
658
+ fallback={<Dynamic
659
+ {...props.attributes}
660
+ {...props.actionAttributes}
661
+ component={props.TagName}
662
+ >{props.children}</Dynamic>}
663
+ when={typeof props.TagName === "string"}
665
664
  ><Dynamic
666
- {...getBlockProperties({
665
+ {...props.attributes}
666
+ {...props.actionAttributes}
667
+ component={props.TagName}
668
+ >{props.children}</Dynamic></Show3></Show3>;
669
+ }
670
+ var Dynamic_renderer_default = DynamicRenderer;
671
+
672
+ // src/components/block/components/block-wrapper.tsx
673
+ function BlockWrapper(props) {
674
+ return <Dynamic_renderer_default
675
+ TagName={props.Wrapper}
676
+ attributes={getBlockProperties({
667
677
  block: props.block,
668
678
  context: props.context
669
679
  })}
670
- {...getBlockActions({
680
+ actionAttributes={getBlockActions({
671
681
  block: props.block,
672
682
  rootState: props.context.rootState,
673
683
  rootSetState: props.context.rootSetState,
@@ -675,8 +685,7 @@ function BlockWrapper(props) {
675
685
  context: props.context.context,
676
686
  stripPrefix: true
677
687
  })}
678
- component={props.Wrapper}
679
- >{props.children}</Dynamic></Show3>;
688
+ >{props.children}</Dynamic_renderer_default>;
680
689
  }
681
690
  var Block_wrapper_default = BlockWrapper;
682
691
 
@@ -855,14 +864,8 @@ function Block(props) {
855
864
  isInteractive={componentRefProps().isInteractive}
856
865
  />}
857
866
  when={!blockComponent()?.noWrap}
858
- >
859
- <Show5 when={isEmptyHtmlElement(Tag())}><Block_wrapper_default
860
- Wrapper={Tag()}
861
- block={processedBlock()}
862
- context={props.context}
863
- hasChildren={false}
864
- /></Show5>
865
- <Show5 when={!isEmptyHtmlElement(Tag()) && repeatItem()}><For2 each={repeatItem()}>{(data, _index) => {
867
+ ><Show5
868
+ fallback={<For2 each={repeatItem()}>{(data, _index) => {
866
869
  const index = _index();
867
870
  return <Repeated_block_default
868
871
  key={index}
@@ -870,34 +873,33 @@ function Block(props) {
870
873
  block={data.block}
871
874
  registeredComponents={props.registeredComponents}
872
875
  />;
873
- }}</For2></Show5>
874
- <Show5 when={!isEmptyHtmlElement(Tag()) && !repeatItem()}><Block_wrapper_default
875
- Wrapper={Tag()}
876
- block={processedBlock()}
877
- context={props.context}
878
- hasChildren={true}
879
- >
880
- <Component_ref_default
881
- componentRef={componentRefProps().componentRef}
882
- componentOptions={componentRefProps().componentOptions}
883
- blockChildren={componentRefProps().blockChildren}
884
- context={componentRefProps().context}
885
- registeredComponents={componentRefProps().registeredComponents}
886
- builderBlock={componentRefProps().builderBlock}
887
- includeBlockProps={componentRefProps().includeBlockProps}
888
- isInteractive={componentRefProps().isInteractive}
889
- />
890
- <For2 each={childrenWithoutParentComponent()}>{(child, _index) => {
891
- const index = _index();
892
- return <Block
893
- key={child.id}
894
- block={child}
895
- context={childrenContext()}
896
- registeredComponents={props.registeredComponents}
897
- />;
898
- }}</For2>
899
- </Block_wrapper_default></Show5>
900
- </Show5>
876
+ }}</For2>}
877
+ when={!repeatItem()}
878
+ ><Block_wrapper_default
879
+ Wrapper={Tag()}
880
+ block={processedBlock()}
881
+ context={props.context}
882
+ >
883
+ <Component_ref_default
884
+ componentRef={componentRefProps().componentRef}
885
+ componentOptions={componentRefProps().componentOptions}
886
+ blockChildren={componentRefProps().blockChildren}
887
+ context={componentRefProps().context}
888
+ registeredComponents={componentRefProps().registeredComponents}
889
+ builderBlock={componentRefProps().builderBlock}
890
+ includeBlockProps={componentRefProps().includeBlockProps}
891
+ isInteractive={componentRefProps().isInteractive}
892
+ />
893
+ <For2 each={childrenWithoutParentComponent()}>{(child, _index) => {
894
+ const index = _index();
895
+ return <Block
896
+ key={child.id}
897
+ block={child}
898
+ context={childrenContext()}
899
+ registeredComponents={props.registeredComponents}
900
+ />;
901
+ }}</For2>
902
+ </Block_wrapper_default></Show5></Show5>
901
903
  </Show5>;
902
904
  }
903
905
  var Block_default = Block;
@@ -2098,8 +2100,42 @@ var componentInfo8 = {
2098
2100
  }]
2099
2101
  };
2100
2102
 
2101
- // src/blocks/symbol/component-info.ts
2103
+ // src/blocks/slot/component-info.ts
2102
2104
  var componentInfo9 = {
2105
+ name: "Slot",
2106
+ isRSC: true,
2107
+ description: "Allow child blocks to be inserted into this content when used as a Symbol",
2108
+ docsLink: "https://www.builder.io/c/docs/symbols-with-blocks",
2109
+ image: "https://cdn.builder.io/api/v1/image/assets%2FYJIGb4i01jvw0SRdL5Bt%2F3aad6de36eae43b59b52c85190fdef56",
2110
+ // Maybe wrap this for canHaveChildren so bind children to this hm
2111
+ inputs: [{
2112
+ name: "name",
2113
+ type: "string",
2114
+ required: true,
2115
+ defaultValue: "children"
2116
+ }]
2117
+ };
2118
+
2119
+ // src/blocks/slot/slot.tsx
2120
+ function Slot(props) {
2121
+ return <div
2122
+ style={{
2123
+ "pointer-events": "auto"
2124
+ }}
2125
+ {...!props.builderContext.context?.symbolId && {
2126
+ "builder-slot": props.name
2127
+ }}
2128
+ ><Blocks_default
2129
+ parent={props.builderContext.context?.symbolId}
2130
+ path={`symbol.data.${props.name}`}
2131
+ context={props.builderContext}
2132
+ blocks={props.builderContext.rootState?.[props.name]}
2133
+ /></div>;
2134
+ }
2135
+ var slot_default = Slot;
2136
+
2137
+ // src/blocks/symbol/component-info.ts
2138
+ var componentInfo10 = {
2103
2139
  name: "Symbol",
2104
2140
  noWrap: true,
2105
2141
  static: true,
@@ -2135,7 +2171,7 @@ var componentInfo9 = {
2135
2171
  };
2136
2172
 
2137
2173
  // src/blocks/text/component-info.ts
2138
- var componentInfo10 = {
2174
+ var componentInfo11 = {
2139
2175
  name: "Text",
2140
2176
  static: true,
2141
2177
  isRSC: true,
@@ -2168,7 +2204,7 @@ function Text(props) {
2168
2204
  var text_default = Text;
2169
2205
 
2170
2206
  // src/blocks/video/component-info.ts
2171
- var componentInfo11 = {
2207
+ var componentInfo12 = {
2172
2208
  name: "Video",
2173
2209
  canHaveChildren: true,
2174
2210
  defaultStyles: {
@@ -2365,13 +2401,16 @@ var getDefaultRegisteredComponents = () => [{
2365
2401
  ...componentInfo8
2366
2402
  }, {
2367
2403
  component: symbol_default,
2368
- ...componentInfo9
2404
+ ...componentInfo10
2369
2405
  }, {
2370
2406
  component: text_default,
2371
- ...componentInfo10
2407
+ ...componentInfo11
2372
2408
  }, {
2373
2409
  component: video_default,
2374
- ...componentInfo11
2410
+ ...componentInfo12
2411
+ }, {
2412
+ component: slot_default,
2413
+ ...componentInfo9
2375
2414
  }];
2376
2415
 
2377
2416
  // src/functions/register-component.ts
@@ -2687,6 +2726,13 @@ async function fetchEntries(options) {
2687
2726
  }
2688
2727
  var getAllContent = fetchEntries;
2689
2728
 
2729
+ // src/functions/is-from-trusted-host.ts
2730
+ var DEFAULT_TRUSTED_HOSTS = ["*.beta.builder.io", "beta.builder.io", "builder.io", "localhost", "qa.builder.io"];
2731
+ function isFromTrustedHost(trustedHosts, e) {
2732
+ const url = new URL(e.origin), hostname = url.hostname;
2733
+ return (trustedHosts || DEFAULT_TRUSTED_HOSTS).findIndex((trustedHost) => trustedHost.startsWith("*.") ? hostname.endsWith(trustedHost.slice(1)) : trustedHost === hostname) > -1;
2734
+ }
2735
+
2690
2736
  // src/functions/is-previewing.ts
2691
2737
  function isPreviewing() {
2692
2738
  if (!isBrowser()) {
@@ -2938,7 +2984,7 @@ var getInteractionPropertiesForEvent = (event) => {
2938
2984
  };
2939
2985
 
2940
2986
  // src/constants/sdk-version.ts
2941
- var SDK_VERSION = "0.12.0";
2987
+ var SDK_VERSION = "0.12.2";
2942
2988
 
2943
2989
  // src/functions/register.ts
2944
2990
  var registry = {};
@@ -3016,9 +3062,13 @@ var setupBrowserForEditing = (options = {}) => {
3016
3062
  options
3017
3063
  }
3018
3064
  }, "*");
3019
- window.addEventListener("message", ({
3020
- data
3021
- }) => {
3065
+ window.addEventListener("message", (event) => {
3066
+ if (!isFromTrustedHost(options.trustedHosts, event)) {
3067
+ return;
3068
+ }
3069
+ const {
3070
+ data
3071
+ } = event;
3022
3072
  if (!data?.type) {
3023
3073
  return;
3024
3074
  }
@@ -3116,6 +3166,9 @@ function EnableEditor(props) {
3116
3166
  }));
3117
3167
  }
3118
3168
  function processMessage(event) {
3169
+ if (!isFromTrustedHost(props.trustedHosts, event)) {
3170
+ return;
3171
+ }
3119
3172
  const { data } = event;
3120
3173
  if (data) {
3121
3174
  switch (data.type) {
@@ -3247,6 +3300,9 @@ function EnableEditor(props) {
3247
3300
  } : {},
3248
3301
  ...props.enrich ? {
3249
3302
  enrich: props.enrich
3303
+ } : {},
3304
+ ...props.trustedHosts ? {
3305
+ trustedHosts: props.trustedHosts
3250
3306
  } : {}
3251
3307
  });
3252
3308
  Object.values(
@@ -3585,6 +3641,7 @@ function ContentComponent(props) {
3585
3641
  builderContextSignal={builderContextSignal()}
3586
3642
  contentWrapper={props.contentWrapper}
3587
3643
  contentWrapperProps={props.contentWrapperProps}
3644
+ trustedHosts={props.trustedHosts}
3588
3645
  {...{
3589
3646
  setBuilderContextSignal
3590
3647
  }}
@@ -3667,6 +3724,7 @@ function ContentVariants(props) {
3667
3724
  blocksWrapperProps={props.blocksWrapperProps}
3668
3725
  contentWrapper={props.contentWrapper}
3669
3726
  contentWrapperProps={props.contentWrapperProps}
3727
+ trustedHosts={props.trustedHosts}
3670
3728
  />;
3671
3729
  }}</For5>
3672
3730
  </Show12>
@@ -3689,6 +3747,7 @@ function ContentVariants(props) {
3689
3747
  blocksWrapperProps={props.blocksWrapperProps}
3690
3748
  contentWrapper={props.contentWrapper}
3691
3749
  contentWrapperProps={props.contentWrapperProps}
3750
+ trustedHosts={props.trustedHosts}
3692
3751
  />
3693
3752
  </>;
3694
3753
  }
@@ -3752,7 +3811,10 @@ function Symbol(props) {
3752
3811
  __isNestedRender={true}
3753
3812
  apiVersion={props.builderContext.apiVersion}
3754
3813
  apiKey={props.builderContext.apiKey}
3755
- context={props.builderContext.context}
3814
+ context={{
3815
+ ...props.builderContext.context,
3816
+ symbolId: props.builderBlock?.id
3817
+ }}
3756
3818
  customComponents={Object.values(props.builderComponents)}
3757
3819
  data={{
3758
3820
  ...props.symbol?.data,