@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.
@@ -3467,26 +3467,6 @@ function getProcessedBlock({ block, context, shouldEvaluateBindings, localState,
3467
3467
  else
3468
3468
  return transformedBlock;
3469
3469
  }
3470
- const EMPTY_HTML_ELEMENTS = [
3471
- "area",
3472
- "base",
3473
- "br",
3474
- "col",
3475
- "embed",
3476
- "hr",
3477
- "img",
3478
- "input",
3479
- "keygen",
3480
- "link",
3481
- "meta",
3482
- "param",
3483
- "source",
3484
- "track",
3485
- "wbr"
3486
- ];
3487
- const isEmptyHtmlElement = (tagName) => {
3488
- return typeof tagName === "string" && EMPTY_HTML_ELEMENTS.includes(tagName.toLowerCase());
3489
- };
3490
3470
  const getComponent = ({ block, context, registeredComponents }) => {
3491
3471
  var _a;
3492
3472
  const componentName = (_a = getProcessedBlock({
@@ -3771,38 +3751,67 @@ function getStyleAttribute(style) {
3771
3751
  return style;
3772
3752
  }
3773
3753
  }
3774
- const BlockWrapper = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((props) => {
3754
+ const EMPTY_HTML_ELEMENTS = /* @__PURE__ */ new Set([
3755
+ "area",
3756
+ "base",
3757
+ "br",
3758
+ "col",
3759
+ "embed",
3760
+ "hr",
3761
+ "img",
3762
+ "input",
3763
+ "keygen",
3764
+ "link",
3765
+ "meta",
3766
+ "param",
3767
+ "source",
3768
+ "track",
3769
+ "wbr"
3770
+ ]);
3771
+ const isEmptyElement = (tagName) => {
3772
+ return typeof tagName === "string" && EMPTY_HTML_ELEMENTS.has(tagName.toLowerCase());
3773
+ };
3774
+ const DynamicRenderer = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((props) => {
3775
3775
  _jsxBranch();
3776
3776
  return /* @__PURE__ */ _jsxC(Fragment, {
3777
- children: props.hasChildren ? /* @__PURE__ */ _jsxC(props.Wrapper, {
3778
- ...getBlockProperties({
3779
- block: props.block,
3780
- context: props.context
3781
- }),
3782
- ...getBlockActions({
3783
- block: props.block,
3784
- rootState: props.context.rootState,
3785
- rootSetState: props.context.rootSetState,
3786
- localState: props.context.localState,
3787
- context: props.context.context,
3788
- stripPrefix: true
3789
- }),
3790
- children: /* @__PURE__ */ _jsxC(Slot$1, null, 3, "87_0")
3791
- }, 0, "87_1") : /* @__PURE__ */ _jsxC(props.Wrapper, {
3792
- ...getBlockProperties({
3793
- block: props.block,
3794
- context: props.context
3795
- }),
3796
- ...getBlockActions({
3797
- block: props.block,
3798
- rootState: props.context.rootState,
3799
- rootSetState: props.context.rootSetState,
3800
- localState: props.context.localState,
3801
- context: props.context.context,
3802
- stripPrefix: true
3803
- })
3804
- }, 0, "87_2")
3805
- }, 1, "87_3");
3777
+ children: !isEmptyElement(props.TagName) ? typeof props.TagName === "string" ? /* @__PURE__ */ _jsxC(props.TagName, {
3778
+ ...props.attributes,
3779
+ ...props.actionAttributes,
3780
+ children: /* @__PURE__ */ _jsxC(Slot$1, null, 3, "yW_0")
3781
+ }, 0, "yW_1") : /* @__PURE__ */ _jsxC(props.TagName, {
3782
+ ...props.attributes,
3783
+ ...props.actionAttributes,
3784
+ children: /* @__PURE__ */ _jsxC(Slot$1, null, 3, "yW_2")
3785
+ }, 0, "yW_3") : /* @__PURE__ */ _jsxC(props.TagName, {
3786
+ ...props.attributes,
3787
+ ...props.actionAttributes
3788
+ }, 0, "yW_4")
3789
+ }, 1, "yW_5");
3790
+ }, "DynamicRenderer_component_1Co0xkmyAfQ"));
3791
+ const BlockWrapper = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((props) => {
3792
+ return /* @__PURE__ */ _jsxC(DynamicRenderer, {
3793
+ get TagName() {
3794
+ return props.Wrapper;
3795
+ },
3796
+ actionAttributes: getBlockActions({
3797
+ block: props.block,
3798
+ rootState: props.context.rootState,
3799
+ rootSetState: props.context.rootSetState,
3800
+ localState: props.context.localState,
3801
+ context: props.context.context,
3802
+ stripPrefix: true
3803
+ }),
3804
+ attributes: getBlockProperties({
3805
+ block: props.block,
3806
+ context: props.context
3807
+ }),
3808
+ children: /* @__PURE__ */ _jsxC(Slot$1, null, 3, "87_0"),
3809
+ [_IMMUTABLE]: {
3810
+ TagName: _fnSignal((p0) => p0.Wrapper, [
3811
+ props
3812
+ ], "p0.Wrapper")
3813
+ }
3814
+ }, 1, "87_1");
3806
3815
  }, "BlockWrapper_component_kOI0j0aW8Nw"));
3807
3816
  const InteractiveElement = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((props) => {
3808
3817
  return /* @__PURE__ */ _jsxC(props.Wrapper, {
@@ -4026,151 +4035,120 @@ const Block = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((props) =>
4026
4035
  ], "p0.context")
4027
4036
  }
4028
4037
  }, 3, "jN_0"),
4029
- !((_a = blockComponent.value) == null ? void 0 : _a.noWrap) ? /* @__PURE__ */ _jsxC(Fragment, {
4038
+ !((_a = blockComponent.value) == null ? void 0 : _a.noWrap) ? !repeatItem.value ? /* @__PURE__ */ _jsxC(BlockWrapper, {
4039
+ get Wrapper() {
4040
+ return Tag.value;
4041
+ },
4042
+ get block() {
4043
+ return processedBlock.value;
4044
+ },
4045
+ get context() {
4046
+ return props.context;
4047
+ },
4030
4048
  children: [
4031
- isEmptyHtmlElement(Tag.value) ? /* @__PURE__ */ _jsxC(BlockWrapper, {
4032
- get Wrapper() {
4033
- return Tag.value;
4049
+ /* @__PURE__ */ _jsxC(ComponentRef, {
4050
+ get componentRef() {
4051
+ return componentRefProps.value.componentRef;
4052
+ },
4053
+ get componentOptions() {
4054
+ return componentRefProps.value.componentOptions;
4034
4055
  },
4035
- get block() {
4036
- return processedBlock.value;
4056
+ get blockChildren() {
4057
+ return componentRefProps.value.blockChildren;
4037
4058
  },
4038
4059
  get context() {
4039
- return props.context;
4060
+ return componentRefProps.value.context;
4061
+ },
4062
+ get registeredComponents() {
4063
+ return componentRefProps.value.registeredComponents;
4064
+ },
4065
+ get builderBlock() {
4066
+ return componentRefProps.value.builderBlock;
4067
+ },
4068
+ get includeBlockProps() {
4069
+ return componentRefProps.value.includeBlockProps;
4070
+ },
4071
+ get isInteractive() {
4072
+ return componentRefProps.value.isInteractive;
4040
4073
  },
4041
- hasChildren: false,
4042
4074
  [_IMMUTABLE]: {
4043
- Wrapper: _fnSignal((p0) => p0.value, [
4044
- Tag
4045
- ], "p0.value"),
4046
- block: _fnSignal((p0) => p0.value, [
4047
- processedBlock
4048
- ], "p0.value"),
4049
- context: _fnSignal((p0) => p0.context, [
4050
- props
4051
- ], "p0.context"),
4052
- hasChildren: _IMMUTABLE
4075
+ blockChildren: _fnSignal((p0) => p0.value.blockChildren, [
4076
+ componentRefProps
4077
+ ], "p0.value.blockChildren"),
4078
+ builderBlock: _fnSignal((p0) => p0.value.builderBlock, [
4079
+ componentRefProps
4080
+ ], "p0.value.builderBlock"),
4081
+ componentOptions: _fnSignal((p0) => p0.value.componentOptions, [
4082
+ componentRefProps
4083
+ ], "p0.value.componentOptions"),
4084
+ componentRef: _fnSignal((p0) => p0.value.componentRef, [
4085
+ componentRefProps
4086
+ ], "p0.value.componentRef"),
4087
+ context: _fnSignal((p0) => p0.value.context, [
4088
+ componentRefProps
4089
+ ], "p0.value.context"),
4090
+ includeBlockProps: _fnSignal((p0) => p0.value.includeBlockProps, [
4091
+ componentRefProps
4092
+ ], "p0.value.includeBlockProps"),
4093
+ isInteractive: _fnSignal((p0) => p0.value.isInteractive, [
4094
+ componentRefProps
4095
+ ], "p0.value.isInteractive"),
4096
+ registeredComponents: _fnSignal((p0) => p0.value.registeredComponents, [
4097
+ componentRefProps
4098
+ ], "p0.value.registeredComponents")
4053
4099
  }
4054
- }, 3, "jN_1") : null,
4055
- !isEmptyHtmlElement(Tag.value) && repeatItem.value ? (repeatItem.value || []).map((data, index) => {
4056
- return /* @__PURE__ */ _jsxC(RepeatedBlock, {
4057
- get repeatContext() {
4058
- return data.context;
4059
- },
4060
- get block() {
4061
- return data.block;
4100
+ }, 3, "jN_1"),
4101
+ (childrenWithoutParentComponent.value || []).map((child) => {
4102
+ return /* @__PURE__ */ _jsxC(Block, {
4103
+ block: child,
4104
+ get context() {
4105
+ return state.childrenContext;
4062
4106
  },
4063
4107
  get registeredComponents() {
4064
4108
  return props.registeredComponents;
4065
4109
  },
4066
4110
  [_IMMUTABLE]: {
4067
- block: _wrapProp(data, "block"),
4111
+ context: _fnSignal((p0) => p0.childrenContext, [
4112
+ state
4113
+ ], "p0.childrenContext"),
4068
4114
  registeredComponents: _fnSignal((p0) => p0.registeredComponents, [
4069
4115
  props
4070
- ], "p0.registeredComponents"),
4071
- repeatContext: _wrapProp(data, "context")
4116
+ ], "p0.registeredComponents")
4072
4117
  }
4073
- }, 3, index);
4074
- }) : null,
4075
- !isEmptyHtmlElement(Tag.value) && !repeatItem.value ? /* @__PURE__ */ _jsxC(BlockWrapper, {
4076
- get Wrapper() {
4077
- return Tag.value;
4078
- },
4079
- get block() {
4080
- return processedBlock.value;
4081
- },
4082
- get context() {
4083
- return props.context;
4084
- },
4085
- children: [
4086
- /* @__PURE__ */ _jsxC(ComponentRef, {
4087
- get componentRef() {
4088
- return componentRefProps.value.componentRef;
4089
- },
4090
- get componentOptions() {
4091
- return componentRefProps.value.componentOptions;
4092
- },
4093
- get blockChildren() {
4094
- return componentRefProps.value.blockChildren;
4095
- },
4096
- get context() {
4097
- return componentRefProps.value.context;
4098
- },
4099
- get registeredComponents() {
4100
- return componentRefProps.value.registeredComponents;
4101
- },
4102
- get builderBlock() {
4103
- return componentRefProps.value.builderBlock;
4104
- },
4105
- get includeBlockProps() {
4106
- return componentRefProps.value.includeBlockProps;
4107
- },
4108
- get isInteractive() {
4109
- return componentRefProps.value.isInteractive;
4110
- },
4111
- [_IMMUTABLE]: {
4112
- blockChildren: _fnSignal((p0) => p0.value.blockChildren, [
4113
- componentRefProps
4114
- ], "p0.value.blockChildren"),
4115
- builderBlock: _fnSignal((p0) => p0.value.builderBlock, [
4116
- componentRefProps
4117
- ], "p0.value.builderBlock"),
4118
- componentOptions: _fnSignal((p0) => p0.value.componentOptions, [
4119
- componentRefProps
4120
- ], "p0.value.componentOptions"),
4121
- componentRef: _fnSignal((p0) => p0.value.componentRef, [
4122
- componentRefProps
4123
- ], "p0.value.componentRef"),
4124
- context: _fnSignal((p0) => p0.value.context, [
4125
- componentRefProps
4126
- ], "p0.value.context"),
4127
- includeBlockProps: _fnSignal((p0) => p0.value.includeBlockProps, [
4128
- componentRefProps
4129
- ], "p0.value.includeBlockProps"),
4130
- isInteractive: _fnSignal((p0) => p0.value.isInteractive, [
4131
- componentRefProps
4132
- ], "p0.value.isInteractive"),
4133
- registeredComponents: _fnSignal((p0) => p0.value.registeredComponents, [
4134
- componentRefProps
4135
- ], "p0.value.registeredComponents")
4136
- }
4137
- }, 3, "jN_2"),
4138
- (childrenWithoutParentComponent.value || []).map((child) => {
4139
- return /* @__PURE__ */ _jsxC(Block, {
4140
- block: child,
4141
- get context() {
4142
- return state.childrenContext;
4143
- },
4144
- get registeredComponents() {
4145
- return props.registeredComponents;
4146
- },
4147
- [_IMMUTABLE]: {
4148
- context: _fnSignal((p0) => p0.childrenContext, [
4149
- state
4150
- ], "p0.childrenContext"),
4151
- registeredComponents: _fnSignal((p0) => p0.registeredComponents, [
4152
- props
4153
- ], "p0.registeredComponents")
4154
- }
4155
- }, 3, child.id);
4156
- })
4157
- ],
4158
- hasChildren: true,
4159
- [_IMMUTABLE]: {
4160
- Wrapper: _fnSignal((p0) => p0.value, [
4161
- Tag
4162
- ], "p0.value"),
4163
- block: _fnSignal((p0) => p0.value, [
4164
- processedBlock
4165
- ], "p0.value"),
4166
- context: _fnSignal((p0) => p0.context, [
4167
- props
4168
- ], "p0.context"),
4169
- hasChildren: _IMMUTABLE
4170
- }
4171
- }, 1, "jN_3") : null
4172
- ]
4173
- }, 1, "jN_4") : /* @__PURE__ */ _jsxC(ComponentRef, {
4118
+ }, 3, child.id);
4119
+ })
4120
+ ],
4121
+ [_IMMUTABLE]: {
4122
+ Wrapper: _fnSignal((p0) => p0.value, [
4123
+ Tag
4124
+ ], "p0.value"),
4125
+ block: _fnSignal((p0) => p0.value, [
4126
+ processedBlock
4127
+ ], "p0.value"),
4128
+ context: _fnSignal((p0) => p0.context, [
4129
+ props
4130
+ ], "p0.context")
4131
+ }
4132
+ }, 1, "jN_2") : (repeatItem.value || []).map((data, index) => {
4133
+ return /* @__PURE__ */ _jsxC(RepeatedBlock, {
4134
+ get repeatContext() {
4135
+ return data.context;
4136
+ },
4137
+ get block() {
4138
+ return data.block;
4139
+ },
4140
+ get registeredComponents() {
4141
+ return props.registeredComponents;
4142
+ },
4143
+ [_IMMUTABLE]: {
4144
+ block: _wrapProp(data, "block"),
4145
+ registeredComponents: _fnSignal((p0) => p0.registeredComponents, [
4146
+ props
4147
+ ], "p0.registeredComponents"),
4148
+ repeatContext: _wrapProp(data, "context")
4149
+ }
4150
+ }, 3, index);
4151
+ }) : /* @__PURE__ */ _jsxC(ComponentRef, {
4174
4152
  get componentRef() {
4175
4153
  return componentRefProps.value.componentRef;
4176
4154
  },
@@ -4221,10 +4199,10 @@ const Block = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((props) =>
4221
4199
  componentRefProps
4222
4200
  ], "p0.value.registeredComponents")
4223
4201
  }
4224
- }, 3, "jN_5")
4202
+ }, 3, "jN_3")
4225
4203
  ]
