@builder.io/sdk-qwik 0.12.1 → 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.
@@ -236,26 +236,6 @@ function getProcessedBlock({ block, context, shouldEvaluateBindings, localState,
236
236
  else
237
237
  return transformedBlock;
238
238
  }
239
- const EMPTY_HTML_ELEMENTS = [
240
- "area",
241
- "base",
242
- "br",
243
- "col",
244
- "embed",
245
- "hr",
246
- "img",
247
- "input",
248
- "keygen",
249
- "link",
250
- "meta",
251
- "param",
252
- "source",
253
- "track",
254
- "wbr"
255
- ];
256
- const isEmptyHtmlElement = (tagName) => {
257
- return typeof tagName === "string" && EMPTY_HTML_ELEMENTS.includes(tagName.toLowerCase());
258
- };
259
239
  const getComponent = ({ block, context, registeredComponents }) => {
260
240
  var _a;
261
241
  const componentName = (_a = getProcessedBlock({
@@ -540,38 +520,67 @@ function getStyleAttribute(style) {
540
520
  return style;
541
521
  }
542
522
  }
543
- const BlockWrapper = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((props) => {
523
+ const EMPTY_HTML_ELEMENTS = /* @__PURE__ */ new Set([
524
+ "area",
525
+ "base",
526
+ "br",
527
+ "col",
528
+ "embed",
529
+ "hr",
530
+ "img",
531
+ "input",
532
+ "keygen",
533
+ "link",
534
+ "meta",
535
+ "param",
536
+ "source",
537
+ "track",
538
+ "wbr"
539
+ ]);
540
+ const isEmptyElement = (tagName) => {
541
+ return typeof tagName === "string" && EMPTY_HTML_ELEMENTS.has(tagName.toLowerCase());
542
+ };
543
+ const DynamicRenderer = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((props) => {
544
544
  _jsxBranch();
545
545
  return /* @__PURE__ */ _jsxC(Fragment, {
546
- children: props.hasChildren ? /* @__PURE__ */ _jsxC(props.Wrapper, {
547
- ...getBlockProperties({
548
- block: props.block,
549
- context: props.context
550
- }),
551
- ...getBlockActions({
552
- block: props.block,
553
- rootState: props.context.rootState,
554
- rootSetState: props.context.rootSetState,
555
- localState: props.context.localState,
556
- context: props.context.context,
557
- stripPrefix: true
558
- }),
559
- children: /* @__PURE__ */ _jsxC(Slot$1, null, 3, "87_0")
560
- }, 0, "87_1") : /* @__PURE__ */ _jsxC(props.Wrapper, {
561
- ...getBlockProperties({
562
- block: props.block,
563
- context: props.context
564
- }),
565
- ...getBlockActions({
566
- block: props.block,
567
- rootState: props.context.rootState,
568
- rootSetState: props.context.rootSetState,
569
- localState: props.context.localState,
570
- context: props.context.context,
571
- stripPrefix: true
572
- })
573
- }, 0, "87_2")
574
- }, 1, "87_3");
546
+ children: !isEmptyElement(props.TagName) ? typeof props.TagName === "string" ? /* @__PURE__ */ _jsxC(props.TagName, {
547
+ ...props.attributes,
548
+ ...props.actionAttributes,
549
+ children: /* @__PURE__ */ _jsxC(Slot$1, null, 3, "yW_0")
550
+ }, 0, "yW_1") : /* @__PURE__ */ _jsxC(props.TagName, {
551
+ ...props.attributes,
552
+ ...props.actionAttributes,
553
+ children: /* @__PURE__ */ _jsxC(Slot$1, null, 3, "yW_2")
554
+ }, 0, "yW_3") : /* @__PURE__ */ _jsxC(props.TagName, {
555
+ ...props.attributes,
556
+ ...props.actionAttributes
557
+ }, 0, "yW_4")
558
+ }, 1, "yW_5");
559
+ }, "DynamicRenderer_component_1Co0xkmyAfQ"));
560
+ const BlockWrapper = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((props) => {
561
+ return /* @__PURE__ */ _jsxC(DynamicRenderer, {
562
+ get TagName() {
563
+ return props.Wrapper;
564
+ },
565
+ actionAttributes: getBlockActions({
566
+ block: props.block,
567
+ rootState: props.context.rootState,
568
+ rootSetState: props.context.rootSetState,
569
+ localState: props.context.localState,
570
+ context: props.context.context,
571
+ stripPrefix: true
572
+ }),
573
+ attributes: getBlockProperties({
574
+ block: props.block,
575
+ context: props.context
576
+ }),
577
+ children: /* @__PURE__ */ _jsxC(Slot$1, null, 3, "87_0"),
578
+ [_IMMUTABLE]: {
579
+ TagName: _fnSignal((p0) => p0.Wrapper, [
580
+ props
581
+ ], "p0.Wrapper")
582
+ }
583
+ }, 1, "87_1");
575
584
  }, "BlockWrapper_component_kOI0j0aW8Nw"));
576
585
  const InteractiveElement = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((props) => {
577
586
  return /* @__PURE__ */ _jsxC(props.Wrapper, {
@@ -795,151 +804,120 @@ const Block = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((props) =>
795
804
  ], "p0.context")
796
805
  }
797
806
  }, 3, "jN_0"),
798
- !((_a = blockComponent.value) == null ? void 0 : _a.noWrap) ? /* @__PURE__ */ _jsxC(Fragment, {
807
+ !((_a = blockComponent.value) == null ? void 0 : _a.noWrap) ? !repeatItem.value ? /* @__PURE__ */ _jsxC(BlockWrapper, {
808
+ get Wrapper() {
809
+ return Tag.value;
810
+ },
811
+ get block() {
812
+ return processedBlock.value;
813
+ },
814
+ get context() {
815
+ return props.context;
816
+ },
799
817
  children: [
800
- isEmptyHtmlElement(Tag.value) ? /* @__PURE__ */ _jsxC(BlockWrapper, {
801
- get Wrapper() {
802
- return Tag.value;
818
+ /* @__PURE__ */ _jsxC(ComponentRef, {
819
+ get componentRef() {
820
+ return componentRefProps.value.componentRef;
821
+ },
822
+ get componentOptions() {
823
+ return componentRefProps.value.componentOptions;
803
824
  },
804
- get block() {
805
- return processedBlock.value;
825
+ get blockChildren() {
826
+ return componentRefProps.value.blockChildren;
806
827
  },
807
828
  get context() {
808
- return props.context;
829
+ return componentRefProps.value.context;
830
+ },
831
+ get registeredComponents() {
832
+ return componentRefProps.value.registeredComponents;
833
+ },
834
+ get builderBlock() {
835
+ return componentRefProps.value.builderBlock;
836
+ },
837
+ get includeBlockProps() {
838
+ return componentRefProps.value.includeBlockProps;
839
+ },
840
+ get isInteractive() {
841
+ return componentRefProps.value.isInteractive;
809
842
  },
810
- hasChildren: false,
811
843
  [_IMMUTABLE]: {
812
- Wrapper: _fnSignal((p0) => p0.value, [
813
- Tag
814
- ], "p0.value"),
815
- block: _fnSignal((p0) => p0.value, [
816
- processedBlock
817
- ], "p0.value"),
818
- context: _fnSignal((p0) => p0.context, [
819
- props
820
- ], "p0.context"),
821
- hasChildren: _IMMUTABLE
844
+ blockChildren: _fnSignal((p0) => p0.value.blockChildren, [
845
+ componentRefProps
846
+ ], "p0.value.blockChildren"),
847
+ builderBlock: _fnSignal((p0) => p0.value.builderBlock, [
848
+ componentRefProps
849
+ ], "p0.value.builderBlock"),
850
+ componentOptions: _fnSignal((p0) => p0.value.componentOptions, [
851
+ componentRefProps
852
+ ], "p0.value.componentOptions"),
853
+ componentRef: _fnSignal((p0) => p0.value.componentRef, [
854
+ componentRefProps
855
+ ], "p0.value.componentRef"),
856
+ context: _fnSignal((p0) => p0.value.context, [
857
+ componentRefProps
858
+ ], "p0.value.context"),
859
+ includeBlockProps: _fnSignal((p0) => p0.value.includeBlockProps, [
860
+ componentRefProps
861
+ ], "p0.value.includeBlockProps"),
862
+ isInteractive: _fnSignal((p0) => p0.value.isInteractive, [
863
+ componentRefProps
864
+ ], "p0.value.isInteractive"),
865
+ registeredComponents: _fnSignal((p0) => p0.value.registeredComponents, [
866
+ componentRefProps
867
+ ], "p0.value.registeredComponents")
822
868
  }
823
- }, 3, "jN_1") : null,
824
- !isEmptyHtmlElement(Tag.value) && repeatItem.value ? (repeatItem.value || []).map((data, index) => {
825
- return /* @__PURE__ */ _jsxC(RepeatedBlock, {
826
- get repeatContext() {
827
- return data.context;
828
- },
829
- get block() {
830
- return data.block;
869
+ }, 3, "jN_1"),
870
+ (childrenWithoutParentComponent.value || []).map((child) => {
871
+ return /* @__PURE__ */ _jsxC(Block, {
872
+ block: child,
873
+ get context() {
874
+ return state.childrenContext;
831
875
  },
832
876
  get registeredComponents() {
833
877
  return props.registeredComponents;
834
878
  },
835
879
  [_IMMUTABLE]: {
836
- block: _wrapProp(data, "block"),
880
+ context: _fnSignal((p0) => p0.childrenContext, [
881
+ state
882
+ ], "p0.childrenContext"),
837
883
  registeredComponents: _fnSignal((p0) => p0.registeredComponents, [
838
884
  props
839
- ], "p0.registeredComponents"),
840
- repeatContext: _wrapProp(data, "context")
885
+ ], "p0.registeredComponents")
841
886
  }
842
- }, 3, index);
843
- }) : null,
844
- !isEmptyHtmlElement(Tag.value) && !repeatItem.value ? /* @__PURE__ */ _jsxC(BlockWrapper, {
845
- get Wrapper() {
846
- return Tag.value;
847
- },
848
- get block() {
849
- return processedBlock.value;
850
- },
851
- get context() {
852
- return props.context;
853
- },
854
- children: [
855
- /* @__PURE__ */ _jsxC(ComponentRef, {
856
- get componentRef() {
857
- return componentRefProps.value.componentRef;
858
- },
859
- get componentOptions() {
860
- return componentRefProps.value.componentOptions;
861
- },
862
- get blockChildren() {
863
- return componentRefProps.value.blockChildren;
864
- },
865
- get context() {
866
- return componentRefProps.value.context;
867
- },
868
- get registeredComponents() {
869
- return componentRefProps.value.registeredComponents;
870
- },
871
- get builderBlock() {
872
- return componentRefProps.value.builderBlock;
873
- },
874
- get includeBlockProps() {
875
- return componentRefProps.value.includeBlockProps;
876
- },
877
- get isInteractive() {
878
- return componentRefProps.value.isInteractive;
879
- },
880
- [_IMMUTABLE]: {
881
- blockChildren: _fnSignal((p0) => p0.value.blockChildren, [
882
- componentRefProps
883
- ], "p0.value.blockChildren"),
884
- builderBlock: _fnSignal((p0) => p0.value.builderBlock, [
885
- componentRefProps
886
- ], "p0.value.builderBlock"),
887
- componentOptions: _fnSignal((p0) => p0.value.componentOptions, [
888
- componentRefProps
889
- ], "p0.value.componentOptions"),
890
- componentRef: _fnSignal((p0) => p0.value.componentRef, [
891
- componentRefProps
892
- ], "p0.value.componentRef"),
893
- context: _fnSignal((p0) => p0.value.context, [
894
- componentRefProps
895
- ], "p0.value.context"),
896
- includeBlockProps: _fnSignal((p0) => p0.value.includeBlockProps, [
897
- componentRefProps
898
- ], "p0.value.includeBlockProps"),
899
- isInteractive: _fnSignal((p0) => p0.value.isInteractive, [
900
- componentRefProps
901
- ], "p0.value.isInteractive"),
902
- registeredComponents: _fnSignal((p0) => p0.value.registeredComponents, [
903
- componentRefProps
904
- ], "p0.value.registeredComponents")
905
- }
906
- }, 3, "jN_2"),
907
- (childrenWithoutParentComponent.value || []).map((child) => {
908
- return /* @__PURE__ */ _jsxC(Block, {
909
- block: child,
910
- get context() {
911
- return state.childrenContext;
912
- },
913
- get registeredComponents() {
914
- return props.registeredComponents;
915
- },
916
- [_IMMUTABLE]: {
917
- context: _fnSignal((p0) => p0.childrenContext, [
918
- state
919
- ], "p0.childrenContext"),
920
- registeredComponents: _fnSignal((p0) => p0.registeredComponents, [
921
- props
922
- ], "p0.registeredComponents")
923
- }
924
- }, 3, child.id);
925
- })
926
- ],
927
- hasChildren: true,
928
- [_IMMUTABLE]: {
929
- Wrapper: _fnSignal((p0) => p0.value, [
930
- Tag
931
- ], "p0.value"),
932
- block: _fnSignal((p0) => p0.value, [
933
- processedBlock
934
- ], "p0.value"),
935
- context: _fnSignal((p0) => p0.context, [
936
- props
937
- ], "p0.context"),
938
- hasChildren: _IMMUTABLE
939
- }
940
- }, 1, "jN_3") : null
941
- ]
942
- }, 1, "jN_4") : /* @__PURE__ */ _jsxC(ComponentRef, {
887
+ }, 3, child.id);
888
+ })
889
+ ],
890
+ [_IMMUTABLE]: {
891
+ Wrapper: _fnSignal((p0) => p0.value, [
892
+ Tag
893
+ ], "p0.value"),
894
+ block: _fnSignal((p0) => p0.value, [
895
+ processedBlock
896
+ ], "p0.value"),
897
+ context: _fnSignal((p0) => p0.context, [
898
+ props
899
+ ], "p0.context")
900
+ }
901
+ }, 1, "jN_2") : (repeatItem.value || []).map((data, index) => {
902
+ return /* @__PURE__ */ _jsxC(RepeatedBlock, {
903
+ get repeatContext() {
904
+ return data.context;
905
+ },
906
+ get block() {
907
+ return data.block;
908
+ },
909
+ get registeredComponents() {
910
+ return props.registeredComponents;
911
+ },
912
+ [_IMMUTABLE]: {
913
+ block: _wrapProp(data, "block"),
914
+ registeredComponents: _fnSignal((p0) => p0.registeredComponents, [
915
+ props
916
+ ], "p0.registeredComponents"),
917
+ repeatContext: _wrapProp(data, "context")
918
+ }
919
+ }, 3, index);
920
+ }) : /* @__PURE__ */ _jsxC(ComponentRef, {
943
921
  get componentRef() {
944
922
  return componentRefProps.value.componentRef;
945
923
  },
@@ -990,10 +968,10 @@ const Block = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((props) =>
990
968
  componentRefProps
991
969
  ], "p0.value.registeredComponents")
992
970
  }
993
- }, 3, "jN_5")
971
+ }, 3, "jN_3")
994
972
  ]
