@builder.io/sdk-solid 0.14.6 → 1.0.13

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.
@@ -71,7 +71,7 @@ function Button(props) {
71
71
  var button_default = Button;
72
72
 
73
73
  // src/blocks/columns/columns.tsx
74
- import { Show as Show6, For as For4, createSignal as createSignal5 } from "solid-js";
74
+ import { Show as Show6, For as For4, createSignal as createSignal6, createMemo as createMemo6 } from "solid-js";
75
75
  import { css as css2 } from "solid-styled-components";
76
76
 
77
77
  // src/components/blocks/blocks.tsx
@@ -99,7 +99,7 @@ import { createContext as createContext2 } from "solid-js";
99
99
  var components_context_default = createContext2({ registeredComponents: {} });
100
100
 
101
101
  // src/components/block/block.tsx
102
- import { Show as Show4, For as For2, onMount, createSignal as createSignal4 } from "solid-js";
102
+ import { Show as Show4, For as For2, onMount, createMemo as createMemo4 } from "solid-js";
103
103
 
104
104
  // src/functions/get-block-component-options.ts
105
105
  function getBlockComponentOptions(block) {
@@ -268,7 +268,7 @@ function flattenState({
268
268
  return localState[prop];
269
269
  }
270
270
  const val = target[prop];
271
- if (typeof val === "object") {
271
+ if (typeof val === "object" && val !== null) {
272
272
  return flattenState({
273
273
  rootState: val,
274
274
  localState: void 0,
@@ -320,6 +320,30 @@ var shouldForceBrowserRuntimeInNode = () => {
320
320
  var chooseBrowserOrServerEval = (args) => isBrowser() || shouldForceBrowserRuntimeInNode() ? runInBrowser(args) : runInBrowser(args);
321
321
 
322
322
  // src/functions/evaluate/evaluate.ts
323
+ var EvalCache = class _EvalCache {
324
+ static cacheLimit = 20;
325
+ static cache = /* @__PURE__ */ new Map();
326
+ static getCacheKey(args) {
327
+ return JSON.stringify({
328
+ ...args,
329
+ // replace the event with a random number to break cache
330
+ // thats because we can't serialize the event object due to circular refs in DOM node refs.
331
+ event: args.event ? Math.random() : void 0
332
+ });
333
+ }
334
+ static getCachedValue(key) {
335
+ const cachedVal = _EvalCache.cache.get(key);
336
+ return cachedVal;
337
+ }
338
+ static setCachedValue(key, value) {
339
+ if (_EvalCache.cache.size > 20) {
340
+ _EvalCache.cache.delete(_EvalCache.cache.keys().next().value);
341
+ }
342
+ _EvalCache.cache.set(key, {
343
+ value
344
+ });
345
+ }
346
+ };
323
347
  function evaluate({
324
348
  code,
325
349
  context,
@@ -327,11 +351,12 @@ function evaluate({
327
351
  rootState,
328
352
  rootSetState,
329
353
  event,
330
- isExpression = true
354
+ isExpression = true,
355
+ enableCache
331
356
  }) {
332
357
  if (code === "") {
333
358
  logger.warn("Skipping evaluation of empty code block.");
334
- return;
359
+ return void 0;
335
360
  }
336
361
  const args = {
337
362
  code: parseCode(code, {
@@ -344,8 +369,20 @@ function evaluate({
344
369
  rootState,
345
370
  localState
346
371
  };
372
+ if (enableCache) {
373
+ const cacheKey = EvalCache.getCacheKey(args);
374
+ const cachedValue = EvalCache.getCachedValue(cacheKey);
375
+ if (cachedValue) {
376
+ return cachedValue.value;
377
+ }
378
+ }
347
379
  try {
348
- return chooseBrowserOrServerEval(args);
380
+ const newEval = chooseBrowserOrServerEval(args);
381
+ if (enableCache) {
382
+ const cacheKey = EvalCache.getCacheKey(args);
383
+ EvalCache.setCachedValue(cacheKey, newEval);
384
+ }
385
+ return newEval;
349
386
  } catch (e) {
350
387
  logger.error("Failed code evaluation: " + e.message, {
351
388
  code
@@ -400,7 +437,8 @@ var evaluateBindings = ({
400
437
  localState,
401
438
  rootState,
402
439
  rootSetState,
403
- context
440
+ context,
441
+ enableCache: true
404
442
  });
405
443
  set(copied, binding, value);
406
444
  }
@@ -634,6 +672,70 @@ function bindScrollInViewAnimation(animation) {
634
672
  });
635
673
  }
636
674
 
675
+ // src/functions/camel-to-kebab-case.ts
676
+ var camelToKebabCase = (string) => string.replace(/([a-z0-9]|(?=[A-Z]))([A-Z])/g, "$1-$2").toLowerCase();
677
+
678
+ // src/helpers/css.ts
679
+ var convertStyleMapToCSSArray = (style) => {
680
+ const cssProps = Object.entries(style).map(([key, value]) => {
681
+ if (typeof value === "string") {
682
+ return `${camelToKebabCase(key)}: ${value};`;
683
+ } else {
684
+ return void 0;
685
+ }
686
+ });
687
+ return cssProps.filter(checkIsDefined);
688
+ };
689
+ var convertStyleMapToCSS = (style) => convertStyleMapToCSSArray(style).join("\n");
690
+ var createCssClass = ({
691
+ mediaQuery,
692
+ className,
693
+ styles
694
+ }) => {
695
+ const cssClass = `.${className} {
696
+ ${convertStyleMapToCSS(styles)}
697
+ }`;
698
+ if (mediaQuery) {
699
+ return `${mediaQuery} {
700
+ ${cssClass}
701
+ }`;
702
+ } else {
703
+ return cssClass;
704
+ }
705
+ };
706
+
707
+ // src/functions/transform-style-property.ts
708
+ function transformStyleProperty({
709
+ style
710
+ }) {
711
+ return style;
712
+ }
713
+
714
+ // src/functions/get-style.ts
715
+ var getStyle = ({
716
+ block,
717
+ context
718
+ }) => {
719
+ return mapStyleObjToStrIfNeeded(transformStyleProperty({
720
+ style: block.style || {},
721
+ context,
722
+ block
723
+ }));
724
+ };
725
+ function mapStyleObjToStrIfNeeded(style) {
726
+ switch (TARGET) {
727
+ case "svelte":
728
+ case "vue":
729
+ case "solid":
730
+ return convertStyleMapToCSSArray(style).join(" ");
731
+ case "qwik":
732
+ case "reactNative":
733
+ case "react":
734
+ case "rsc":
735
+ return style;
736
+ }
737
+ }
738
+
637
739
  // src/components/block/block.helpers.ts
638
740
  var getComponent = ({
639
741
  block,
@@ -677,7 +779,8 @@ var getRepeatItemData = ({
677
779
  localState: context.localState,
678
780
  rootState: context.rootState,
679
781
  rootSetState: context.rootSetState,
680
- context: context.context
782
+ context: context.context,
783
+ enableCache: true
681
784
  });
682
785
  if (!Array.isArray(itemsArray)) {
683
786
  return void 0;
@@ -701,7 +804,7 @@ var getRepeatItemData = ({
701
804
  };
702
805
 
703
806
  // src/components/block/components/block-styles.tsx
704
- import { Show as Show2 } from "solid-js";
807
+ import { Show as Show2, createMemo } from "solid-js";
705
808
 
706
809
  // src/constants/device-sizes.ts
707
810
  var SIZES = {
@@ -752,38 +855,6 @@ var getSizesForBreakpoints = ({
752
855
  return newSizes;
753
856
  };
754
857
 
755
- // src/functions/camel-to-kebab-case.ts
756
- var camelToKebabCase = (string) => string.replace(/([a-z0-9]|(?=[A-Z]))([A-Z])/g, "$1-$2").toLowerCase();
757
-
758
- // src/helpers/css.ts
759
- var convertStyleMapToCSSArray = (style) => {
760
- const cssProps = Object.entries(style).map(([key, value]) => {
761
- if (typeof value === "string") {
762
- return `${camelToKebabCase(key)}: ${value};`;
763
- } else {
764
- return void 0;
765
- }
766
- });
767
- return cssProps.filter(checkIsDefined);
768
- };
769
- var convertStyleMapToCSS = (style) => convertStyleMapToCSSArray(style).join("\n");
770
- var createCssClass = ({
771
- mediaQuery,
772
- className,
773
- styles
774
- }) => {
775
- const cssClass = `.${className} {
776
- ${convertStyleMapToCSS(styles)}
777
- }`;
778
- if (mediaQuery) {
779
- return `${mediaQuery} {
780
- ${cssClass}
781
- }`;
782
- } else {
783
- return cssClass;
784
- }
785
- };
786
-
787
858
  // src/components/inlined-styles.tsx
788
859
  function InlinedStyles(props) {
789
860
  return <style innerHTML={props.styles} id={props.id} />;
@@ -792,7 +863,7 @@ var Inlined_styles_default = InlinedStyles;
792
863
 
793
864
  // src/components/block/components/block-styles.tsx
794
865
  function BlockStyles(props) {
795
- function canShowBlock() {
866
+ const canShowBlock = createMemo(() => {
796
867
  const processedBlock = getProcessedBlock({
797
868
  block: props.block,
798
869
  localState: props.context.localState,
@@ -808,8 +879,8 @@ function BlockStyles(props) {
808
879
  return processedBlock.show;
809
880
  }
810
881
  return true;
811
- }
812
- function css5() {
882
+ });
883
+ const css5 = createMemo(() => {
813
884
  const processedBlock = getProcessedBlock({
814
885
  block: props.block,
815
886
  localState: props.context.localState,
@@ -851,7 +922,7 @@ function BlockStyles(props) {
851
922
  )
852
923
  }) : "";
853
924
  return [largeStylesClass, mediumStylesClass, smallStylesClass].join(" ");
854
- }
925
+ });
855
926
  return <Show2 when={TARGET !== "reactNative" && css5() && canShowBlock()}><Inlined_styles_default styles={css5()} /></Show2>;
856
927
  }
857
928
  var Block_styles_default = BlockStyles;
@@ -870,7 +941,8 @@ var createEventHandler = (value, options) => (event) => evaluate({
870
941
  rootState: options.rootState,
871
942
  rootSetState: options.rootSetState,
872
943
  event,
873
- isExpression: false
944
+ isExpression: false,
945
+ enableCache: true
874
946
  });
875
947
 
876
948
  // src/functions/get-block-actions.ts
@@ -898,38 +970,6 @@ function getBlockActions(options) {
898
970
  return obj;
899
971
  }
900
972
 
901
- // src/functions/transform-style-property.ts
902
- function transformStyleProperty({
903
- style
904
- }) {
905
- return style;
906
- }
907
-
908
- // src/functions/get-style.ts
909
- var getStyle = ({
910
- block,
911
- context
912
- }) => {
913
- return mapStyleObjToStrIfNeeded(transformStyleProperty({
914
- style: block.style || {},
915
- context,
916
- block
917
- }));
918
- };
919
- function mapStyleObjToStrIfNeeded(style) {
920
- switch (TARGET) {
921
- case "svelte":
922
- case "vue":
923
- case "solid":
924
- return convertStyleMapToCSSArray(style).join(" ");
925
- case "qwik":
926
- case "reactNative":
927
- case "react":
928
- case "rsc":
929
- return style;
930
- }
931
- }
932
-
933
973
  // src/functions/transform-block-properties.ts
934
974
  function transformBlockProperties({
935
975
  properties
@@ -1089,21 +1129,20 @@ var Repeated_block_default = RepeatedBlock;
1089
1129
 
1090
1130
  // src/components/block/block.tsx
1091
1131
  function Block(props) {
1092
- const [childrenContext, setChildrenContext] = createSignal4(props.context);
1093
- function blockComponent() {
1132
+ const blockComponent = createMemo4(() => {
1094
1133
  return getComponent({
1095
1134
  block: props.block,
1096
1135
  context: props.context,
1097
1136
  registeredComponents: props.registeredComponents
1098
1137
  });
1099
- }
1100
- function repeatItem() {
1138
+ });
1139
+ const repeatItem = createMemo4(() => {
1101
1140
  return getRepeatItemData({
1102
1141
  block: props.block,
1103
1142
  context: props.context
1104
1143
  });
1105
- }
1106
- function processedBlock() {
1144
+ });
1145
+ const processedBlock = createMemo4(() => {
1107
1146
  return props.block.repeat?.collection ? props.block : getProcessedBlock({
1108
1147
  block: props.block,
1109
1148
  localState: props.context.localState,
@@ -1112,15 +1151,15 @@ function Block(props) {
1112
1151
  context: props.context.context,
1113
1152
  shouldEvaluateBindings: true
1114
1153
  });
1115
- }
1116
- function Tag() {
1154
+ });
1155
+ const Tag = createMemo4(() => {
1117
1156
  const shouldUseLink = props.block.tagName === "a" || processedBlock().properties?.href || processedBlock().href;
1118
1157
  if (shouldUseLink) {
1119
1158
  return props.linkComponent || "a";
1120
1159
  }
1121
1160
  return props.block.tagName || "div";
1122
- }
1123
- function canShowBlock() {
1161
+ });
1162
+ const canShowBlock = createMemo4(() => {
1124
1163
  if (props.block.repeat?.collection) {
1125
1164
  if (repeatItem()?.length)
1126
1165
  return true;
@@ -1129,12 +1168,12 @@ function Block(props) {
1129
1168
  const shouldHide = "hide" in processedBlock() ? processedBlock().hide : false;
1130
1169
  const shouldShow = "show" in processedBlock() ? processedBlock().show : true;
1131
1170
  return shouldShow && !shouldHide;
1132
- }
1133
- function childrenWithoutParentComponent() {
1171
+ });
1172
+ const childrenWithoutParentComponent = createMemo4(() => {
1134
1173
  const shouldRenderChildrenOutsideRef = !blockComponent()?.component && !repeatItem();
1135
1174
  return shouldRenderChildrenOutsideRef ? processedBlock().children ?? [] : [];
1136
- }
1137
- function componentRefProps() {
1175
+ });
1176
+ const componentRefProps = createMemo4(() => {
1138
1177
  return {
1139
1178
  blockChildren: processedBlock().children ?? [],
1140
1179
  componentRef: blockComponent()?.component,
@@ -1148,14 +1187,14 @@ function Block(props) {
1148
1187
  builderComponents: props.registeredComponents
1149
1188
  } : {}
1150
1189
  },
1151
- context: childrenContext(),
1190
+ context: props.context,
1152
1191
  linkComponent: props.linkComponent,
1153
1192
  registeredComponents: props.registeredComponents,
1154
1193
  builderBlock: processedBlock(),
1155
1194
  includeBlockProps: blockComponent()?.noWrap === true,
1156
1195
  isInteractive: !blockComponent()?.isRSC
1157
1196
  };
1158
- }
1197
+ });
1159
1198
  onMount(() => {
1160
1199
  const blockId = processedBlock().id;
1161
1200
  const animations = processedBlock().animations;
@@ -1217,9 +1256,9 @@ function Block(props) {
1217
1256
  return <Block
1218
1257
  key={child.id}
1219
1258
  block={child}
1220
- context={childrenContext()}
1221
1259
  registeredComponents={props.registeredComponents}
1222
1260
  linkComponent={props.linkComponent}
1261
+ context={props.context}
1223
1262
  />;
1224
1263
  }}</For2>
1225
1264
  </Block_wrapper_default></Show4></Show4>
@@ -1228,12 +1267,13 @@ function Block(props) {
1228
1267
  var Block_default = Block;
1229
1268
 
1230
1269
  // src/components/blocks/blocks-wrapper.tsx
1270
+ import { createMemo as createMemo5 } from "solid-js";
1231
1271
  import { Dynamic as Dynamic4 } from "solid-js/web";
1232
1272
  import { css } from "solid-styled-components";
1233
1273
  function BlocksWrapper(props) {
1234
- function className() {
1274
+ const className = createMemo5(() => {
1235
1275
  return "builder-blocks" + (!props.blocks?.length ? " no-blocks" : "");
1236
- }
1276
+ });
1237
1277
  function onClick() {
1238
1278
  if (isEditing() && !props.blocks?.length) {
1239
1279
  window.parent?.postMessage(
@@ -1307,12 +1347,12 @@ var Blocks_default = Blocks;
1307
1347
 
1308
1348
  // src/blocks/columns/columns.tsx
1309
1349
  function Columns(props) {
1310
- const [gutterSize, setGutterSize] = createSignal5(
1350
+ const [gutterSize, setGutterSize] = createSignal6(
1311
1351
  typeof props.space === "number" ? props.space || 0 : 20
1312
1352
  );
1313
- const [cols, setCols] = createSignal5(props.columns || []);
1314
- const [stackAt, setStackAt] = createSignal5(props.stackColumnsAt || "tablet");
1315
- const [flexDir, setFlexDir] = createSignal5(
1353
+ const [cols, setCols] = createSignal6(props.columns || []);
1354
+ const [stackAt, setStackAt] = createSignal6(props.stackColumnsAt || "tablet");
1355
+ const [flexDir, setFlexDir] = createSignal6(
1316
1356
  props.stackColumnsAt === "never" ? "row" : props.reverseColumnsWhenStacked ? "column-reverse" : "column"
1317
1357
  );
1318
1358
  function getWidth(index) {
@@ -1334,7 +1374,7 @@ function Columns(props) {
1334
1374
  }) {
1335
1375
  return stackAt() === "never" ? desktopStyle : stackedStyle;
1336
1376
  }
1337
- function columnsCssVars() {
1377
+ const columnsCssVars = createMemo6(() => {
1338
1378
  return {
1339
1379
  "--flex-dir": flexDir(),
1340
1380
  "--flex-dir-tablet": getTabletStyle({
@@ -1342,7 +1382,7 @@ function Columns(props) {
1342
1382
  desktopStyle: "row"
1343
1383
  })
1344
1384
  };
1345
- }
1385
+ });
1346
1386
  function columnCssVars(index) {
1347
1387
  const gutter = index === 0 ? 0 : gutterSize();
1348
1388
  const width = getColumnCssWidth(index);
@@ -1383,7 +1423,7 @@ function Columns(props) {
1383
1423
  );
1384
1424
  return breakpointSizes[size].max;
1385
1425
  }
1386
- function columnsStyles() {
1426
+ const columnsStyles = createMemo6(() => {
1387
1427
  return `
1388
1428
  @media (max-width: ${getWidthForBreakpointSize("medium")}px) {
1389
1429
  .${props.builderBlock.id}-breakpoints {
@@ -1409,7 +1449,7 @@ function Columns(props) {
1409
1449
  }
1410
1450
  },
1411
1451
  `;
1412
- }
1452
+ });
1413
1453
  return <div
1414
1454
  class={`builder-columns ${props.builderBlock.id}-breakpoints ` + css2({
1415
1455
  display: "flex",
@@ -1456,7 +1496,7 @@ function FragmentComponent(props) {
1456
1496
  var fragment_default = FragmentComponent;
1457
1497
 
1458
1498
  // src/blocks/image/image.tsx
1459
- import { Show as Show7 } from "solid-js";
1499
+ import { Show as Show7, createMemo as createMemo7 } from "solid-js";
1460
1500
  import { css as css3 } from "solid-styled-components";
1461
1501
 
1462
1502
  // src/blocks/image/image.helpers.ts
@@ -1508,7 +1548,7 @@ function getSrcSet(url) {
1508
1548
 
1509
1549
  // src/blocks/image/image.tsx
1510
1550
  function Image(props) {
1511
- function srcSetToUse() {
1551
+ const srcSetToUse = createMemo7(() => {
1512
1552
  const imageToUse = props.image || props.src;
1513
1553
  const url = imageToUse;
1514
1554
  if (!url || // We can auto add srcset for cdn.builder.io and shopify
@@ -1525,15 +1565,15 @@ function Image(props) {
1525
1565
  return getSrcSet(url);
1526
1566
  }
1527
1567
  return getSrcSet(url);
1528
- }
1529
- function webpSrcSet() {
1568
+ });
1569
+ const webpSrcSet = createMemo7(() => {
1530
1570
  if (srcSetToUse()?.match(/builder\.io/) && !props.noWebp) {
1531
1571
  return srcSetToUse().replace(/\?/g, "?format=webp&");
1532
1572
  } else {
1533
1573
  return "";
1534
1574
  }
1535
- }
1536
- function aspectRatioCss() {
1575
+ });
1576
+ const aspectRatioCss = createMemo7(() => {
1537
1577
  const aspectRatioStyles = {
1538
1578
  position: "absolute",
1539
1579
  height: "100%",
@@ -1543,7 +1583,7 @@ function Image(props) {
1543
1583
  };
1544
1584
  const out = props.aspectRatio ? aspectRatioStyles : void 0;
1545
1585
  return out;
1546
- }
1586
+ });
1547
1587
  return <>
1548
1588
  <picture>
1549
1589
  <Show7 when={webpSrcSet()}><source type="image/webp" srcset={webpSrcSet()} /></Show7>
@@ -1616,10 +1656,10 @@ function SectionComponent(props) {
1616
1656
  var section_default = SectionComponent;
1617
1657
 
1618
1658
  // src/blocks/symbol/symbol.tsx
1619
- import { onMount as onMount5, on as on3, createEffect as createEffect3, createSignal as createSignal15 } from "solid-js";
1659
+ import { onMount as onMount5, on as on3, createEffect as createEffect3, createMemo as createMemo16, createSignal as createSignal16 } from "solid-js";
1620
1660
 
1621
1661
  // src/components/content-variants/content-variants.tsx
1622
- import { Show as Show12, For as For7, onMount as onMount4, createSignal as createSignal14 } from "solid-js";
1662
+ import { Show as Show12, For as For7, onMount as onMount4, createSignal as createSignal15, createMemo as createMemo15 } from "solid-js";
1623
1663
 
1624
1664
  // src/helpers/url.ts
1625
1665
  var getTopLevelDomain = (host) => {
@@ -1813,7 +1853,7 @@ var handleABTesting = async ({
1813
1853
  var getDefaultCanTrack = (canTrack) => checkIsDefined(canTrack) ? canTrack : true;
1814
1854
 
1815
1855
  // src/components/content/content.tsx
1816
- import { Show as Show11, createSignal as createSignal13 } from "solid-js";
1856
+ import { Show as Show11, createSignal as createSignal14 } from "solid-js";
1817
1857
 
1818
1858
  // src/blocks/button/component-info.ts
1819
1859
  var componentInfo = {
@@ -2374,10 +2414,10 @@ var componentInfo9 = {
2374
2414
  };
2375
2415
 
2376
2416
  // src/blocks/custom-code/custom-code.tsx
2377
- import { onMount as onMount2, createSignal as createSignal7 } from "solid-js";
2417
+ import { onMount as onMount2, createSignal as createSignal8 } from "solid-js";
2378
2418
  function CustomCode(props) {
2379
- const [scriptsInserted, setScriptsInserted] = createSignal7([]);
2380
- const [scriptsRun, setScriptsRun] = createSignal7([]);
2419
+ const [scriptsInserted, setScriptsInserted] = createSignal8([]);
2420
+ const [scriptsRun, setScriptsRun] = createSignal8([]);
2381
2421
  let elementRef;
2382
2422
  onMount2(() => {
2383
2423
  if (!elementRef?.getElementsByTagName || typeof window === "undefined") {
@@ -2459,7 +2499,7 @@ var componentInfo10 = {
2459
2499
  };
2460
2500
 
2461
2501
  // src/blocks/embed/embed.tsx
2462
- import { on, createEffect, createSignal as createSignal8 } from "solid-js";
2502
+ import { on, createEffect, createMemo as createMemo9, createSignal as createSignal9 } from "solid-js";
2463
2503
 
2464
2504
  // src/blocks/embed/helpers.ts
2465
2505
  var SCRIPT_MIME_TYPES = ["text/javascript", "application/javascript", "application/ecmascript"];
@@ -2467,9 +2507,9 @@ var isJsScript = (script) => SCRIPT_MIME_TYPES.includes(script.type);
2467
2507
 
2468
2508
  // src/blocks/embed/embed.tsx
2469
2509
  function Embed(props) {
2470
- const [scriptsInserted, setScriptsInserted] = createSignal8([]);
2471
- const [scriptsRun, setScriptsRun] = createSignal8([]);
2472
- const [ranInitFn, setRanInitFn] = createSignal8(false);
2510
+ const [scriptsInserted, setScriptsInserted] = createSignal9([]);
2511
+ const [scriptsRun, setScriptsRun] = createSignal9([]);
2512
+ const [ranInitFn, setRanInitFn] = createSignal9(false);
2473
2513
  function findAndRunScripts() {
2474
2514
  if (!elem || !elem.getElementsByTagName)
2475
2515
  return;
@@ -2493,13 +2533,17 @@ function Embed(props) {
2493
2533
  }
2494
2534
  }
2495
2535
  let elem;
2536
+ const onUpdateFn_0_elem = createMemo9(() => elem);
2537
+ const onUpdateFn_0_ranInitFn__ = createMemo9(() => ranInitFn());
2496
2538
  function onUpdateFn_0() {
2497
2539
  if (elem && !ranInitFn()) {
2498
2540
  setRanInitFn(true);
2499
2541
  findAndRunScripts();
2500
2542
  }
2501
2543
  }
2502
- createEffect(on(() => [elem, ranInitFn()], onUpdateFn_0));
2544
+ createEffect(
2545
+ on(() => [onUpdateFn_0_elem(), onUpdateFn_0_ranInitFn__()], onUpdateFn_0)
2546
+ );
2503
2547
  return <div class="builder-embed" ref={elem} innerHTML={props.content} />;
2504
2548
  }
2505
2549
  var embed_default = Embed;
@@ -2739,7 +2783,7 @@ var componentInfo11 = {
2739
2783
  };
2740
2784
 
2741
2785
  // src/blocks/form/form/form.tsx
2742
- import { Show as Show8, For as For5, createSignal as createSignal9 } from "solid-js";
2786
+ import { Show as Show8, For as For5, createSignal as createSignal10 } from "solid-js";
2743
2787
  import { css as css4 } from "solid-styled-components";
2744
2788
 
2745
2789
  // src/functions/get-env.ts
@@ -2757,9 +2801,9 @@ var get = (obj, path, defaultValue) => {
2757
2801
 
2758
2802
  // src/blocks/form/form/form.tsx
2759
2803
  function FormComponent(props) {
2760
- const [formState, setFormState] = createSignal9("unsubmitted");
2761
- const [responseData, setResponseData] = createSignal9(null);
2762
- const [formErrorMessage, setFormErrorMessage] = createSignal9("");
2804
+ const [formState, setFormState] = createSignal10("unsubmitted");
2805
+ const [responseData, setResponseData] = createSignal10(null);
2806
+ const [formErrorMessage, setFormErrorMessage] = createSignal10("");
2763
2807
  function mergeNewRootState(newData) {
2764
2808
  const combinedState = {
2765
2809
  ...props.builderContext.rootState,
@@ -3275,9 +3319,9 @@ var componentInfo16 = {
3275
3319
  };
3276
3320
 
3277
3321
  // src/blocks/video/video.tsx
3278
- import { Show as Show9 } from "solid-js";
3322
+ import { Show as Show9, createMemo as createMemo11 } from "solid-js";
3279
3323
  function Video(props) {
3280
- function videoProps() {
3324
+ const videoProps = createMemo11(() => {
3281
3325
  return {
3282
3326
  ...props.autoPlay === true ? {
3283
3327
  autoPlay: true
@@ -3295,12 +3339,12 @@ function Video(props) {
3295
3339
  playsInline: true
3296
3340
  } : {}
3297
3341
  };
3298
- }
3299
- function spreadProps() {
3342
+ });
3343
+ const spreadProps = createMemo11(() => {
3300
3344
  return {
3301
3345
  ...videoProps()
3302
3346
  };
3303
- }
3347
+ });
3304
3348
  return <div
3305
3349
  style={{
3306
3350
  position: "relative"
@@ -3490,7 +3534,14 @@ function InlinedScript(props) {
3490
3534
  var Inlined_script_default = InlinedScript;
3491
3535
 
3492
3536
  // src/components/content/components/enable-editor.tsx
3493
- import { Show as Show10, onMount as onMount3, on as on2, createEffect as createEffect2, createSignal as createSignal11 } from "solid-js";
3537
+ import {
3538
+ Show as Show10,
3539
+ onMount as onMount3,
3540
+ on as on2,
3541
+ createEffect as createEffect2,
3542
+ createMemo as createMemo12,
3543
+ createSignal as createSignal12
3544
+ } from "solid-js";
3494
3545
  import { Dynamic as Dynamic5 } from "solid-js/web";
3495
3546
 
3496
3547
  // src/helpers/preview-lru-cache/get.ts
@@ -3978,7 +4029,7 @@ function isFromTrustedHost(trustedHosts, e) {
3978
4029
  }
3979
4030
 
3980
4031
  // src/constants/sdk-version.ts
3981
- var SDK_VERSION = "0.14.6";
4032
+ var SDK_VERSION = "1.0.13";
3982
4033
 
3983
4034
  // src/functions/register.ts
3984
4035
  var registry = {};
@@ -4177,15 +4228,15 @@ var subscribeToEditor = (model, callback, options) => {
4177
4228
 
4178
4229
  // src/components/content/components/enable-editor.tsx
4179
4230
  function EnableEditor(props) {
4180
- const [forceReRenderCount, setForceReRenderCount] = createSignal11(0);
4181
- const [firstRender, setFirstRender] = createSignal11(true);
4182
- const [lastUpdated, setLastUpdated] = createSignal11(0);
4183
- const [shouldSendResetCookie, setShouldSendResetCookie] = createSignal11(false);
4184
- const [ContentWrapper, setContentWrapper] = createSignal11(
4231
+ const [forceReRenderCount, setForceReRenderCount] = createSignal12(0);
4232
+ const [firstRender, setFirstRender] = createSignal12(true);
4233
+ const [lastUpdated, setLastUpdated] = createSignal12(0);
4234
+ const [shouldSendResetCookie, setShouldSendResetCookie] = createSignal12(false);
4235
+ const [ContentWrapper, setContentWrapper] = createSignal12(
4185
4236
  props.contentWrapper || "div"
4186
4237
  );
4187
- const [httpReqsData, setHttpReqsData] = createSignal11({});
4188
- const [clicked, setClicked] = createSignal11(false);
4238
+ const [httpReqsData, setHttpReqsData] = createSignal12({});
4239
+ const [clicked, setClicked] = createSignal12(false);
4189
4240
  function mergeNewRootState(newData) {
4190
4241
  const combinedState = {
4191
4242
  ...props.builderContextSignal.rootState,
@@ -4256,7 +4307,11 @@ function EnableEditor(props) {
4256
4307
  context: props.context || {},
4257
4308
  localState: void 0,
4258
4309
  rootState: props.builderContextSignal.rootState,
4259
- rootSetState: props.builderContextSignal.rootSetState
4310
+ rootSetState: props.builderContextSignal.rootSetState,
4311
+ /**
4312
+ * We don't want to cache the result of the JS code, since it's arbitrary side effect code.
4313
+ */
4314
+ enableCache: false
4260
4315
  });
4261
4316
  }
4262
4317
  }
@@ -4281,13 +4336,16 @@ function EnableEditor(props) {
4281
4336
  function evalExpression(expression) {
4282
4337
  return expression.replace(
4283
4338
  /{{([^}]+)}}/g,
4284
- (_match, group) => evaluate({
4285
- code: group,
4286
- context: props.context || {},
4287
- localState: void 0,
4288
- rootState: props.builderContextSignal.rootState,
4289
- rootSetState: props.builderContextSignal.rootSetState
4290
- })
4339
+ (_match, group) => String(
4340
+ evaluate({
4341
+ code: group,
4342
+ context: props.context || {},
4343
+ localState: void 0,
4344
+ rootState: props.builderContextSignal.rootState,
4345
+ rootSetState: props.builderContextSignal.rootSetState,
4346
+ enableCache: true
4347
+ })
4348
+ )
4291
4349
  );
4292
4350
  }
4293
4351
  function handleRequest({ url, key }) {
@@ -4404,40 +4462,63 @@ function EnableEditor(props) {
4404
4462
  runHttpRequests();
4405
4463
  emitStateUpdate();
4406
4464
  });
4465
+ const onUpdateFn_0_props_content = createMemo12(() => props.content);
4407
4466
  function onUpdateFn_0() {
4408
4467
  if (props.content) {
4409
4468
  mergeNewContent(props.content);
4410
4469
  }
4411
4470
  }
4412
- createEffect2(on2(() => [props.content], onUpdateFn_0));
4471
+ createEffect2(on2(() => [onUpdateFn_0_props_content()], onUpdateFn_0));
4472
+ const onUpdateFn_1_shouldSendResetCookie__ = createMemo12(
4473
+ () => shouldSendResetCookie()
4474
+ );
4413
4475
  function onUpdateFn_1() {
4414
4476
  }
4415
- createEffect2(on2(() => [shouldSendResetCookie()], onUpdateFn_1));
4477
+ createEffect2(
4478
+ on2(() => [onUpdateFn_1_shouldSendResetCookie__()], onUpdateFn_1)
4479
+ );
4480
+ const onUpdateFn_2_props_builderContextSignal_content__data__jsCode = createMemo12(() => props.builderContextSignal.content?.data?.jsCode);
4416
4481
  function onUpdateFn_2() {
4417
4482
  evaluateJsCode();
4418
4483
  }
4419
4484
  createEffect2(
4420
- on2(() => [props.builderContextSignal.content?.data?.jsCode], onUpdateFn_2)
4485
+ on2(
4486
+ () => [onUpdateFn_2_props_builderContextSignal_content__data__jsCode()],
4487
+ onUpdateFn_2
4488
+ )
4421
4489
  );
4490
+ const onUpdateFn_3_props_builderContextSignal_content__data__httpRequests = createMemo12(() => props.builderContextSignal.content?.data?.httpRequests);
4422
4491
  function onUpdateFn_3() {
4423
4492
  runHttpRequests();
4424
4493
  }
4425
4494
  createEffect2(
4426
4495
  on2(
4427
- () => [props.builderContextSignal.content?.data?.httpRequests],
4496
+ () => [
4497
+ onUpdateFn_3_props_builderContextSignal_content__data__httpRequests()
4498
+ ],
4428
4499
  onUpdateFn_3
4429
4500
  )
4430
4501
  );
4502
+ const onUpdateFn_4_props_builderContextSignal_rootState = createMemo12(
4503
+ () => props.builderContextSignal.rootState
4504
+ );
4431
4505
  function onUpdateFn_4() {
4432
4506
  emitStateUpdate();
4433
4507
  }
4434
- createEffect2(on2(() => [props.builderContextSignal.rootState], onUpdateFn_4));
4508
+ createEffect2(
4509
+ on2(
4510
+ () => [onUpdateFn_4_props_builderContextSignal_rootState()],
4511
+ onUpdateFn_4
4512
+ )
4513
+ );
4514
+ const onUpdateFn_5_props_data = createMemo12(() => props.data);
4435
4515
  function onUpdateFn_5() {
4436
4516
  if (props.data) {
4437
4517
  mergeNewRootState(props.data);
4438
4518
  }
4439
4519
  }
4440
- createEffect2(on2(() => [props.data], onUpdateFn_5));
4520
+ createEffect2(on2(() => [onUpdateFn_5_props_data()], onUpdateFn_5));
4521
+ const onUpdateFn_6_props_locale = createMemo12(() => props.locale);
4441
4522
  function onUpdateFn_6() {
4442
4523
  if (props.locale) {
4443
4524
  mergeNewRootState({
@@ -4445,7 +4526,7 @@ function EnableEditor(props) {
4445
4526
  });
4446
4527
  }
4447
4528
  }
4448
- createEffect2(on2(() => [props.locale], onUpdateFn_6));
4529
+ createEffect2(on2(() => [onUpdateFn_6_props_locale()], onUpdateFn_6));
4449
4530
  return <builder_context_default.Provider value={props.builderContextSignal}><Show10 when={props.builderContextSignal.content}><Dynamic5
4450
4531
  class={`variant-${props.content?.testVariationId || props.content?.id}`}
4451
4532
  {...{}}
@@ -4466,7 +4547,7 @@ function EnableEditor(props) {
4466
4547
  var Enable_editor_default = EnableEditor;
4467
4548
 
4468
4549
  // src/components/content/components/styles.tsx
4469
- import { createSignal as createSignal12 } from "solid-js";
4550
+ import { createSignal as createSignal13 } from "solid-js";
4470
4551
 
4471
4552
  // src/components/content/components/styles.helpers.ts
4472
4553
  var getCssFromFont = (font) => {
@@ -4522,19 +4603,7 @@ var getCss = ({
4522
4603
  }
4523
4604
  return cssCode?.replace(/&/g, `div[builder-content-id="${contentId}"]`) || "";
4524
4605
  };
4525
-
4526
- // src/components/content/components/styles.tsx
4527
- function ContentStyles(props) {
4528
- const [injectedStyles, setInjectedStyles] = createSignal12(
4529
- `
4530
- ${getCss({
4531
- cssCode: props.cssCode,
4532
- contentId: props.contentId
4533
- })}
4534
- ${getFontCss({
4535
- customFonts: props.customFonts
4536
- })}
4537
-
4606
+ var DEFAULT_STYLES = `
4538
4607
  .builder-button {
4539
4608
  all: unset;
4540
4609
  }
@@ -4551,6 +4620,23 @@ ${getFontCss({
4551
4620
  text-align: inherit;
4552
4621
  font-family: inherit;
4553
4622
  }
4623
+ `;
4624
+ var getDefaultStyles = (isNested) => {
4625
+ return !isNested ? DEFAULT_STYLES : "";
4626
+ };
4627
+
4628
+ // src/components/content/components/styles.tsx
4629
+ function ContentStyles(props) {
4630
+ const [injectedStyles, setInjectedStyles] = createSignal13(
4631
+ `
4632
+ ${getCss({
4633
+ cssCode: props.cssCode,
4634
+ contentId: props.contentId
4635
+ })}
4636
+ ${getFontCss({
4637
+ customFonts: props.customFonts
4638
+ })}
4639
+ ${getDefaultStyles(props.isNestedRender)}
4554
4640
  `.trim()
4555
4641
  );
4556
4642
  return <Inlined_styles_default styles={injectedStyles()} />;
@@ -4595,7 +4681,7 @@ var getContentInitialValue = ({
4595
4681
 
4596
4682
  // src/components/content/content.tsx
4597
4683
  function ContentComponent(props) {
4598
- const [scriptStr, setScriptStr] = createSignal13(
4684
+ const [scriptStr, setScriptStr] = createSignal14(
4599
4685
  getUpdateVariantVisibilityScript({
4600
4686
  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion, @typescript-eslint/no-non-null-asserted-optional-chain
4601
4687
  variationId: props.content?.testVariationId,
@@ -4603,7 +4689,7 @@ function ContentComponent(props) {
4603
4689
  contentId: props.content?.id
4604
4690
  })
4605
4691
  );
4606
- const [registeredComponents, setRegisteredComponents] = createSignal13(
4692
+ const [registeredComponents, setRegisteredComponents] = createSignal14(
4607
4693
  [
4608
4694
  ...getDefaultRegisteredComponents(),
4609
4695
  ...props.customComponents || []
@@ -4618,7 +4704,7 @@ function ContentComponent(props) {
4618
4704
  {}
4619
4705
  )
4620
4706
  );
4621
- const [builderContextSignal, setBuilderContextSignal] = createSignal13({
4707
+ const [builderContextSignal, setBuilderContextSignal] = createSignal14({
4622
4708
  content: getContentInitialValue({
4623
4709
  content: props.content,
4624
4710
  data: props.data
@@ -4678,6 +4764,7 @@ function ContentComponent(props) {
4678
4764
  >
4679
4765
  <Show11 when={props.isSsrAbTest}><Inlined_script_default scriptStr={scriptStr()} /></Show11>
4680
4766
  <Show11 when={TARGET !== "reactNative"}><Styles_default
4767
+ isNestedRender={props.isNestedRender}
4681
4768
  contentId={builderContextSignal().content?.id}
4682
4769
  cssCode={builderContextSignal().content?.data?.cssCode}
4683
4770
  customFonts={builderContextSignal().content?.data?.customFonts}
@@ -4694,13 +4781,13 @@ var Content_default = ContentComponent;
4694
4781
 
4695
4782
  // src/components/content-variants/content-variants.tsx
4696
4783
  function ContentVariants(props) {
4697
- const [shouldRenderVariants, setShouldRenderVariants] = createSignal14(
4784
+ const [shouldRenderVariants, setShouldRenderVariants] = createSignal15(
4698
4785
  checkShouldRenderVariants({
4699
4786
  canTrack: getDefaultCanTrack(props.canTrack),
4700
4787
  content: props.content
4701
4788
  })
4702
4789
  );
4703
- function updateCookieAndStylesScriptStr() {
4790
+ const updateCookieAndStylesScriptStr = createMemo15(() => {
4704
4791
  return getUpdateCookieAndStylesScript(
4705
4792
  getVariants(props.content).map((value) => ({
4706
4793
  id: value.testVariationId,
@@ -4708,11 +4795,11 @@ function ContentVariants(props) {
4708
4795
  })),
4709
4796
  props.content?.id || ""
4710
4797
  );
4711
- }
4712
- function hideVariantsStyleString() {
4798
+ });
4799
+ const hideVariantsStyleString = createMemo15(() => {
4713
4800
  return getVariants(props.content).map((value) => `.variant-${value.testVariationId} { display: none; } `).join("");
4714
- }
4715
- function defaultContent() {
4801
+ });
4802
+ const defaultContent = createMemo15(() => {
4716
4803
  return shouldRenderVariants() ? {
4717
4804
  ...props.content,
4718
4805
  testVariationId: props.content?.id
@@ -4720,12 +4807,12 @@ function ContentVariants(props) {
4720
4807
  item: props.content,
4721
4808
  canTrack: getDefaultCanTrack(props.canTrack)
4722
4809
  });
4723
- }
4810
+ });
4724
4811
  onMount4(() => {
4725
4812
  setShouldRenderVariants(false);
4726
4813
  });
4727
4814
  return <>
4728
- <Show12 when={!props.__isNestedRender && TARGET !== "reactNative"}><Inlined_script_default scriptStr={getScriptString()} /></Show12>
4815
+ <Show12 when={!props.isNestedRender && TARGET !== "reactNative"}><Inlined_script_default scriptStr={getScriptString()} /></Show12>
4729
4816
  <Show12 when={shouldRenderVariants()}>
4730
4817
  <Inlined_styles_default
4731
4818
  id={`variants-styles-${props.content?.id}`}
@@ -4737,6 +4824,7 @@ function ContentVariants(props) {
4737
4824
  <For7 each={getVariants(props.content)}>{(variant, _index) => {
4738
4825
  const index = _index();
4739
4826
  return <Content_default
4827
+ isNestedRender={props.isNestedRender}
4740
4828
  key={variant.testVariationId}
4741
4829
  content={variant}
4742
4830
  showContent={false}
@@ -4760,6 +4848,7 @@ function ContentVariants(props) {
4760
4848
  }}</For7>
4761
4849
  </Show12>
4762
4850
  <Content_default
4851
+ isNestedRender={props.isNestedRender}
4763
4852
  {...{}}
4764
4853
  content={defaultContent()}
4765
4854
  showContent={true}
@@ -4810,15 +4899,15 @@ var fetchSymbolContent = async ({
4810
4899
 
4811
4900
  // src/blocks/symbol/symbol.tsx
4812
4901
  function Symbol(props) {
4813
- const [contentToUse, setContentToUse] = createSignal15(props.symbol?.content);
4814
- function className() {
4902
+ const [contentToUse, setContentToUse] = createSignal16(props.symbol?.content);
4903
+ const className = createMemo16(() => {
4815
4904
  return [
4816
4905
  ...[props.attributes[getClassPropName()]],
4817
4906
  "builder-symbol",
4818
4907
  props.symbol?.inline ? "builder-inline-symbol" : void 0,
4819
4908
  props.symbol?.dynamic || props.dynamic ? "builder-dynamic-symbol" : void 0
4820
4909
  ].filter(Boolean).join(" ");
4821
- }
4910
+ });
4822
4911
  function setContent() {
4823
4912
  if (contentToUse())
4824
4913
  return;
@@ -4832,14 +4921,14 @@ function Symbol(props) {
4832
4921
  });
4833
4922
  }
4834
4923
  onMount5(() => {
4835
- setContent();
4836
4924
  });
4925
+ const onUpdateFn_0_props_symbol = createMemo16(() => props.symbol);
4837
4926
  function onUpdateFn_0() {
4838
4927
  setContent();
4839
4928
  }
4840
- createEffect3(on3(() => [props.symbol], onUpdateFn_0));
4929
+ createEffect3(on3(() => [onUpdateFn_0_props_symbol()], onUpdateFn_0));
4841
4930
  return <div class={className()} {...{}} {...props.attributes} {...{}}><Content_variants_default
4842
- __isNestedRender={true}
4931
+ isNestedRender={true}
4843
4932
  apiVersion={props.builderContext.apiVersion}
4844
4933
  apiKey={props.builderContext.apiKey}
4845
4934
  context={{