4226
- }, 1, "jN_6") : null
4227
- }, 1, "jN_7");
4204
+ }, 1, "jN_4") : null
4205
+ }, 1, "jN_5");
4228
4206
  }, "Block_component_nnPv0RY0U0k"));
4229
4207
  const onClick$1 = function onClick2(props, state) {
4230
4208
  var _a, _b;
@@ -6271,6 +6249,17 @@ async function fetchEntries(options) {
6271
6249
  }
6272
6250
  }
6273
6251
  const getAllContent = fetchEntries;
6252
+ const DEFAULT_TRUSTED_HOSTS = [
6253
+ "*.beta.builder.io",
6254
+ "beta.builder.io",
6255
+ "builder.io",
6256
+ "localhost",
6257
+ "qa.builder.io"
6258
+ ];
6259
+ function isFromTrustedHost(trustedHosts, e) {
6260
+ const url = new URL(e.origin), hostname = url.hostname;
6261
+ return (trustedHosts || DEFAULT_TRUSTED_HOSTS).findIndex((trustedHost) => trustedHost.startsWith("*.") ? hostname.endsWith(trustedHost.slice(1)) : trustedHost === hostname) > -1;
6262
+ }
6274
6263
  function isPreviewing() {
6275
6264
  if (!isBrowser())
6276
6265
  return false;
@@ -6470,7 +6459,7 @@ const getInteractionPropertiesForEvent = (event) => {
6470
6459
  }
6471
6460
  };
