@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.
@@ -339,26 +339,6 @@ function getProcessedBlock({ block, context, shouldEvaluateBindings, localState,
339
339
  else
340
340
  return transformedBlock;
341
341
  }
342
- const EMPTY_HTML_ELEMENTS = [
343
- "area",
344
- "base",
345
- "br",
346
- "col",
347
- "embed",
348
- "hr",
349
- "img",
350
- "input",
351
- "keygen",
352
- "link",
353
- "meta",
354
- "param",
355
- "source",
356
- "track",
357
- "wbr"
358
- ];
359
- const isEmptyHtmlElement = (tagName) => {
360
- return typeof tagName === "string" && EMPTY_HTML_ELEMENTS.includes(tagName.toLowerCase());
361
- };
362
342
  const getComponent = ({ block, context, registeredComponents }) => {
363
343
  var _a;
364
344
  const componentName = (_a = getProcessedBlock({
@@ -643,38 +623,67 @@ function getStyleAttribute(style) {
643
623
  return style;
644
624
  }
645
625
  }
646
- const BlockWrapper = /* @__PURE__ */ qwik.componentQrl(/* @__PURE__ */ qwik.inlinedQrl((props) => {
626
+ const EMPTY_HTML_ELEMENTS = /* @__PURE__ */ new Set([
627
+ "area",
628
+ "base",
629
+ "br",
630
+ "col",
631
+ "embed",
632
+ "hr",
633
+ "img",
634
+ "input",
635
+ "keygen",
636
+ "link",
637
+ "meta",
638
+ "param",
639
+ "source",
640
+ "track",
641
+ "wbr"
642
+ ]);
643
+ const isEmptyElement = (tagName) => {
644
+ return typeof tagName === "string" && EMPTY_HTML_ELEMENTS.has(tagName.toLowerCase());
645
+ };
646
+ const DynamicRenderer = /* @__PURE__ */ qwik.componentQrl(/* @__PURE__ */ qwik.inlinedQrl((props) => {
647
647
  qwik._jsxBranch();
648
648
  return /* @__PURE__ */ qwik._jsxC(jsxRuntime.Fragment, {
649
- children: props.hasChildren ? /* @__PURE__ */ qwik._jsxC(props.Wrapper, {
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
- children: /* @__PURE__ */ qwik._jsxC(qwik.Slot, null, 3, "87_0")
663
- }, 0, "87_1") : /* @__PURE__ */ qwik._jsxC(props.Wrapper, {
664
- ...getBlockProperties({
665
- block: props.block,
666
- context: props.context
667
- }),
668
- ...getBlockActions({
669
- block: props.block,
670
- rootState: props.context.rootState,
671
- rootSetState: props.context.rootSetState,
672
- localState: props.context.localState,
673
- context: props.context.context,
674
- stripPrefix: true
675
- })
676
- }, 0, "87_2")
677
- }, 1, "87_3");
649
+ children: !isEmptyElement(props.TagName) ? typeof props.TagName === "string" ? /* @__PURE__ */ qwik._jsxC(props.TagName, {
650
+ ...props.attributes,
651
+ ...props.actionAttributes,
652
+ children: /* @__PURE__ */ qwik._jsxC(qwik.Slot, null, 3, "yW_0")
653
+ }, 0, "yW_1") : /* @__PURE__ */ qwik._jsxC(props.TagName, {
654
+ ...props.attributes,
655
+ ...props.actionAttributes,
656
+ children: /* @__PURE__ */ qwik._jsxC(qwik.Slot, null, 3, "yW_2")
657
+ }, 0, "yW_3") : /* @__PURE__ */ qwik._jsxC(props.TagName, {
658
+ ...props.attributes,
659
+ ...props.actionAttributes
660
+ }, 0, "yW_4")
661
+ }, 1, "yW_5");
662
+ }, "DynamicRenderer_component_1Co0xkmyAfQ"));
663
+ const BlockWrapper = /* @__PURE__ */ qwik.componentQrl(/* @__PURE__ */ qwik.inlinedQrl((props) => {
664
+ return /* @__PURE__ */ qwik._jsxC(DynamicRenderer, {
665
+ get TagName() {
666
+ return props.Wrapper;
667
+ },
668
+ actionAttributes: getBlockActions({
669
+ block: props.block,
670
+ rootState: props.context.rootState,
671
+ rootSetState: props.context.rootSetState,
672
+ localState: props.context.localState,
673
+ context: props.context.context,
674
+ stripPrefix: true
675
+ }),
676
+ attributes: getBlockProperties({
677
+ block: props.block,
678
+ context: props.context
679
+ }),
680
+ children: /* @__PURE__ */ qwik._jsxC(qwik.Slot, null, 3, "87_0"),
681
+ [qwik._IMMUTABLE]: {
682
+ TagName: qwik._fnSignal((p0) => p0.Wrapper, [
683
+ props
684
+ ], "p0.Wrapper")
685
+ }
686
+ }, 1, "87_1");
678
687
  }, "BlockWrapper_component_kOI0j0aW8Nw"));
679
688
  const InteractiveElement = /* @__PURE__ */ qwik.componentQrl(/* @__PURE__ */ qwik.inlinedQrl((props) => {
680
689
  return /* @__PURE__ */ qwik._jsxC(props.Wrapper, {
@@ -898,151 +907,120 @@ const Block = /* @__PURE__ */ qwik.componentQrl(/* @__PURE__ */ qwik.inlinedQrl(
898
907
  ], "p0.context")
899
908
  }
900
909
  }, 3, "jN_0"),
901
- !((_a = blockComponent.value) == null ? void 0 : _a.noWrap) ? /* @__PURE__ */ qwik._jsxC(jsxRuntime.Fragment, {
910
+ !((_a = blockComponent.value) == null ? void 0 : _a.noWrap) ? !repeatItem.value ? /* @__PURE__ */ qwik._jsxC(BlockWrapper, {
911
+ get Wrapper() {
912
+ return Tag.value;
913
+ },
914
+ get block() {
915
+ return processedBlock.value;
916
+ },
917
+ get context() {
918
+ return props.context;
919
+ },
902
920
  children: [
903
- isEmptyHtmlElement(Tag.value) ? /* @__PURE__ */ qwik._jsxC(BlockWrapper, {
904
- get Wrapper() {
905
- return Tag.value;
921
+ /* @__PURE__ */ qwik._jsxC(ComponentRef, {
922
+ get componentRef() {
923
+ return componentRefProps.value.componentRef;
924
+ },
925
+ get componentOptions() {
926
+ return componentRefProps.value.componentOptions;
906
927
  },
907
- get block() {
908
- return processedBlock.value;
928
+ get blockChildren() {
929
+ return componentRefProps.value.blockChildren;
909
930
  },
910
931
  get context() {
911
- return props.context;
932
+ return componentRefProps.value.context;
933
+ },
934
+ get registeredComponents() {
935
+ return componentRefProps.value.registeredComponents;
936
+ },
937
+ get builderBlock() {
938
+ return componentRefProps.value.builderBlock;
939
+ },
940
+ get includeBlockProps() {
941
+ return componentRefProps.value.includeBlockProps;
942
+ },
943
+ get isInteractive() {
944
+ return componentRefProps.value.isInteractive;
912
945
  },
913
- hasChildren: false,
914
946
  [qwik._IMMUTABLE]: {
915
- Wrapper: qwik._fnSignal((p0) => p0.value, [
916
- Tag
917
- ], "p0.value"),
918
- block: qwik._fnSignal((p0) => p0.value, [
919
- processedBlock
920
- ], "p0.value"),
921
- context: qwik._fnSignal((p0) => p0.context, [
922
- props
923
- ], "p0.context"),
924
- hasChildren: qwik._IMMUTABLE
947
+ blockChildren: qwik._fnSignal((p0) => p0.value.blockChildren, [
948
+ componentRefProps
949
+ ], "p0.value.blockChildren"),
950
+ builderBlock: qwik._fnSignal((p0) => p0.value.builderBlock, [
951
+ componentRefProps
952
+ ], "p0.value.builderBlock"),
953
+ componentOptions: qwik._fnSignal((p0) => p0.value.componentOptions, [
954
+ componentRefProps
955
+ ], "p0.value.componentOptions"),
956
+ componentRef: qwik._fnSignal((p0) => p0.value.componentRef, [
957
+ componentRefProps
958
+ ], "p0.value.componentRef"),
959
+ context: qwik._fnSignal((p0) => p0.value.context, [
960
+ componentRefProps
961
+ ], "p0.value.context"),
962
+ includeBlockProps: qwik._fnSignal((p0) => p0.value.includeBlockProps, [
963
+ componentRefProps
964
+ ], "p0.value.includeBlockProps"),
965
+ isInteractive: qwik._fnSignal((p0) => p0.value.isInteractive, [
966
+ componentRefProps
967
+ ], "p0.value.isInteractive"),
968
+ registeredComponents: qwik._fnSignal((p0) => p0.value.registeredComponents, [
969
+ componentRefProps
970
+ ], "p0.value.registeredComponents")
925
971
  }
926
- }, 3, "jN_1") : null,
927
- !isEmptyHtmlElement(Tag.value) && repeatItem.value ? (repeatItem.value || []).map((data, index) => {
928
- return /* @__PURE__ */ qwik._jsxC(RepeatedBlock, {
929
- get repeatContext() {
930
- return data.context;
931
- },
932
- get block() {
933
- return data.block;
972
+ }, 3, "jN_1"),
973
+ (childrenWithoutParentComponent.value || []).map((child) => {
974
+ return /* @__PURE__ */ qwik._jsxC(Block, {
975
+ block: child,
976
+ get context() {
977
+ return state.childrenContext;
934
978
  },
935
979
  get registeredComponents() {
936
980
  return props.registeredComponents;
937
981
  },
938
982
  [qwik._IMMUTABLE]: {
939
- block: qwik._wrapProp(data, "block"),
983
+ context: qwik._fnSignal((p0) => p0.childrenContext, [
984
+ state
985
+ ], "p0.childrenContext"),
940
986
  registeredComponents: qwik._fnSignal((p0) => p0.registeredComponents, [
941
987
  props
942
- ], "p0.registeredComponents"),
943
- repeatContext: qwik._wrapProp(data, "context")
988
+ ], "p0.registeredComponents")
944
989
  }
945
- }, 3, index);
946
- }) : null,
947
- !isEmptyHtmlElement(Tag.value) && !repeatItem.value ? /* @__PURE__ */ qwik._jsxC(BlockWrapper, {
948
- get Wrapper() {
949
- return Tag.value;
950
- },
951
- get block() {
952
- return processedBlock.value;
953
- },
954
- get context() {
955
- return props.context;
956
- },
957
- children: [
958
- /* @__PURE__ */ qwik._jsxC(ComponentRef, {
959
- get componentRef() {
960
- return componentRefProps.value.componentRef;
961
- },
962
- get componentOptions() {
963
- return componentRefProps.value.componentOptions;
964
- },
965
- get blockChildren() {
966
- return componentRefProps.value.blockChildren;
967
- },
968
- get context() {
969
- return componentRefProps.value.context;
970
- },
971
- get registeredComponents() {
972
- return componentRefProps.value.registeredComponents;
973
- },
974
- get builderBlock() {
975
- return componentRefProps.value.builderBlock;
976
- },
977
- get includeBlockProps() {
978
- return componentRefProps.value.includeBlockProps;
979
- },
980
- get isInteractive() {
981
- return componentRefProps.value.isInteractive;
982
- },
983
- [qwik._IMMUTABLE]: {
984
- blockChildren: qwik._fnSignal((p0) => p0.value.blockChildren, [
985
- componentRefProps
986
- ], "p0.value.blockChildren"),
987
- builderBlock: qwik._fnSignal((p0) => p0.value.builderBlock, [
988
- componentRefProps
989
- ], "p0.value.builderBlock"),
990
- componentOptions: qwik._fnSignal((p0) => p0.value.componentOptions, [
991
- componentRefProps
992
- ], "p0.value.componentOptions"),
993
- componentRef: qwik._fnSignal((p0) => p0.value.componentRef, [
994
- componentRefProps
995
- ], "p0.value.componentRef"),
996
- context: qwik._fnSignal((p0) => p0.value.context, [
997
- componentRefProps
998
- ], "p0.value.context"),
999
- includeBlockProps: qwik._fnSignal((p0) => p0.value.includeBlockProps, [
1000
- componentRefProps
1001
- ], "p0.value.includeBlockProps"),
1002
- isInteractive: qwik._fnSignal((p0) => p0.value.isInteractive, [
1003
- componentRefProps
1004
- ], "p0.value.isInteractive"),
1005
- registeredComponents: qwik._fnSignal((p0) => p0.value.registeredComponents, [
1006
- componentRefProps
1007
- ], "p0.value.registeredComponents")
1008
- }
1009
- }, 3, "jN_2"),
1010
- (childrenWithoutParentComponent.value || []).map((child) => {
1011
- return /* @__PURE__ */ qwik._jsxC(Block, {
1012
- block: child,
1013
- get context() {
1014
- return state.childrenContext;
1015
- },
1016
- get registeredComponents() {
1017
- return props.registeredComponents;
1018
- },
1019
- [qwik._IMMUTABLE]: {
1020
- context: qwik._fnSignal((p0) => p0.childrenContext, [
1021
- state
1022
- ], "p0.childrenContext"),
1023
- registeredComponents: qwik._fnSignal((p0) => p0.registeredComponents, [
1024
- props
1025
- ], "p0.registeredComponents")
1026
- }
1027
- }, 3, child.id);
1028
- })
1029
- ],
1030
- hasChildren: true,
1031
- [qwik._IMMUTABLE]: {
1032
- Wrapper: qwik._fnSignal((p0) => p0.value, [
1033
- Tag
1034
- ], "p0.value"),
1035
- block: qwik._fnSignal((p0) => p0.value, [
1036
- processedBlock
1037
- ], "p0.value"),
1038
- context: qwik._fnSignal((p0) => p0.context, [
1039
- props
1040
- ], "p0.context"),
1041
- hasChildren: qwik._IMMUTABLE
1042
- }
1043
- }, 1, "jN_3") : null
1044
- ]
1045
- }, 1, "jN_4") : /* @__PURE__ */ qwik._jsxC(ComponentRef, {
990
+ }, 3, child.id);
991
+ })
992
+ ],
993
+ [qwik._IMMUTABLE]: {
994
+ Wrapper: qwik._fnSignal((p0) => p0.value, [
995
+ Tag
996
+ ], "p0.value"),
997
+ block: qwik._fnSignal((p0) => p0.value, [
998
+ processedBlock
999
+ ], "p0.value"),
1000
+ context: qwik._fnSignal((p0) => p0.context, [
1001
+ props
1002
+ ], "p0.context")
1003
+ }
1004
+ }, 1, "jN_2") : (repeatItem.value || []).map((data, index) => {
1005
+ return /* @__PURE__ */ qwik._jsxC(RepeatedBlock, {
1006
+ get repeatContext() {
1007
+ return data.context;
1008
+ },
1009
+ get block() {
1010
+ return data.block;
1011
+ },
1012
+ get registeredComponents() {
1013
+ return props.registeredComponents;
1014
+ },
1015
+ [qwik._IMMUTABLE]: {
1016
+ block: qwik._wrapProp(data, "block"),
1017
+ registeredComponents: qwik._fnSignal((p0) => p0.registeredComponents, [
1018
+ props
1019
+ ], "p0.registeredComponents"),
1020
+ repeatContext: qwik._wrapProp(data, "context")
1021
+ }
1022
+ }, 3, index);
1023
+ }) : /* @__PURE__ */ qwik._jsxC(ComponentRef, {
1046
1024
  get componentRef() {
1047
1025
  return componentRefProps.value.componentRef;
1048
1026
  },
@@ -1093,10 +1071,10 @@ const Block = /* @__PURE__ */ qwik.componentQrl(/* @__PURE__ */ qwik.inlinedQrl(
1093
1071
  componentRefProps
1094
1072
  ], "p0.value.registeredComponents")
1095
1073
  }
1096
- }, 3, "jN_5")
1074
+ }, 3, "jN_3")
1097
1075
  ]
1098
- }, 1, "jN_6") : null
1099
- }, 1, "jN_7");
1076
+ }, 1, "jN_4") : null
1077
+ }, 1, "jN_5");
1100
1078
  }, "Block_component_nnPv0RY0U0k"));