995
- }, 1, "jN_6") : null
996
- }, 1, "jN_7");
973
+ }, 1, "jN_4") : null
974
+ }, 1, "jN_5");
997
975
  }, "Block_component_nnPv0RY0U0k"));
998
976
  const onClick$1 = function onClick2(props, state) {
999
977
  var _a, _b;
@@ -3040,6 +3018,17 @@ async function fetchEntries(options) {
3040
3018
  }
3041
3019
  }
3042
3020
  const getAllContent = fetchEntries;
3021
+ const DEFAULT_TRUSTED_HOSTS = [
3022
+ "*.beta.builder.io",
3023
+ "beta.builder.io",
3024
+ "builder.io",
3025
+ "localhost",
3026
+ "qa.builder.io"
3027
+ ];
3028
+ function isFromTrustedHost(trustedHosts, e) {
3029
+ const url = new URL(e.origin), hostname = url.hostname;
3030
+ return (trustedHosts || DEFAULT_TRUSTED_HOSTS).findIndex((trustedHost) => trustedHost.startsWith("*.") ? hostname.endsWith(trustedHost.slice(1)) : trustedHost === hostname) > -1;
3031
+ }
3043
3032
  function isPreviewing() {
3044
3033
  if (!isBrowser())
3045
3034
  return false;
@@ -3239,7 +3228,7 @@ const getInteractionPropertiesForEvent = (event) => {
3239
3228
  }
3240
3229
  };
