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