1101
1079
  const onClick$1 = function onClick2(props, state) {
1102
1080
  var _a, _b;
@@ -3143,6 +3121,17 @@ async function fetchEntries(options) {
3143
3121
  }
3144
3122
  }
3145
3123
  const getAllContent = fetchEntries;
3124
+ const DEFAULT_TRUSTED_HOSTS = [
3125
+ "*.beta.builder.io",
3126
+ "beta.builder.io",
3127
+ "builder.io",
3128
+ "localhost",
3129
+ "qa.builder.io"
3130
+ ];
3131
+ function isFromTrustedHost(trustedHosts, e) {
3132
+ const url = new URL(e.origin), hostname = url.hostname;
3133
+ return (trustedHosts || DEFAULT_TRUSTED_HOSTS).findIndex((trustedHost) => trustedHost.startsWith("*.") ? hostname.endsWith(trustedHost.slice(1)) : trustedHost === hostname) > -1;
3134
+ }
3146
3135
  function isPreviewing() {
3147
3136
  if (!isBrowser())
3148
3137
  return false;
@@ -3342,7 +3331,7 @@ const getInteractionPropertiesForEvent = (event) => {
3342
3331
  }
3343
3332
  };
3344
3333
  };
3345
- const SDK_VERSION = "0.12.1";
3334
+ const SDK_VERSION = "0.12.2";
3346
3335
  const registry = {};