3241
3230
  };
3242
- const SDK_VERSION = "0.12.1";
3231
+ const SDK_VERSION = "0.12.2";
3243
3232
  const registry = {};
3244
3233
  function register(type, info) {
3245
3234
  let typeList = registry[type];
@@ -3322,8 +3311,11 @@ const setupBrowserForEditing = (options = {}) => {
3322
3311
  options
3323
3312
  }
3324
3313
  }, "*");
3325
- window.addEventListener("message", ({ data }) => {
3314
+ window.addEventListener("message", (event) => {
3326
3315
  var _a2, _b2;
3316
+ if (!isFromTrustedHost(options.trustedHosts, event))
3317
+ return;
3318
+ const { data } = event;
3327
3319
  if (!(data == null ? void 0 : data.type))
3328
3320
  return;
3329
3321
  switch (data.type) {
@@ -3402,6 +3394,8 @@ const mergeNewContent = function mergeNewContent2(props, state, elementRef, newC
3402
3394
  };
3403
3395
  const processMessage = function processMessage2(props, state, elementRef, event) {
3404
3396
  var _a;
3397
+ if (!isFromTrustedHost(props.trustedHosts, event))
3398
+ return;
3405
3399
  const { data } = event;
3406
3400
  if (data)
3407
3401
  switch (data.type) {
@@ -3536,6 +3530,9 @@ const EnableEditor = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((pr
3536
3530
  } : {},
3537
3531
  ...props2.enrich ? {
3538
3532
  enrich: props2.enrich
3533
+ } : {},
3534
+ ...props2.trustedHosts ? {
3535
+ trustedHosts: props2.trustedHosts
3539
3536
  } : {}
3540
3537
  });
3541
3538
  Object.values(props2.builderContextSignal.componentInfos).forEach((registeredComponent) => {
@@ -3914,6 +3911,9 @@ const ContentComponent = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl
3914
3911
  get contentWrapperProps() {
3915
3912
  return props.contentWrapperProps;
3916
3913
  },
3914
+ get trustedHosts() {
3915
+ return props.trustedHosts;
3916
+ },
3917
3917
  children: [
3918
3918
  props.isSsrAbTest ? /* @__PURE__ */ _jsxC(InlinedScript, {
3919
3919
  get scriptStr() {
@@ -4025,7 +4025,10 @@ const ContentComponent = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl
4025
4025
  ], "p0.model"),
4026
4026
  showContent: _fnSignal((p0) => p0.showContent, [
4027
4027
  props
4028
- ], "p0.showContent")
4028
+ ], "p0.showContent"),
4029
+ trustedHosts: _fnSignal((p0) => p0.trustedHosts, [
4030
+ props
4031
+ ], "p0.trustedHosts")
4029
4032
  }
4030
4033
  }, 1, "LQ_3");
4031
4034
  }, "ContentComponent_component_HIsczUcxjCE"));
@@ -4158,6 +4161,9 @@ const ContentVariants = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl(
4158
4161
  get contentWrapperProps() {
4159
4162
  return props.contentWrapperProps;
4160
4163
  },
4164
+ get trustedHosts() {
4165
+ return props.trustedHosts;
4166
+ },
4161
4167
  [_IMMUTABLE]: {
4162
4168
  apiKey: _fnSignal((p0) => p0.apiKey, [
4163
4169
  props
@@ -4204,7 +4210,10 @@ const ContentVariants = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl(
4204
4210
  model: _fnSignal((p0) => p0.model, [
4205
4211
  props
4206
4212
  ], "p0.model"),
4207
- showContent: _IMMUTABLE
4213
+ showContent: _IMMUTABLE,
4214
+ trustedHosts: _fnSignal((p0) => p0.trustedHosts, [
4215
+ props
4216
+ ], "p0.trustedHosts")
4208
4217
  }
4209
4218
  }, 3, variant.testVariationId);
4210
4219
  })
@@ -4260,6 +4269,9 @@ const ContentVariants = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl(
4260
4269
  get contentWrapperProps() {
4261
4270
  return props.contentWrapperProps;
4262
4271
  },
4272
+ get trustedHosts() {
4273
+ return props.trustedHosts;
4274
+ },
4263
4275
  [_IMMUTABLE]: {
4264
4276
  apiKey: _fnSignal((p0) => p0.apiKey, [
4265
4277
  props
@@ -4309,7 +4321,10 @@ const ContentVariants = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl(
4309
4321
  model: _fnSignal((p0) => p0.model, [
4310
4322
  props
4311
4323
  ], "p0.model"),
4312
- showContent: _IMMUTABLE
4324
+ showContent: _IMMUTABLE,
4325
+ trustedHosts: _fnSignal((p0) => p0.trustedHosts, [
4326
+ props
4327
+ ], "p0.trustedHosts")
4313
4328
  }
4314
4329
  }, 3, "XM_4")
4315
4330
  ]