6472
6461
  };
6473
- const SDK_VERSION = "0.12.1";
6462
+ const SDK_VERSION = "0.12.2";
6474
6463
  const registry = {};
6475
6464
  function register(type, info) {
6476
6465
  let typeList = registry[type];
@@ -6553,8 +6542,11 @@ const setupBrowserForEditing = (options = {}) => {
6553
6542
  options
6554
6543
  }
6555
6544
  }, "*");
6556
- window.addEventListener("message", ({ data }) => {
6545
+ window.addEventListener("message", (event) => {
6557
6546
  var _a2, _b2;
6547
+ if (!isFromTrustedHost(options.trustedHosts, event))
6548
+ return;
6549
+ const { data } = event;
6558
6550
  if (!(data == null ? void 0 : data.type))
6559
6551
  return;
6560
6552
  switch (data.type) {
@@ -6633,6 +6625,8 @@ const mergeNewContent = function mergeNewContent2(props, state, elementRef, newC
6633
6625
  };
6634
6626
  const processMessage = function processMessage2(props, state, elementRef, event) {
6635
6627
  var _a;
6628
+ if (!isFromTrustedHost(props.trustedHosts, event))
6629
+ return;
6636
6630
  const { data } = event;
6637
6631
  if (data)
6638
6632
  switch (data.type) {
@@ -6767,6 +6761,9 @@ const EnableEditor = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((pr
6767
6761
  } : {},
6768
6762
  ...props2.enrich ? {
6769
6763
  enrich: props2.enrich
6764
+ } : {},
6765
+ ...props2.trustedHosts ? {
6766
+ trustedHosts: props2.trustedHosts
6770
6767
  } : {}
6771
6768
  });
6772
6769
  Object.values(props2.builderContextSignal.componentInfos).forEach((registeredComponent) => {
@@ -7145,6 +7142,9 @@ const ContentComponent = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl
7145
7142
  get contentWrapperProps() {
7146
7143
  return props.contentWrapperProps;
7147
7144
  },
7145
+ get trustedHosts() {
7146
+ return props.trustedHosts;
7147
+ },
7148
7148
  children: [
7149
7149
  props.isSsrAbTest ? /* @__PURE__ */ _jsxC(InlinedScript, {
7150
7150
  get scriptStr() {
@@ -7256,7 +7256,10 @@ const ContentComponent = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl
7256
7256
  ], "p0.model"),
7257
7257
  showContent: _fnSignal((p0) => p0.showContent, [
7258
7258
  props
7259
- ], "p0.showContent")
7259
+ ], "p0.showContent"),
7260
+ trustedHosts: _fnSignal((p0) => p0.trustedHosts, [
7261
+ props
7262
+ ], "p0.trustedHosts")
7260
7263
  }
7261
7264
  }, 1, "LQ_3");
7262
7265
  }, "ContentComponent_component_HIsczUcxjCE"));
@@ -7389,6 +7392,9 @@ const ContentVariants = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl(
7389
7392
  get contentWrapperProps() {
7390
7393
  return props.contentWrapperProps;
7391
7394
  },
7395
+ get trustedHosts() {
7396
+ return props.trustedHosts;
7397
+ },
7392
7398
  [_IMMUTABLE]: {
7393
7399
  apiKey: _fnSignal((p0) => p0.apiKey, [
7394
7400
  props
@@ -7435,7 +7441,10 @@ const ContentVariants = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl(
7435
7441
  model: _fnSignal((p0) => p0.model, [
7436
7442
  props
7437
7443
  ], "p0.model"),
7438
- showContent: _IMMUTABLE
7444
+ showContent: _IMMUTABLE,
7445
+ trustedHosts: _fnSignal((p0) => p0.trustedHosts, [
7446
+ props
7447
+ ], "p0.trustedHosts")
7439
7448
  }
7440
7449
  }, 3, variant.testVariationId);
7441
7450
  })
@@ -7491,6 +7500,9 @@ const ContentVariants = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl(
7491
7500
  get contentWrapperProps() {
7492
7501
  return props.contentWrapperProps;
7493
7502
  },
7503
+ get trustedHosts() {
7504
+ return props.trustedHosts;
7505
+ },
7494
7506
  [_IMMUTABLE]: {
7495
7507
  apiKey: _fnSignal((p0) => p0.apiKey, [
7496
7508
  props
@@ -7540,7 +7552,10 @@ const ContentVariants = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl(
7540
7552
  model: _fnSignal((p0) => p0.model, [
7541
7553
  props
7542
7554
  ], "p0.model"),
7543
- showContent: _IMMUTABLE
7555
+ showContent: _IMMUTABLE,
7556
+ trustedHosts: _fnSignal((p0) => p0.trustedHosts, [
7557
+ props
7558
+ ], "p0.trustedHosts")
7544
7559
  }
7545
7560
  }, 3, "XM_4")
7546
7561
  ]