3347
3336
  function register(type, info) {
3348
3337
  let typeList = registry[type];
@@ -3425,8 +3414,11 @@ const setupBrowserForEditing = (options = {}) => {
3425
3414
  options
3426
3415
  }
3427
3416
  }, "*");
3428
- window.addEventListener("message", ({ data }) => {
3417
+ window.addEventListener("message", (event) => {
3429
3418
  var _a2, _b2;
3419
+ if (!isFromTrustedHost(options.trustedHosts, event))
3420
+ return;
3421
+ const { data } = event;
3430
3422
  if (!(data == null ? void 0 : data.type))
3431
3423
  return;
3432
3424
  switch (data.type) {
@@ -3505,6 +3497,8 @@ const mergeNewContent = function mergeNewContent2(props, state, elementRef, newC
3505
3497
  };
3506
3498
  const processMessage = function processMessage2(props, state, elementRef, event) {
3507
3499
  var _a;
3500
+ if (!isFromTrustedHost(props.trustedHosts, event))
3501
+ return;
3508
3502
  const { data } = event;
3509
3503
  if (data)
3510
3504
  switch (data.type) {
@@ -3639,6 +3633,9 @@ const EnableEditor = /* @__PURE__ */ qwik.componentQrl(/* @__PURE__ */ qwik.inli
3639
3633
  } : {},
3640
3634
  ...props2.enrich ? {
3641
3635
  enrich: props2.enrich
3636
+ } : {},
3637
+ ...props2.trustedHosts ? {
3638
+ trustedHosts: props2.trustedHosts
3642
3639
  } : {}
3643
3640
  });
3644
3641
  Object.values(props2.builderContextSignal.componentInfos).forEach((registeredComponent) => {
@@ -4017,6 +4014,9 @@ const ContentComponent = /* @__PURE__ */ qwik.componentQrl(/* @__PURE__ */ qwik.
4017
4014
  get contentWrapperProps() {
4018
4015
  return props.contentWrapperProps;
4019
4016
  },
4017
+ get trustedHosts() {
4018
+ return props.trustedHosts;
4019
+ },
4020
4020
  children: [
4021
4021
  props.isSsrAbTest ? /* @__PURE__ */ qwik._jsxC(InlinedScript, {
4022
4022
  get scriptStr() {
@@ -4128,7 +4128,10 @@ const ContentComponent = /* @__PURE__ */ qwik.componentQrl(/* @__PURE__ */ qwik.
4128
4128
  ], "p0.model"),
4129
4129
  showContent: qwik._fnSignal((p0) => p0.showContent, [
4130
4130
  props
4131
- ], "p0.showContent")
4131
+ ], "p0.showContent"),
4132
+ trustedHosts: qwik._fnSignal((p0) => p0.trustedHosts, [
4133
+ props
4134
+ ], "p0.trustedHosts")
4132
4135
  }
4133
4136
  }, 1, "LQ_3");
4134
4137
  }, "ContentComponent_component_HIsczUcxjCE"));
@@ -4261,6 +4264,9 @@ const ContentVariants = /* @__PURE__ */ qwik.componentQrl(/* @__PURE__ */ qwik.i
4261
4264
  get contentWrapperProps() {
4262
4265
  return props.contentWrapperProps;
4263
4266
  },
4267
+ get trustedHosts() {
4268
+ return props.trustedHosts;
4269
+ },
4264
4270
  [qwik._IMMUTABLE]: {
4265
4271
  apiKey: qwik._fnSignal((p0) => p0.apiKey, [
4266
4272
  props
@@ -4307,7 +4313,10 @@ const ContentVariants = /* @__PURE__ */ qwik.componentQrl(/* @__PURE__ */ qwik.i
4307
4313
  model: qwik._fnSignal((p0) => p0.model, [
4308
4314
  props
4309
4315
  ], "p0.model"),
4310
- showContent: qwik._IMMUTABLE
4316
+ showContent: qwik._IMMUTABLE,
4317
+ trustedHosts: qwik._fnSignal((p0) => p0.trustedHosts, [
4318
+ props
4319
+ ], "p0.trustedHosts")
4311
4320
  }
4312
4321
  }, 3, variant.testVariationId);
4313
4322
  })
@@ -4363,6 +4372,9 @@ const ContentVariants = /* @__PURE__ */ qwik.componentQrl(/* @__PURE__ */ qwik.i
4363
4372
  get contentWrapperProps() {
4364
4373
  return props.contentWrapperProps;
4365
4374
  },
4375
+ get trustedHosts() {
4376
+ return props.trustedHosts;
4377
+ },
4366
4378
  [qwik._IMMUTABLE]: {
4367
4379
  apiKey: qwik._fnSignal((p0) => p0.apiKey, [
4368
4380
  props
@@ -4412,7 +4424,10 @@ const ContentVariants = /* @__PURE__ */ qwik.componentQrl(/* @__PURE__ */ qwik.i
4412
4424
  model: qwik._fnSignal((p0) => p0.model, [
4413
4425
  props
4414
4426
  ], "p0.model"),
4415
- showContent: qwik._IMMUTABLE
4427
+ showContent: qwik._IMMUTABLE,
4428
+ trustedHosts: qwik._fnSignal((p0) => p0.trustedHosts, [
4429
+ props
4430
+ ], "p0.trustedHosts")
4416
4431
  }
4417
4432
  }, 3, "XM_4")
4418
4433
  ]