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