@builder.io/sdk-solid 0.14.5 → 1.0.12

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.
@@ -79,7 +79,7 @@ function Button(props) {
79
79
  var button_default = Button;
80
80
 
81
81
  // src/blocks/columns/columns.tsx
82
- import { Show as Show6, For as For4, createSignal as createSignal5 } from "solid-js";
82
+ import { Show as Show6, For as For4, createSignal as createSignal6, createMemo as createMemo6 } from "solid-js";
83
83
  import { css as css2 } from "solid-styled-components";
84
84
 
85
85
  // src/components/blocks/blocks.tsx
@@ -107,7 +107,7 @@ import { createContext as createContext2 } from "solid-js";
107
107
  var components_context_default = createContext2({ registeredComponents: {} });
108
108
 
109
109
  // src/components/block/block.tsx
110
- import { Show as Show4, For as For2, onMount, createSignal as createSignal4 } from "solid-js";
110
+ import { Show as Show4, For as For2, onMount, createMemo as createMemo4 } from "solid-js";
111
111
 
112
112
  // src/functions/get-block-component-options.ts
113
113
  function getBlockComponentOptions(block) {
@@ -274,7 +274,7 @@ function flattenState({
274
274
  return localState[prop];
275
275
  }
276
276
  const val = target[prop];
277
- if (typeof val === "object") {
277
+ if (typeof val === "object" && val !== null) {
278
278
  return flattenState({
279
279
  rootState: val,
280
280
  localState: void 0,
@@ -3483,6 +3483,30 @@ var shouldForceBrowserRuntimeInNode = () => {
3483
3483
  var chooseBrowserOrServerEval = (args) => isBrowser() || shouldForceBrowserRuntimeInNode() ? runInBrowser(args) : runInEdge(args);
3484
3484
 
3485
3485
  // src/functions/evaluate/evaluate.ts
3486
+ var EvalCache = class _EvalCache {
3487
+ static cacheLimit = 20;
3488
+ static cache = /* @__PURE__ */ new Map();
3489
+ static getCacheKey(args) {
3490
+ return JSON.stringify({
3491
+ ...args,
3492
+ // replace the event with a random number to break cache
3493
+ // thats because we can't serialize the event object due to circular refs in DOM node refs.
3494
+ event: args.event ? Math.random() : void 0
3495
+ });
3496
+ }
3497
+ static getCachedValue(key) {
3498
+ const cachedVal = _EvalCache.cache.get(key);
3499
+ return cachedVal;
3500
+ }
3501
+ static setCachedValue(key, value) {
3502
+ if (_EvalCache.cache.size > 20) {
3503
+ _EvalCache.cache.delete(_EvalCache.cache.keys().next().value);
3504
+ }
3505
+ _EvalCache.cache.set(key, {
3506
+ value
3507
+ });
3508
+ }
3509
+ };
3486
3510
  function evaluate({
3487
3511
  code,
3488
3512
  context,
@@ -3490,11 +3514,12 @@ function evaluate({
3490
3514
  rootState,
3491
3515
  rootSetState,
3492
3516
  event,
3493
- isExpression = true
3517
+ isExpression = true,
3518
+ enableCache
3494
3519
  }) {
3495
3520
  if (code === "") {
3496
3521
  logger.warn("Skipping evaluation of empty code block.");
3497
- return;
3522
+ return void 0;
3498
3523
  }
3499
3524
  const args = {
3500
3525
  code: parseCode(code, {
@@ -3507,8 +3532,20 @@ function evaluate({
3507
3532
  rootState,
3508
3533
  localState
3509
3534
  };
3535
+ if (enableCache) {
3536
+ const cacheKey = EvalCache.getCacheKey(args);
3537
+ const cachedValue = EvalCache.getCachedValue(cacheKey);
3538
+ if (cachedValue) {
3539
+ return cachedValue.value;
3540
+ }
3541
+ }
3510
3542
  try {
3511
- return chooseBrowserOrServerEval(args);
3543
+ const newEval = chooseBrowserOrServerEval(args);
3544
+ if (enableCache) {
3545
+ const cacheKey = EvalCache.getCacheKey(args);
3546
+ EvalCache.setCachedValue(cacheKey, newEval);
3547
+ }
3548
+ return newEval;
3512
3549
  } catch (e) {
3513
3550
  logger.error("Failed code evaluation: " + e.message, {
3514
3551
  code
@@ -3553,7 +3590,8 @@ var evaluateBindings = ({
3553
3590
  localState,
3554
3591
  rootState,
3555
3592
  rootSetState,
3556
- context
3593
+ context,
3594
+ enableCache: true
3557
3595
  });
3558
3596
  set(copied, binding, value);
3559
3597
  }
@@ -3786,6 +3824,70 @@ function bindScrollInViewAnimation(animation) {
3786
3824
  });
3787
3825
  }
3788
3826
 
3827
+ // src/functions/camel-to-kebab-case.ts
3828
+ var camelToKebabCase = (string) => string.replace(/([a-z0-9]|(?=[A-Z]))([A-Z])/g, "$1-$2").toLowerCase();
3829
+
3830
+ // src/helpers/css.ts
3831
+ var convertStyleMapToCSSArray = (style) => {
3832
+ const cssProps = Object.entries(style).map(([key, value]) => {
3833
+ if (typeof value === "string") {
3834
+ return `${camelToKebabCase(key)}: ${value};`;
3835
+ } else {
3836
+ return void 0;
3837
+ }
3838
+ });
3839
+ return cssProps.filter(checkIsDefined);
3840
+ };
3841
+ var convertStyleMapToCSS = (style) => convertStyleMapToCSSArray(style).join("\n");
3842
+ var createCssClass = ({
3843
+ mediaQuery,
3844
+ className,
3845
+ styles
3846
+ }) => {
3847
+ const cssClass = `.${className} {
3848
+ ${convertStyleMapToCSS(styles)}
3849
+ }`;
3850
+ if (mediaQuery) {
3851
+ return `${mediaQuery} {
3852
+ ${cssClass}
3853
+ }`;
3854
+ } else {
3855
+ return cssClass;
3856
+ }
3857
+ };
3858
+
3859
+ // src/functions/transform-style-property.ts
3860
+ function transformStyleProperty({
3861
+ style
3862
+ }) {
3863
+ return style;
3864
+ }
3865
+
3866
+ // src/functions/get-style.ts
3867
+ var getStyle = ({
3868
+ block,
3869
+ context
3870
+ }) => {
3871
+ return mapStyleObjToStrIfNeeded(transformStyleProperty({
3872
+ style: block.style || {},
3873
+ context,
3874
+ block
3875
+ }));
3876
+ };
3877
+ function mapStyleObjToStrIfNeeded(style) {
3878
+ switch (TARGET) {
3879
+ case "svelte":
3880
+ case "vue":
3881
+ case "solid":
3882
+ return convertStyleMapToCSSArray(style).join(" ");
3883
+ case "qwik":
3884
+ case "reactNative":
3885
+ case "react":
3886
+ case "rsc":
3887
+ return style;
3888
+ }
3889
+ }
3890
+
3789
3891
  // src/components/block/block.helpers.ts
3790
3892
  var getComponent = ({
3791
3893
  block,
@@ -3826,7 +3928,8 @@ var getRepeatItemData = ({
3826
3928
  localState: context.localState,
3827
3929
  rootState: context.rootState,
3828
3930
  rootSetState: context.rootSetState,
3829
- context: context.context
3931
+ context: context.context,
3932
+ enableCache: true
3830
3933
  });
3831
3934
  if (!Array.isArray(itemsArray)) {
3832
3935
  return void 0;
@@ -3850,7 +3953,7 @@ var getRepeatItemData = ({
3850
3953
  };
3851
3954
 
3852
3955
  // src/components/block/components/block-styles.tsx
3853
- import { Show as Show2 } from "solid-js";
3956
+ import { Show as Show2, createMemo } from "solid-js";
3854
3957
 
3855
3958
  // src/constants/device-sizes.ts
3856
3959
  var SIZES = {
@@ -3901,38 +4004,6 @@ var getSizesForBreakpoints = ({
3901
4004
  return newSizes;
3902
4005
  };
3903
4006
 
3904
- // src/functions/camel-to-kebab-case.ts
3905
- var camelToKebabCase = (string) => string.replace(/([a-z0-9]|(?=[A-Z]))([A-Z])/g, "$1-$2").toLowerCase();
3906
-
3907
- // src/helpers/css.ts
3908
- var convertStyleMapToCSSArray = (style) => {
3909
- const cssProps = Object.entries(style).map(([key, value]) => {
3910
- if (typeof value === "string") {
3911
- return `${camelToKebabCase(key)}: ${value};`;
3912
- } else {
3913
- return void 0;
3914
- }
3915
- });
3916
- return cssProps.filter(checkIsDefined);
3917
- };
3918
- var convertStyleMapToCSS = (style) => convertStyleMapToCSSArray(style).join("\n");
3919
- var createCssClass = ({
3920
- mediaQuery,
3921
- className,
3922
- styles
3923
- }) => {
3924
- const cssClass = `.${className} {
3925
- ${convertStyleMapToCSS(styles)}
3926
- }`;
3927
- if (mediaQuery) {
3928
- return `${mediaQuery} {
3929
- ${cssClass}
3930
- }`;
3931
- } else {
3932
- return cssClass;
3933
- }
3934
- };
3935
-
3936
4007
  // src/components/inlined-styles.tsx
3937
4008
  function InlinedStyles(props) {
3938
4009
  return <style innerHTML={props.styles} id={props.id} />;
@@ -3941,7 +4012,7 @@ var Inlined_styles_default = InlinedStyles;
3941
4012
 
3942
4013
  // src/components/block/components/block-styles.tsx
3943
4014
  function BlockStyles(props) {
3944
- function canShowBlock() {
4015
+ const canShowBlock = createMemo(() => {
3945
4016
  const processedBlock = getProcessedBlock({
3946
4017
  block: props.block,
3947
4018
  localState: props.context.localState,
@@ -3957,8 +4028,8 @@ function BlockStyles(props) {
3957
4028
  return processedBlock.show;
3958
4029
  }
3959
4030
  return true;
3960
- }
3961
- function css5() {
4031
+ });
4032
+ const css5 = createMemo(() => {
3962
4033
  const processedBlock = getProcessedBlock({
3963
4034
  block: props.block,
3964
4035
  localState: props.context.localState,
@@ -4000,7 +4071,7 @@ function BlockStyles(props) {
4000
4071
  )
4001
4072
  }) : "";
4002
4073
  return [largeStylesClass, mediumStylesClass, smallStylesClass].join(" ");
4003
- }
4074
+ });
4004
4075
  return <Show2 when={TARGET !== "reactNative" && css5() && canShowBlock()}><Inlined_styles_default styles={css5()} /></Show2>;
4005
4076
  }
4006
4077
  var Block_styles_default = BlockStyles;
@@ -4019,7 +4090,8 @@ var createEventHandler = (value, options) => (event) => evaluate({
4019
4090
  rootState: options.rootState,
4020
4091
  rootSetState: options.rootSetState,
4021
4092
  event,
4022
- isExpression: false
4093
+ isExpression: false,
4094
+ enableCache: true
4023
4095
  });
4024
4096
 
4025
4097
  // src/functions/get-block-actions.ts
@@ -4047,38 +4119,6 @@ function getBlockActions(options) {
4047
4119
  return obj;
4048
4120
  }
4049
4121
 
4050
- // src/functions/transform-style-property.ts
4051
- function transformStyleProperty({
4052
- style
4053
- }) {
4054
- return style;
4055
- }
4056
-
4057
- // src/functions/get-style.ts
4058
- var getStyle = ({
4059
- block,
4060
- context
4061
- }) => {
4062
- return mapStyleObjToStrIfNeeded(transformStyleProperty({
4063
- style: block.style || {},
4064
- context,
4065
- block
4066
- }));
4067
- };
4068
- function mapStyleObjToStrIfNeeded(style) {
4069
- switch (TARGET) {
4070
- case "svelte":
4071
- case "vue":
4072
- case "solid":
4073
- return convertStyleMapToCSSArray(style).join(" ");
4074
- case "qwik":
4075
- case "reactNative":
4076
- case "react":
4077
- case "rsc":
4078
- return style;
4079
- }
4080
- }
4081
-
4082
4122
  // src/functions/transform-block-properties.ts
4083
4123
  function transformBlockProperties({
4084
4124
  properties
@@ -4238,21 +4278,20 @@ var Repeated_block_default = RepeatedBlock;
4238
4278
 
4239
4279
  // src/components/block/block.tsx
4240
4280
  function Block(props) {
4241
- const [childrenContext, setChildrenContext] = createSignal4(props.context);
4242
- function blockComponent() {
4281
+ const blockComponent = createMemo4(() => {
4243
4282
  return getComponent({
4244
4283
  block: props.block,
4245
4284
  context: props.context,
4246
4285
  registeredComponents: props.registeredComponents
4247
4286
  });
4248
- }
4249
- function repeatItem() {
4287
+ });
4288
+ const repeatItem = createMemo4(() => {
4250
4289
  return getRepeatItemData({
4251
4290
  block: props.block,
4252
4291
  context: props.context
4253
4292
  });
4254
- }
4255
- function processedBlock() {
4293
+ });
4294
+ const processedBlock = createMemo4(() => {
4256
4295
  return props.block.repeat?.collection ? props.block : getProcessedBlock({
4257
4296
  block: props.block,
4258
4297
  localState: props.context.localState,
@@ -4261,15 +4300,15 @@ function Block(props) {
4261
4300
  context: props.context.context,
4262
4301
  shouldEvaluateBindings: true
4263
4302
  });
4264
- }
4265
- function Tag() {
4303
+ });
4304
+ const Tag = createMemo4(() => {
4266
4305
  const shouldUseLink = props.block.tagName === "a" || processedBlock().properties?.href || processedBlock().href;
4267
4306
  if (shouldUseLink) {
4268
4307
  return props.linkComponent || "a";
4269
4308
  }
4270
4309
  return props.block.tagName || "div";
4271
- }
4272
- function canShowBlock() {
4310
+ });
4311
+ const canShowBlock = createMemo4(() => {
4273
4312
  if (props.block.repeat?.collection) {
4274
4313
  if (repeatItem()?.length)
4275
4314
  return true;
@@ -4278,12 +4317,12 @@ function Block(props) {
4278
4317
  const shouldHide = "hide" in processedBlock() ? processedBlock().hide : false;
4279
4318
  const shouldShow = "show" in processedBlock() ? processedBlock().show : true;
4280
4319
  return shouldShow && !shouldHide;
4281
- }
4282
- function childrenWithoutParentComponent() {
4320
+ });
4321
+ const childrenWithoutParentComponent = createMemo4(() => {
4283
4322
  const shouldRenderChildrenOutsideRef = !blockComponent()?.component && !repeatItem();
4284
4323
  return shouldRenderChildrenOutsideRef ? processedBlock().children ?? [] : [];
4285
- }
4286
- function componentRefProps() {
4324
+ });
4325
+ const componentRefProps = createMemo4(() => {
4287
4326
  return {
4288
4327
  blockChildren: processedBlock().children ?? [],
4289
4328
  componentRef: blockComponent()?.component,
@@ -4297,14 +4336,14 @@ function Block(props) {
4297
4336
  builderComponents: props.registeredComponents
4298
4337
  } : {}
4299
4338
  },
4300
- context: childrenContext(),
4339
+ context: props.context,
4301
4340
  linkComponent: props.linkComponent,
4302
4341
  registeredComponents: props.registeredComponents,
4303
4342
  builderBlock: processedBlock(),
4304
4343
  includeBlockProps: blockComponent()?.noWrap === true,
4305
4344
  isInteractive: !blockComponent()?.isRSC
4306
4345
  };
4307
- }
4346
+ });
4308
4347
  onMount(() => {
4309
4348
  const blockId = processedBlock().id;
4310
4349
  const animations = processedBlock().animations;
@@ -4366,9 +4405,9 @@ function Block(props) {
4366
4405
  return <Block
4367
4406
  key={child.id}
4368
4407
  block={child}
4369
- context={childrenContext()}
4370
4408
  registeredComponents={props.registeredComponents}
4371
4409
  linkComponent={props.linkComponent}
4410
+ context={props.context}
4372
4411
  />;
4373
4412
  }}</For2>
4374
4413
  </Block_wrapper_default></Show4></Show4>
@@ -4377,12 +4416,13 @@ function Block(props) {
4377
4416
  var Block_default = Block;
4378
4417
 
4379
4418
  // src/components/blocks/blocks-wrapper.tsx
4419
+ import { createMemo as createMemo5 } from "solid-js";
4380
4420
  import { Dynamic as Dynamic4 } from "solid-js/web";
4381
4421
  import { css } from "solid-styled-components";
4382
4422
  function BlocksWrapper(props) {
4383
- function className() {
4423
+ const className = createMemo5(() => {
4384
4424
  return "builder-blocks" + (!props.blocks?.length ? " no-blocks" : "");
4385
- }
4425
+ });
4386
4426
  function onClick() {
4387
4427
  if (isEditing() && !props.blocks?.length) {
4388
4428
  window.parent?.postMessage(
@@ -4456,12 +4496,12 @@ var Blocks_default = Blocks;
4456
4496
 
4457
4497
  // src/blocks/columns/columns.tsx
4458
4498
  function Columns(props) {
4459
- const [gutterSize, setGutterSize] = createSignal5(
4499
+ const [gutterSize, setGutterSize] = createSignal6(
4460
4500
  typeof props.space === "number" ? props.space || 0 : 20
4461
4501
  );
4462
- const [cols, setCols] = createSignal5(props.columns || []);
4463
- const [stackAt, setStackAt] = createSignal5(props.stackColumnsAt || "tablet");
4464
- const [flexDir, setFlexDir] = createSignal5(
4502
+ const [cols, setCols] = createSignal6(props.columns || []);
4503
+ const [stackAt, setStackAt] = createSignal6(props.stackColumnsAt || "tablet");
4504
+ const [flexDir, setFlexDir] = createSignal6(
4465
4505
  props.stackColumnsAt === "never" ? "row" : props.reverseColumnsWhenStacked ? "column-reverse" : "column"
4466
4506
  );
4467
4507
  function getWidth(index) {
@@ -4483,7 +4523,7 @@ function Columns(props) {
4483
4523
  }) {
4484
4524
  return stackAt() === "never" ? desktopStyle : stackedStyle;
4485
4525
  }
4486
- function columnsCssVars() {
4526
+ const columnsCssVars = createMemo6(() => {
4487
4527
  return {
4488
4528
  "--flex-dir": flexDir(),
4489
4529
  "--flex-dir-tablet": getTabletStyle({
@@ -4491,7 +4531,7 @@ function Columns(props) {
4491
4531
  desktopStyle: "row"
4492
4532
  })
4493
4533
  };
4494
- }
4534
+ });
4495
4535
  function columnCssVars(index) {
4496
4536
  const gutter = index === 0 ? 0 : gutterSize();
4497
4537
  const width = getColumnCssWidth(index);
@@ -4532,7 +4572,7 @@ function Columns(props) {
4532
4572
  );
4533
4573
  return breakpointSizes[size].max;
4534
4574
  }
4535
- function columnsStyles() {
4575
+ const columnsStyles = createMemo6(() => {
4536
4576
  return `
4537
4577
  @media (max-width: ${getWidthForBreakpointSize("medium")}px) {
4538
4578
  .${props.builderBlock.id}-breakpoints {
@@ -4558,7 +4598,7 @@ function Columns(props) {
4558
4598
  }
4559
4599
  },
4560
4600
  `;
4561
- }
4601
+ });
4562
4602
  return <div
4563
4603
  class={`builder-columns ${props.builderBlock.id}-breakpoints ` + css2({
4564
4604
  display: "flex",
@@ -4605,7 +4645,7 @@ function FragmentComponent(props) {
4605
4645
  var fragment_default = FragmentComponent;
4606
4646
 
4607
4647
  // src/blocks/image/image.tsx
4608
- import { Show as Show7 } from "solid-js";
4648
+ import { Show as Show7, createMemo as createMemo7 } from "solid-js";
4609
4649
  import { css as css3 } from "solid-styled-components";
4610
4650
 
4611
4651
  // src/blocks/image/image.helpers.ts
@@ -4657,7 +4697,7 @@ function getSrcSet(url) {
4657
4697
 
4658
4698
  // src/blocks/image/image.tsx
4659
4699
  function Image(props) {
4660
- function srcSetToUse() {
4700
+ const srcSetToUse = createMemo7(() => {
4661
4701
  const imageToUse = props.image || props.src;
4662
4702
  const url = imageToUse;
4663
4703
  if (!url || // We can auto add srcset for cdn.builder.io and shopify
@@ -4673,15 +4713,15 @@ function Image(props) {
4673
4713
  return getSrcSet(url);
4674
4714
  }
4675
4715
  return getSrcSet(url);
4676
- }
4677
- function webpSrcSet() {
4716
+ });
4717
+ const webpSrcSet = createMemo7(() => {
4678
4718
  if (srcSetToUse()?.match(/builder\.io/) && !props.noWebp) {
4679
4719
  return srcSetToUse().replace(/\?/g, "?format=webp&");
4680
4720
  } else {
4681
4721
  return "";
4682
4722
  }
4683
- }
4684
- function aspectRatioCss() {
4723
+ });
4724
+ const aspectRatioCss = createMemo7(() => {
4685
4725
  const aspectRatioStyles = {
4686
4726
  position: "absolute",
4687
4727
  height: "100%",
@@ -4691,7 +4731,7 @@ function Image(props) {
4691
4731
  };
4692
4732
  const out = props.aspectRatio ? aspectRatioStyles : void 0;
4693
4733
  return out;
4694
- }
4734
+ });
4695
4735
  return <>
4696
4736
  <picture>
4697
4737
  <Show7 when={webpSrcSet()}><source type="image/webp" srcset={webpSrcSet()} /></Show7>
@@ -4702,7 +4742,7 @@ function Image(props) {
4702
4742
  })}
4703
4743
  loading="lazy"
4704
4744
  alt={props.altText}
4705
- role={props.altText ? "presentation" : void 0}
4745
+ role={props.altText ? void 0 : "presentation"}
4706
4746
  style={{
4707
4747
  "object-position": props.backgroundPosition || "center",
4708
4748
  "object-fit": props.backgroundSize || "cover",
@@ -4764,10 +4804,10 @@ function SectionComponent(props) {
4764
4804
  var section_default = SectionComponent;
4765
4805
 
4766
4806
  // src/blocks/symbol/symbol.tsx
4767
- import { onMount as onMount5, on as on3, createEffect as createEffect3, createSignal as createSignal15 } from "solid-js";
4807
+ import { onMount as onMount5, on as on3, createEffect as createEffect3, createMemo as createMemo16, createSignal as createSignal16 } from "solid-js";
4768
4808
 
4769
4809
  // src/components/content-variants/content-variants.tsx
4770
- import { Show as Show12, For as For7, onMount as onMount4, createSignal as createSignal14 } from "solid-js";
4810
+ import { Show as Show12, For as For7, onMount as onMount4, createSignal as createSignal15, createMemo as createMemo15 } from "solid-js";
4771
4811
 
4772
4812
  // src/helpers/url.ts
4773
4813
  var getTopLevelDomain = (host) => {
@@ -4961,7 +5001,7 @@ var handleABTesting = async ({
4961
5001
  var getDefaultCanTrack = (canTrack) => checkIsDefined(canTrack) ? canTrack : true;
4962
5002
 
4963
5003
  // src/components/content/content.tsx
4964
- import { Show as Show11, createSignal as createSignal13 } from "solid-js";
5004
+ import { Show as Show11, createSignal as createSignal14 } from "solid-js";
4965
5005
 
4966
5006
  // src/blocks/button/component-info.ts
4967
5007
  var componentInfo = {
@@ -5521,10 +5561,10 @@ var componentInfo9 = {
5521
5561
  };
5522
5562
 
5523
5563
  // src/blocks/custom-code/custom-code.tsx
5524
- import { onMount as onMount2, createSignal as createSignal7 } from "solid-js";
5564
+ import { onMount as onMount2, createSignal as createSignal8 } from "solid-js";
5525
5565
  function CustomCode(props) {
5526
- const [scriptsInserted, setScriptsInserted] = createSignal7([]);
5527
- const [scriptsRun, setScriptsRun] = createSignal7([]);
5566
+ const [scriptsInserted, setScriptsInserted] = createSignal8([]);
5567
+ const [scriptsRun, setScriptsRun] = createSignal8([]);
5528
5568
  let elementRef;
5529
5569
  onMount2(() => {
5530
5570
  if (!elementRef?.getElementsByTagName || typeof window === "undefined") {
@@ -5605,7 +5645,7 @@ var componentInfo10 = {
5605
5645
  };
5606
5646
 
5607
5647
  // src/blocks/embed/embed.tsx
5608
- import { on, createEffect, createSignal as createSignal8 } from "solid-js";
5648
+ import { on, createEffect, createMemo as createMemo9, createSignal as createSignal9 } from "solid-js";
5609
5649
 
5610
5650
  // src/blocks/embed/helpers.ts
5611
5651
  var SCRIPT_MIME_TYPES = ["text/javascript", "application/javascript", "application/ecmascript"];
@@ -5613,9 +5653,9 @@ var isJsScript = (script) => SCRIPT_MIME_TYPES.includes(script.type);
5613
5653
 
5614
5654
  // src/blocks/embed/embed.tsx
5615
5655
  function Embed(props) {
5616
- const [scriptsInserted, setScriptsInserted] = createSignal8([]);
5617
- const [scriptsRun, setScriptsRun] = createSignal8([]);
5618
- const [ranInitFn, setRanInitFn] = createSignal8(false);
5656
+ const [scriptsInserted, setScriptsInserted] = createSignal9([]);
5657
+ const [scriptsRun, setScriptsRun] = createSignal9([]);
5658
+ const [ranInitFn, setRanInitFn] = createSignal9(false);
5619
5659
  function findAndRunScripts() {
5620
5660
  if (!elem || !elem.getElementsByTagName)
5621
5661
  return;
@@ -5638,13 +5678,17 @@ function Embed(props) {
5638
5678
  }
5639
5679
  }
5640
5680
  let elem;
5681
+ const onUpdateFn_0_elem = createMemo9(() => elem);
5682
+ const onUpdateFn_0_ranInitFn__ = createMemo9(() => ranInitFn());
5641
5683
  function onUpdateFn_0() {
5642
5684
  if (elem && !ranInitFn()) {
5643
5685
  setRanInitFn(true);
5644
5686
  findAndRunScripts();
5645
5687
  }
5646
5688
  }
5647
- createEffect(on(() => [elem, ranInitFn()], onUpdateFn_0));
5689
+ createEffect(
5690
+ on(() => [onUpdateFn_0_elem(), onUpdateFn_0_ranInitFn__()], onUpdateFn_0)
5691
+ );
5648
5692
  return <div class="builder-embed" ref={elem} innerHTML={props.content} />;
5649
5693
  }
5650
5694
  var embed_default = Embed;
@@ -5884,7 +5928,7 @@ var componentInfo11 = {
5884
5928
  };
5885
5929
 
5886
5930
  // src/blocks/form/form/form.tsx
5887
- import { Show as Show8, For as For5, createSignal as createSignal9 } from "solid-js";
5931
+ import { Show as Show8, For as For5, createSignal as createSignal10 } from "solid-js";
5888
5932
  import { css as css4 } from "solid-styled-components";
5889
5933
 
5890
5934
  // src/functions/get-env.ts
@@ -5902,9 +5946,9 @@ var get = (obj, path, defaultValue) => {
5902
5946
 
5903
5947
  // src/blocks/form/form/form.tsx
5904
5948
  function FormComponent(props) {
5905
- const [formState, setFormState] = createSignal9("unsubmitted");
5906
- const [responseData, setResponseData] = createSignal9(null);
5907
- const [formErrorMessage, setFormErrorMessage] = createSignal9("");
5949
+ const [formState, setFormState] = createSignal10("unsubmitted");
5950
+ const [responseData, setResponseData] = createSignal10(null);
5951
+ const [formErrorMessage, setFormErrorMessage] = createSignal10("");
5908
5952
  function mergeNewRootState(newData) {
5909
5953
  const combinedState = {
5910
5954
  ...props.builderContext.rootState,
@@ -6420,9 +6464,9 @@ var componentInfo16 = {
6420
6464
  };
6421
6465
 
6422
6466
  // src/blocks/video/video.tsx
6423
- import { Show as Show9 } from "solid-js";
6467
+ import { Show as Show9, createMemo as createMemo11 } from "solid-js";
6424
6468
  function Video(props) {
6425
- function videoProps() {
6469
+ const videoProps = createMemo11(() => {
6426
6470
  return {
6427
6471
  ...props.autoPlay === true ? {
6428
6472
  autoPlay: true
@@ -6440,12 +6484,12 @@ function Video(props) {
6440
6484
  playsInline: true
6441
6485
  } : {}
6442
6486
  };
6443
- }
6444
- function spreadProps() {
6487
+ });
6488
+ const spreadProps = createMemo11(() => {
6445
6489
  return {
6446
6490
  ...videoProps()
6447
6491
  };
6448
- }
6492
+ });
6449
6493
  return <div
6450
6494
  style={{
6451
6495
  position: "relative"
@@ -6635,7 +6679,14 @@ function InlinedScript(props) {
6635
6679
  var Inlined_script_default = InlinedScript;
6636
6680
 
6637
6681
  // src/components/content/components/enable-editor.tsx
6638
- import { Show as Show10, onMount as onMount3, on as on2, createEffect as createEffect2, createSignal as createSignal11 } from "solid-js";
6682
+ import {
6683
+ Show as Show10,
6684
+ onMount as onMount3,
6685
+ on as on2,
6686
+ createEffect as createEffect2,
6687
+ createMemo as createMemo12,
6688
+ createSignal as createSignal12
6689
+ } from "solid-js";
6639
6690
  import { Dynamic as Dynamic5 } from "solid-js/web";
6640
6691
 
6641
6692
  // src/helpers/preview-lru-cache/get.ts
@@ -7118,7 +7169,7 @@ function isFromTrustedHost(trustedHosts, e) {
7118
7169
  }
7119
7170
 
7120
7171
  // src/constants/sdk-version.ts
7121
- var SDK_VERSION = "0.14.5";
7172
+ var SDK_VERSION = "1.0.12";
7122
7173
 
7123
7174
  // src/functions/register.ts
7124
7175
  var registry = {};
@@ -7316,15 +7367,15 @@ var subscribeToEditor = (model, callback, options) => {
7316
7367
 
7317
7368
  // src/components/content/components/enable-editor.tsx
7318
7369
  function EnableEditor(props) {
7319
- const [forceReRenderCount, setForceReRenderCount] = createSignal11(0);
7320
- const [firstRender, setFirstRender] = createSignal11(true);
7321
- const [lastUpdated, setLastUpdated] = createSignal11(0);
7322
- const [shouldSendResetCookie, setShouldSendResetCookie] = createSignal11(false);
7323
- const [ContentWrapper, setContentWrapper] = createSignal11(
7370
+ const [forceReRenderCount, setForceReRenderCount] = createSignal12(0);
7371
+ const [firstRender, setFirstRender] = createSignal12(true);
7372
+ const [lastUpdated, setLastUpdated] = createSignal12(0);
7373
+ const [shouldSendResetCookie, setShouldSendResetCookie] = createSignal12(false);
7374
+ const [ContentWrapper, setContentWrapper] = createSignal12(
7324
7375
  props.contentWrapper || "div"
7325
7376
  );
7326
- const [httpReqsData, setHttpReqsData] = createSignal11({});
7327
- const [clicked, setClicked] = createSignal11(false);
7377
+ const [httpReqsData, setHttpReqsData] = createSignal12({});
7378
+ const [clicked, setClicked] = createSignal12(false);
7328
7379
  function mergeNewRootState(newData) {
7329
7380
  const combinedState = {
7330
7381
  ...props.builderContextSignal.rootState,
@@ -7395,7 +7446,11 @@ function EnableEditor(props) {
7395
7446
  context: props.context || {},
7396
7447
  localState: void 0,
7397
7448
  rootState: props.builderContextSignal.rootState,
7398
- rootSetState: props.builderContextSignal.rootSetState
7449
+ rootSetState: props.builderContextSignal.rootSetState,
7450
+ /**
7451
+ * We don't want to cache the result of the JS code, since it's arbitrary side effect code.
7452
+ */
7453
+ enableCache: false
7399
7454
  });
7400
7455
  }
7401
7456
  }
@@ -7420,13 +7475,16 @@ function EnableEditor(props) {
7420
7475
  function evalExpression(expression) {
7421
7476
  return expression.replace(
7422
7477
  /{{([^}]+)}}/g,
7423
- (_match, group) => evaluate({
7424
- code: group,
7425
- context: props.context || {},
7426
- localState: void 0,
7427
- rootState: props.builderContextSignal.rootState,
7428
- rootSetState: props.builderContextSignal.rootSetState
7429
- })
7478
+ (_match, group) => String(
7479
+ evaluate({
7480
+ code: group,
7481
+ context: props.context || {},
7482
+ localState: void 0,
7483
+ rootState: props.builderContextSignal.rootState,
7484
+ rootSetState: props.builderContextSignal.rootSetState,
7485
+ enableCache: true
7486
+ })
7487
+ )
7430
7488
  );
7431
7489
  }
7432
7490
  function handleRequest({ url, key }) {
@@ -7542,40 +7600,63 @@ function EnableEditor(props) {
7542
7600
  runHttpRequests();
7543
7601
  emitStateUpdate();
7544
7602
  });
7603
+ const onUpdateFn_0_props_content = createMemo12(() => props.content);
7545
7604
  function onUpdateFn_0() {
7546
7605
  if (props.content) {
7547
7606
  mergeNewContent(props.content);
7548
7607
  }
7549
7608
  }
7550
- createEffect2(on2(() => [props.content], onUpdateFn_0));
7609
+ createEffect2(on2(() => [onUpdateFn_0_props_content()], onUpdateFn_0));
7610
+ const onUpdateFn_1_shouldSendResetCookie__ = createMemo12(
7611
+ () => shouldSendResetCookie()
7612
+ );
7551
7613
  function onUpdateFn_1() {
7552
7614
  }
7553
- createEffect2(on2(() => [shouldSendResetCookie()], onUpdateFn_1));
7615
+ createEffect2(
7616
+ on2(() => [onUpdateFn_1_shouldSendResetCookie__()], onUpdateFn_1)
7617
+ );
7618
+ const onUpdateFn_2_props_builderContextSignal_content__data__jsCode = createMemo12(() => props.builderContextSignal.content?.data?.jsCode);
7554
7619
  function onUpdateFn_2() {
7555
7620
  evaluateJsCode();
7556
7621
  }
7557
7622
  createEffect2(
7558
- on2(() => [props.builderContextSignal.content?.data?.jsCode], onUpdateFn_2)
7623
+ on2(
7624
+ () => [onUpdateFn_2_props_builderContextSignal_content__data__jsCode()],
7625
+ onUpdateFn_2
7626
+ )
7559
7627
  );
7628
+ const onUpdateFn_3_props_builderContextSignal_content__data__httpRequests = createMemo12(() => props.builderContextSignal.content?.data?.httpRequests);
7560
7629
  function onUpdateFn_3() {
7561
7630
  runHttpRequests();
7562
7631
  }
7563
7632
  createEffect2(
7564
7633
  on2(
7565
- () => [props.builderContextSignal.content?.data?.httpRequests],
7634
+ () => [
7635
+ onUpdateFn_3_props_builderContextSignal_content__data__httpRequests()
7636
+ ],
7566
7637
  onUpdateFn_3
7567
7638
  )
7568
7639
  );
7640
+ const onUpdateFn_4_props_builderContextSignal_rootState = createMemo12(
7641
+ () => props.builderContextSignal.rootState
7642
+ );
7569
7643
  function onUpdateFn_4() {
7570
7644
  emitStateUpdate();
7571
7645
  }
7572
- createEffect2(on2(() => [props.builderContextSignal.rootState], onUpdateFn_4));
7646
+ createEffect2(
7647
+ on2(
7648
+ () => [onUpdateFn_4_props_builderContextSignal_rootState()],
7649
+ onUpdateFn_4
7650
+ )
7651
+ );
7652
+ const onUpdateFn_5_props_data = createMemo12(() => props.data);
7573
7653
  function onUpdateFn_5() {
7574
7654
  if (props.data) {
7575
7655
  mergeNewRootState(props.data);
7576
7656
  }
7577
7657
  }
7578
- createEffect2(on2(() => [props.data], onUpdateFn_5));
7658
+ createEffect2(on2(() => [onUpdateFn_5_props_data()], onUpdateFn_5));
7659
+ const onUpdateFn_6_props_locale = createMemo12(() => props.locale);
7579
7660
  function onUpdateFn_6() {
7580
7661
  if (props.locale) {
7581
7662
  mergeNewRootState({
@@ -7583,7 +7664,7 @@ function EnableEditor(props) {
7583
7664
  });
7584
7665
  }
7585
7666
  }
7586
- createEffect2(on2(() => [props.locale], onUpdateFn_6));
7667
+ createEffect2(on2(() => [onUpdateFn_6_props_locale()], onUpdateFn_6));
7587
7668
  return <builder_context_default.Provider value={props.builderContextSignal}><Show10 when={props.builderContextSignal.content}><Dynamic5
7588
7669
  class={`variant-${props.content?.testVariationId || props.content?.id}`}
7589
7670
  {...{}}
@@ -7604,7 +7685,7 @@ function EnableEditor(props) {
7604
7685
  var Enable_editor_default = EnableEditor;
7605
7686
 
7606
7687
  // src/components/content/components/styles.tsx
7607
- import { createSignal as createSignal12 } from "solid-js";
7688
+ import { createSignal as createSignal13 } from "solid-js";
7608
7689
 
7609
7690
  // src/components/content/components/styles.helpers.ts
7610
7691
  var getCssFromFont = (font) => {
@@ -7663,7 +7744,7 @@ var getCss = ({
7663
7744
 
7664
7745
  // src/components/content/components/styles.tsx
7665
7746
  function ContentStyles(props) {
7666
- const [injectedStyles, setInjectedStyles] = createSignal12(
7747
+ const [injectedStyles, setInjectedStyles] = createSignal13(
7667
7748
  `
7668
7749
  ${getCss({
7669
7750
  cssCode: props.cssCode,
@@ -7733,7 +7814,7 @@ var getContentInitialValue = ({
7733
7814
 
7734
7815
  // src/components/content/content.tsx
7735
7816
  function ContentComponent(props) {
7736
- const [scriptStr, setScriptStr] = createSignal13(
7817
+ const [scriptStr, setScriptStr] = createSignal14(
7737
7818
  getUpdateVariantVisibilityScript({
7738
7819
  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion, @typescript-eslint/no-non-null-asserted-optional-chain
7739
7820
  variationId: props.content?.testVariationId,
@@ -7741,7 +7822,7 @@ function ContentComponent(props) {
7741
7822
  contentId: props.content?.id
7742
7823
  })
7743
7824
  );
7744
- const [registeredComponents, setRegisteredComponents] = createSignal13(
7825
+ const [registeredComponents, setRegisteredComponents] = createSignal14(
7745
7826
  [
7746
7827
  ...getDefaultRegisteredComponents(),
7747
7828
  ...props.customComponents || []
@@ -7756,7 +7837,7 @@ function ContentComponent(props) {
7756
7837
  {}
7757
7838
  )
7758
7839
  );
7759
- const [builderContextSignal, setBuilderContextSignal] = createSignal13({
7840
+ const [builderContextSignal, setBuilderContextSignal] = createSignal14({
7760
7841
  content: getContentInitialValue({
7761
7842
  content: props.content,
7762
7843
  data: props.data
@@ -7832,13 +7913,13 @@ var Content_default = ContentComponent;
7832
7913
 
7833
7914
  // src/components/content-variants/content-variants.tsx
7834
7915
  function ContentVariants(props) {
7835
- const [shouldRenderVariants, setShouldRenderVariants] = createSignal14(
7916
+ const [shouldRenderVariants, setShouldRenderVariants] = createSignal15(
7836
7917
  checkShouldRenderVariants({
7837
7918
  canTrack: getDefaultCanTrack(props.canTrack),
7838
7919
  content: props.content
7839
7920
  })
7840
7921
  );
7841
- function updateCookieAndStylesScriptStr() {
7922
+ const updateCookieAndStylesScriptStr = createMemo15(() => {
7842
7923
  return getUpdateCookieAndStylesScript(
7843
7924
  getVariants(props.content).map((value) => ({
7844
7925
  id: value.testVariationId,
@@ -7846,11 +7927,11 @@ function ContentVariants(props) {
7846
7927
  })),
7847
7928
  props.content?.id || ""
7848
7929
  );
7849
- }
7850
- function hideVariantsStyleString() {
7930
+ });
7931
+ const hideVariantsStyleString = createMemo15(() => {
7851
7932
  return getVariants(props.content).map((value) => `.variant-${value.testVariationId} { display: none; } `).join("");
7852
- }
7853
- function defaultContent() {
7933
+ });
7934
+ const defaultContent = createMemo15(() => {
7854
7935
  return shouldRenderVariants() ? {
7855
7936
  ...props.content,
7856
7937
  testVariationId: props.content?.id
@@ -7858,7 +7939,7 @@ function ContentVariants(props) {
7858
7939
  item: props.content,
7859
7940
  canTrack: getDefaultCanTrack(props.canTrack)
7860
7941
  });
7861
- }
7942
+ });
7862
7943
  onMount4(() => {
7863
7944
  setShouldRenderVariants(false);
7864
7945
  });
@@ -7948,15 +8029,15 @@ var fetchSymbolContent = async ({
7948
8029
 
7949
8030
  // src/blocks/symbol/symbol.tsx
7950
8031
  function Symbol2(props) {
7951
- const [contentToUse, setContentToUse] = createSignal15(props.symbol?.content);
7952
- function className() {
8032
+ const [contentToUse, setContentToUse] = createSignal16(props.symbol?.content);
8033
+ const className = createMemo16(() => {
7953
8034
  return [
7954
8035
  ...[props.attributes[getClassPropName()]],
7955
8036
  "builder-symbol",
7956
8037
  props.symbol?.inline ? "builder-inline-symbol" : void 0,
7957
8038
  props.symbol?.dynamic || props.dynamic ? "builder-dynamic-symbol" : void 0
7958
8039
  ].filter(Boolean).join(" ");
7959
- }
8040
+ });
7960
8041
  function setContent() {
7961
8042
  if (contentToUse())
7962
8043
  return;
@@ -7970,12 +8051,12 @@ function Symbol2(props) {
7970
8051
  });
7971
8052
  }
7972
8053
  onMount5(() => {
7973
- setContent();
7974
8054
  });
8055
+ const onUpdateFn_0_props_symbol = createMemo16(() => props.symbol);
7975
8056
  function onUpdateFn_0() {
7976
8057
  setContent();
7977
8058
  }
7978
- createEffect3(on3(() => [props.symbol], onUpdateFn_0));
8059
+ createEffect3(on3(() => [onUpdateFn_0_props_symbol()], onUpdateFn_0));
7979
8060
  return <div class={className()} {...{}} {...props.attributes} {...{}}><Content_variants_default
7980
8061
  __isNestedRender={true}
7981
8062
  apiVersion={props.builderContext.apiVersion}