@builder.io/sdk-svelte 1.0.8 → 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.
Files changed (102) hide show
  1. package/lib/browser/blocks/BaseText.svelte +1 -3
  2. package/lib/browser/blocks/button/button.svelte +2 -3
  3. package/lib/browser/blocks/columns/columns.svelte +3 -5
  4. package/lib/browser/blocks/form/form/form.svelte +5 -7
  5. package/lib/browser/blocks/form/submit-button/submit-button.svelte +2 -4
  6. package/lib/browser/blocks/image/image.svelte +5 -8
  7. package/lib/browser/blocks/video/video.svelte +2 -5
  8. package/lib/browser/components/block/block.helpers.d.ts +4 -0
  9. package/lib/browser/components/block/block.helpers.js +14 -1
  10. package/lib/browser/components/block/block.svelte +4 -10
  11. package/lib/browser/components/block/components/block-wrapper.svelte +2 -4
  12. package/lib/browser/components/block/components/interactive-element.svelte +2 -4
  13. package/lib/browser/components/blocks/blocks-wrapper.svelte +1 -3
  14. package/lib/browser/components/blocks/blocks.svelte +2 -2
  15. package/lib/browser/components/content/components/enable-editor.svelte +8 -5
  16. package/lib/browser/components/content/content.svelte +3 -5
  17. package/lib/browser/components/content-variants/content-variants.svelte +0 -2
  18. package/lib/browser/components/dynamic-renderer/dynamic-renderer.svelte +4 -6
  19. package/lib/browser/constants/sdk-version.d.ts +1 -1
  20. package/lib/browser/constants/sdk-version.js +1 -1
  21. package/lib/browser/functions/evaluate/browser-runtime/browser.js +1 -1
  22. package/lib/browser/functions/evaluate/evaluate.d.ts +3 -1
  23. package/lib/browser/functions/evaluate/evaluate.js +39 -3
  24. package/lib/browser/functions/evaluate/helpers.d.ts +1 -0
  25. package/lib/browser/functions/get-block-actions-handler.js +2 -1
  26. package/lib/browser/functions/get-processed-block.js +2 -1
  27. package/lib/edge/blocks/BaseText.svelte +1 -3
  28. package/lib/edge/blocks/button/button.svelte +2 -3
  29. package/lib/edge/blocks/columns/columns.svelte +3 -5
  30. package/lib/edge/blocks/form/form/form.svelte +5 -7
  31. package/lib/edge/blocks/form/submit-button/submit-button.svelte +2 -4
  32. package/lib/edge/blocks/image/image.svelte +5 -8
  33. package/lib/edge/blocks/video/video.svelte +2 -5
  34. package/lib/edge/components/block/block.helpers.d.ts +4 -0
  35. package/lib/edge/components/block/block.helpers.js +14 -1
  36. package/lib/edge/components/block/block.svelte +4 -10
  37. package/lib/edge/components/block/components/block-wrapper.svelte +2 -4
  38. package/lib/edge/components/block/components/interactive-element.svelte +2 -4
  39. package/lib/edge/components/blocks/blocks-wrapper.svelte +1 -3
  40. package/lib/edge/components/blocks/blocks.svelte +2 -2
  41. package/lib/edge/components/content/components/enable-editor.svelte +8 -5
  42. package/lib/edge/components/content/content.svelte +3 -5
  43. package/lib/edge/components/content-variants/content-variants.svelte +0 -2
  44. package/lib/edge/components/dynamic-renderer/dynamic-renderer.svelte +4 -6
  45. package/lib/edge/constants/sdk-version.d.ts +1 -1
  46. package/lib/edge/constants/sdk-version.js +1 -1
  47. package/lib/edge/functions/evaluate/browser-runtime/browser.js +1 -1
  48. package/lib/edge/functions/evaluate/evaluate.d.ts +3 -1
  49. package/lib/edge/functions/evaluate/evaluate.js +39 -3
  50. package/lib/edge/functions/evaluate/helpers.d.ts +1 -0
  51. package/lib/edge/functions/get-block-actions-handler.js +2 -1
  52. package/lib/edge/functions/get-processed-block.js +2 -1
  53. package/lib/node/blocks/BaseText.svelte +1 -3
  54. package/lib/node/blocks/button/button.svelte +2 -3
  55. package/lib/node/blocks/columns/columns.svelte +3 -5
  56. package/lib/node/blocks/form/form/form.svelte +5 -7
  57. package/lib/node/blocks/form/submit-button/submit-button.svelte +2 -4
  58. package/lib/node/blocks/image/image.svelte +5 -8
  59. package/lib/node/blocks/video/video.svelte +2 -5
  60. package/lib/node/components/block/block.helpers.d.ts +4 -0
  61. package/lib/node/components/block/block.helpers.js +14 -1
  62. package/lib/node/components/block/block.svelte +4 -10
  63. package/lib/node/components/block/components/block-wrapper.svelte +2 -4
  64. package/lib/node/components/block/components/interactive-element.svelte +2 -4
  65. package/lib/node/components/blocks/blocks-wrapper.svelte +1 -3
  66. package/lib/node/components/blocks/blocks.svelte +2 -2
  67. package/lib/node/components/content/components/enable-editor.svelte +8 -5
  68. package/lib/node/components/content/content.svelte +3 -5
  69. package/lib/node/components/content-variants/content-variants.svelte +0 -2
  70. package/lib/node/components/dynamic-renderer/dynamic-renderer.svelte +4 -6
  71. package/lib/node/constants/sdk-version.d.ts +1 -1
  72. package/lib/node/constants/sdk-version.js +1 -1
  73. package/lib/node/functions/evaluate/browser-runtime/browser.js +1 -1
  74. package/lib/node/functions/evaluate/evaluate.d.ts +3 -1
  75. package/lib/node/functions/evaluate/evaluate.js +39 -3
  76. package/lib/node/functions/evaluate/helpers.d.ts +1 -0
  77. package/lib/node/functions/get-block-actions-handler.js +2 -1
  78. package/lib/node/functions/get-processed-block.js +2 -1
  79. package/package.json +1 -1
  80. package/src/blocks/BaseText.svelte +1 -3
  81. package/src/blocks/button/button.svelte +2 -3
  82. package/src/blocks/columns/columns.svelte +3 -5
  83. package/src/blocks/form/form/form.svelte +5 -7
  84. package/src/blocks/form/submit-button/submit-button.svelte +2 -4
  85. package/src/blocks/image/image.svelte +5 -8
  86. package/src/blocks/video/video.svelte +2 -5
  87. package/src/components/block/block.helpers.ts +20 -1
  88. package/src/components/block/block.svelte +8 -11
  89. package/src/components/block/components/block-wrapper.svelte +2 -4
  90. package/src/components/block/components/interactive-element.svelte +2 -4
  91. package/src/components/blocks/blocks-wrapper.svelte +1 -3
  92. package/src/components/blocks/blocks.svelte +2 -2
  93. package/src/components/content/components/enable-editor.svelte +21 -10
  94. package/src/components/content/content.svelte +3 -5
  95. package/src/components/content-variants/content-variants.svelte +0 -2
  96. package/src/components/dynamic-renderer/dynamic-renderer.svelte +4 -6
  97. package/src/constants/sdk-version.ts +1 -1
  98. package/src/functions/evaluate/browser-runtime/browser.ts +1 -1
  99. package/src/functions/evaluate/evaluate.ts +44 -4
  100. package/src/functions/evaluate/helpers.ts +1 -0
  101. package/src/functions/get-block-actions-handler.ts +2 -1
  102. package/src/functions/get-processed-block.ts +2 -1
@@ -60,10 +60,8 @@ $: className = () => {
60
60
  on:keypress={(event) => {
61
61
  onClick();
62
62
  }}
63
- {...BlocksWrapperProps}
63
+ {...BlocksWrapperProps}><slot /></svelte:element
64
64
  >
65
- <slot />
66
- </svelte:element>
67
65
 
68
66
  <style>
69
67
  .svelte-element {
@@ -33,5 +33,5 @@ let componentsContext = getContext(ComponentsContext.key);
33
33
  componentsContext.registeredComponents}
34
34
  />
35
35
  {/each}
36
- {/if}
37
- </BlocksWrapper>
36
+ {/if}</BlocksWrapper
37
+ >
@@ -99,6 +99,10 @@ function evaluateJsCode() {
99
99
  localState: undefined,
100
100
  rootState: $builderContextSignal.rootState,
101
101
  rootSetState: $builderContextSignal.rootSetState,
102
+ /**
103
+ * We don't want to cache the result of the JS code, since it's arbitrary side effect code.
104
+ */
105
+ enableCache: false,
102
106
  });
103
107
  }
104
108
  }
@@ -121,13 +125,14 @@ function onClick(event) {
121
125
  }
122
126
  }
123
127
  function evalExpression(expression) {
124
- return expression.replace(/{{([^}]+)}}/g, (_match, group) => evaluate({
128
+ return expression.replace(/{{([^}]+)}}/g, (_match, group) => String(evaluate({
125
129
  code: group,
126
130
  context: context || {},
127
131
  localState: undefined,
128
132
  rootState: $builderContextSignal.rootState,
129
133
  rootSetState: $builderContextSignal.rootSetState,
130
- }));
134
+ enableCache: true,
135
+ })));
131
136
  }
132
137
  function handleRequest({ url, key }) {
133
138
  fetch(url)
@@ -341,8 +346,6 @@ onDestroy(() => {
341
346
  }}
342
347
  on:initpreviewingbldr={(event) => {
343
348
  elementRef_onInitpreviewingbldr(event);
344
- }}
349
+ }}><slot /></svelte:element
345
350
  >
346
- <slot />
347
- </svelte:element>
348
351
  {/if}
@@ -99,18 +99,16 @@ setContext(ComponentsContext.key, {
99
99
  {#if isSsrAbTest}
100
100
  <InlinedScript {scriptStr} />
101
101
  {/if}
102
-
103
102
  {#if TARGET !== "reactNative"}
104
103
  <ContentStyles
105
104
  contentId={$builderContextSignal.content?.id}
106
105
  cssCode={$builderContextSignal.content?.data?.cssCode}
107
106
  customFonts={$builderContextSignal.content?.data?.customFonts}
108
107
  />
109
- {/if}
110
- <Blocks
108
+ {/if}<Blocks
111
109
  blocks={$builderContextSignal.content?.data?.blocks}
112
110
  context={builderContextSignal}
113
111
  {registeredComponents}
114
112
  {linkComponent}
115
- />
116
- </EnableEditor>
113
+ /></EnableEditor
114
+ >
@@ -68,7 +68,6 @@ onMount(() => {
68
68
  id={`variants-styles-${content?.id}`}
69
69
  styles={hideVariantsStyleString()}
70
70
  />
71
-
72
71
  <InlinedScript scriptStr={updateCookieAndStylesScriptStr()} />
73
72
 
74
73
  {#each getVariants(content) as variant (variant.testVariationId)}
@@ -94,7 +93,6 @@ onMount(() => {
94
93
  />
95
94
  {/each}
96
95
  {/if}
97
-
98
96
  <ContentComponent
99
97
  {...{}}
100
98
  content={defaultContent()}
@@ -12,14 +12,12 @@ export let actionAttributes;
12
12
  <svelte:element
13
13
  this={TagName}
14
14
  {...attributes}
15
- use:setAttrs={actionAttributes}
15
+ use:setAttrs={actionAttributes}><slot /></svelte:element
16
16
  >
17
- <slot />
18
- </svelte:element>
19
17
  {:else}
20
- <svelte:component this={TagName} {...attributes} {...actionAttributes}>
21
- <slot />
22
- </svelte:component>
18
+ <svelte:component this={TagName} {...attributes} {...actionAttributes}
19
+ ><slot /></svelte:component
20
+ >
23
21
  {/if}
24
22
  {:else}
25
23
  <svelte:element
@@ -1 +1 @@
1
- export declare const SDK_VERSION = "1.0.8";
1
+ export declare const SDK_VERSION = "1.0.12";
@@ -1 +1 @@
1
- export const SDK_VERSION = "1.0.8";
1
+ export const SDK_VERSION = "1.0.12";
@@ -19,7 +19,7 @@ export function flattenState({ rootState, localState, rootSetState }) {
19
19
  return localState[prop];
20
20
  }
21
21
  const val = target[prop];
22
- if (typeof val === 'object') {
22
+ if (typeof val === 'object' && val !== null) {
23
23
  return flattenState({
24
24
  rootState: val,
25
25
  localState: undefined,
@@ -1,2 +1,4 @@
1
1
  import type { EvaluatorArgs } from './helpers.js';
2
- export declare function evaluate({ code, context, localState, rootState, rootSetState, event, isExpression }: EvaluatorArgs): any;
2
+ type EvalValue = unknown;
3
+ export declare function evaluate({ code, context, localState, rootState, rootSetState, event, isExpression, enableCache }: EvaluatorArgs): EvalValue;
4
+ export {};
@@ -1,10 +1,34 @@
1
1
  import { logger } from '../../helpers/logger.js';
2
2
  import { chooseBrowserOrServerEval } from './choose-eval.js';
3
3
  import { getBuilderGlobals, parseCode } from './helpers.js';
4
- export function evaluate({ code, context, localState, rootState, rootSetState, event, isExpression = true }) {
4
+ class EvalCache {
5
+ static cacheLimit = 20;
6
+ static cache = new Map();
7
+ static getCacheKey(args) {
8
+ return JSON.stringify({
9
+ ...args,
10
+ // replace the event with a random number to break cache
11
+ // thats because we can't serialize the event object due to circular refs in DOM node refs.
12
+ event: args.event ? Math.random() : undefined
13
+ });
14
+ }
15
+ static getCachedValue(key) {
16
+ const cachedVal = EvalCache.cache.get(key);
17
+ return cachedVal;
18
+ }
19
+ static setCachedValue(key, value) {
20
+ if (EvalCache.cache.size > 20) {
21
+ EvalCache.cache.delete(EvalCache.cache.keys().next().value);
22
+ }
23
+ EvalCache.cache.set(key, {
24
+ value
25
+ });
26
+ }
27
+ }
28
+ export function evaluate({ code, context, localState, rootState, rootSetState, event, isExpression = true, enableCache }) {
5
29
  if (code === '') {
6
30
  logger.warn('Skipping evaluation of empty code block.');
7
- return;
31
+ return undefined;
8
32
  }
9
33
  const args = {
10
34
  code: parseCode(code, {
@@ -17,8 +41,20 @@ export function evaluate({ code, context, localState, rootState, rootSetState, e
17
41
  rootState,
18
42
  localState
19
43
  };
44
+ if (enableCache) {
45
+ const cacheKey = EvalCache.getCacheKey(args);
46
+ const cachedValue = EvalCache.getCachedValue(cacheKey);
47
+ if (cachedValue) {
48
+ return cachedValue.value;
49
+ }
50
+ }
20
51
  try {
21
- return chooseBrowserOrServerEval(args);
52
+ const newEval = chooseBrowserOrServerEval(args);
53
+ if (enableCache) {
54
+ const cacheKey = EvalCache.getCacheKey(args);
55
+ EvalCache.setCachedValue(cacheKey, newEval);
56
+ }
57
+ return newEval;
22
58
  }
23
59
  catch (e) {
24
60
  logger.error('Failed code evaluation: ' + e.message, {
@@ -3,6 +3,7 @@ import { getUserAttributes } from '../track/helpers.js';
3
3
  export type EvaluatorArgs = Omit<ExecutorArgs, 'builder' | 'event'> & {
4
4
  event?: Event;
5
5
  isExpression?: boolean;
6
+ enableCache: boolean;
6
7
  };
7
8
  export type BuilderGlobals = {
8
9
  isEditing: boolean | undefined;
@@ -6,5 +6,6 @@ export const createEventHandler = (value, options) => event => evaluate({
6
6
  rootState: options.rootState,
7
7
  rootSetState: options.rootSetState,
8
8
  event,
9
- isExpression: false
9
+ isExpression: false,
10
+ enableCache: true
10
11
  });
@@ -23,7 +23,8 @@ const evaluateBindings = ({ block, context, localState, rootState, rootSetState
23
23
  localState,
24
24
  rootState,
25
25
  rootSetState,
26
- context
26
+ context,
27
+ enableCache: true
27
28
  });
28
29
  set(copied, binding, value);
29
30
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@builder.io/sdk-svelte",
3
3
  "description": "Builder.io SDK for Svelte",
4
- "version": "1.0.8",
4
+ "version": "1.0.12",
5
5
  "type": "module",
6
6
  "files": [
7
7
  "lib",
@@ -24,6 +24,4 @@
24
24
  let builderContext = getContext(BuilderContext.key);
25
25
  </script>
26
26
 
27
- <span use:mitosis_styling={$builderContext.inheritedStyles}>
28
- {text}
29
- </span>
27
+ <span use:mitosis_styling={$builderContext.inheritedStyles}>{text}</span>
@@ -30,6 +30,5 @@
30
30
  }}
31
31
  TagName={link ? builderLinkComponent || "a" : "button"}
32
32
  actionAttributes={filterAttrs(attributes, "on:", true)}
33
- >
34
- {text}
35
- </DynamicRenderer>
33
+ >{text}</DynamicRenderer
34
+ >
@@ -157,7 +157,6 @@
157
157
  {#if TARGET !== "reactNative"}
158
158
  <InlinedStyles styles={columnsStyles()} />
159
159
  {/if}
160
-
161
160
  {#each columns as column, index (index)}
162
161
  <DynamicRenderer
163
162
  TagName={column.link ? builderLinkComponent || "a" : "div"}
@@ -172,8 +171,7 @@
172
171
  [getClassPropName()]: "builder-column",
173
172
  style: mapStyleObjToStrIfNeeded(columnCssVars(index)),
174
173
  }}
175
- >
176
- <Blocks
174
+ ><Blocks
177
175
  path={`component.options.columns.${index}.blocks`}
178
176
  parent={builderBlock.id}
179
177
  styleProp={{
@@ -183,8 +181,8 @@
183
181
  registeredComponents={builderComponents}
184
182
  linkComponent={builderLinkComponent}
185
183
  blocks={column.blocks}
186
- />
187
- </DynamicRenderer>
184
+ /></DynamicRenderer
185
+ >
188
186
  {/each}
189
187
  </div>
190
188
 
@@ -317,7 +317,6 @@
317
317
  />
318
318
  {/each}
319
319
  {/if}
320
-
321
320
  {#if submissionState() === "error"}
322
321
  <Blocks
323
322
  path="errorMessage"
@@ -325,7 +324,6 @@
325
324
  context={builderContext}
326
325
  />
327
326
  {/if}
328
-
329
327
  {#if submissionState() === "sending"}
330
328
  <Blocks
331
329
  path="sendingMessage"
@@ -333,13 +331,13 @@
333
331
  context={builderContext}
334
332
  />
335
333
  {/if}
336
-
337
334
  {#if submissionState() === "error" && responseData}
338
- <pre class="builder-form-error-text pre">
339
- {JSON.stringify(responseData, null, 2)}
340
- </pre>
335
+ <pre class="builder-form-error-text pre">{JSON.stringify(
336
+ responseData,
337
+ null,
338
+ 2
339
+ )}</pre>
341
340
  {/if}
342
-
343
341
  {#if submissionState() === "success"}
344
342
  <Blocks
345
343
  path="successMessage"
@@ -20,7 +20,5 @@
20
20
  <button
21
21
  type="submit"
22
22
  {...filterAttrs(attributes, "on:", false)}
23
- use:setAttrs={filterAttrs(attributes, "on:", true)}
24
- >
25
- {text}
26
- </button>
23
+ use:setAttrs={filterAttrs(attributes, "on:", true)}>{text}</button
24
+ >
@@ -69,8 +69,7 @@
69
69
  <picture>
70
70
  {#if webpSrcSet()}
71
71
  <source type="image/webp" srcset={webpSrcSet()} />
72
- {/if}
73
- <img
72
+ {/if}<img
74
73
  use:mitosis_styling={{
75
74
  objectPosition: backgroundPosition || "center",
76
75
  objectFit: backgroundSize || "cover",
@@ -78,13 +77,13 @@
78
77
  }}
79
78
  loading="lazy"
80
79
  alt={altText}
81
- role={altText ? "presentation" : undefined}
80
+ role={altText ? undefined : "presentation"}
82
81
  class={"builder-image" + (className ? " " + className : "") + " img"}
83
82
  src={image}
84
83
  srcset={srcSetToUse()}
85
84
  {sizes}
86
- />
87
- </picture>
85
+ /></picture
86
+ >
88
87
 
89
88
  {#if aspectRatio && !(builderBlock?.children?.length && fitContent)}
90
89
  <div
@@ -100,9 +99,7 @@
100
99
  {/if}
101
100
 
102
101
  {#if !fitContent && $$slots.default}
103
- <div class="div-2">
104
- <slot />
105
- </div>
102
+ <div class="div-2"><slot /></div>
106
103
  {/if}
107
104
 
108
105
  <style>
@@ -93,9 +93,8 @@
93
93
  >
94
94
  {#if !lazyLoad}
95
95
  <source type="video/mp4" src={video} />
96
- {/if}
97
- </video>
98
-
96
+ {/if}</video
97
+ >
99
98
  {#if aspectRatio && !(fitContent && builderBlock?.children?.length)}
100
99
  <div
101
100
  use:mitosis_styling={{
@@ -106,7 +105,6 @@
106
105
  }}
107
106
  />
108
107
  {/if}
109
-
110
108
  {#if builderBlock?.children?.length && fitContent}
111
109
  <div
112
110
  use:mitosis_styling={{
@@ -118,7 +116,6 @@
118
116
  <slot />
119
117
  </div>
120
118
  {/if}
121
-
122
119
  {#if builderBlock?.children?.length && !fitContent}
123
120
  <div
124
121
  use:mitosis_styling={{
@@ -1,6 +1,8 @@
1
1
  import type { BuilderContextInterface, RegisteredComponents } from '../../context/types.js';
2
2
  import { evaluate } from '../../functions/evaluate/index.js';
3
+ import { extractTextStyles } from '../../functions/extract-text-styles.js';
3
4
  import { getProcessedBlock } from '../../functions/get-processed-block.js';
5
+ import { getStyle } from '../../functions/get-style.js';
4
6
  import type { BuilderBlock } from '../../types/builder-block.js';
5
7
  import type { RepeatData } from './types.js';
6
8
  export const getComponent = ({
@@ -57,7 +59,8 @@ export const getRepeatItemData = ({
57
59
  localState: context.localState,
58
60
  rootState: context.rootState,
59
61
  rootSetState: context.rootSetState,
60
- context: context.context
62
+ context: context.context,
63
+ enableCache: true
61
64
  });
62
65
  if (!Array.isArray(itemsArray)) {
63
66
  return undefined;
@@ -78,4 +81,20 @@ export const getRepeatItemData = ({
78
81
  block: blockWithoutRepeat
79
82
  }));
80
83
  return repeatArray;
84
+ };
85
+ export const getInheritedStyles = ({
86
+ block,
87
+ context
88
+ }: {
89
+ block: BuilderBlock;
90
+ context: BuilderContextInterface;
91
+ }) => {
92
+ const style = getStyle({
93
+ block,
94
+ context
95
+ });
96
+ if (!style) {
97
+ return {};
98
+ }
99
+ return extractTextStyles(style);
81
100
  }
@@ -9,19 +9,20 @@
9
9
 
10
10
  <script lang="ts">
11
11
  import { onMount } from "svelte";
12
- import { writable } from "svelte/store";
13
12
 
14
13
  import type {
15
14
  BuilderContextInterface,
16
15
  RegisteredComponents,
17
16
  } from "../../context/types.js";
18
- import { extractTextStyles } from "../../functions/extract-text-styles.js";
19
17
  import { getBlockComponentOptions } from "../../functions/get-block-component-options.js";
20
18
  import { getProcessedBlock } from "../../functions/get-processed-block.js";
21
- import { getStyle } from "../../functions/get-style.js";
22
19
  import type { BuilderBlock } from "../../types/builder-block.js";
23
20
  import { bindAnimations } from "./animator.js";
24
- import { getComponent, getRepeatItemData } from "./block.helpers.js";
21
+ import {
22
+ getComponent,
23
+ getInheritedStyles,
24
+ getRepeatItemData,
25
+ } from "./block.helpers.js";
25
26
  import BlockStyles from "./components/block-styles.svelte";
26
27
  import BlockWrapper from "./components/block-wrapper.svelte";
27
28
  import type { ComponentProps } from "./components/component-ref/component-ref.helpers.js";
@@ -116,7 +117,7 @@
116
117
  }
117
118
  : {}),
118
119
  },
119
- context: childrenContext,
120
+ context: context,
120
121
  linkComponent: linkComponent,
121
122
  registeredComponents: registeredComponents,
122
123
  builderBlock: processedBlock(),
@@ -125,8 +126,6 @@
125
126
  };
126
127
  };
127
128
 
128
- let childrenContext = writable($context);
129
-
130
129
  onMount(() => {
131
130
  const blockId = processedBlock().id;
132
131
  const animations = processedBlock().animations;
@@ -153,8 +152,7 @@
153
152
  block={processedBlock()}
154
153
  {context}
155
154
  {linkComponent}
156
- >
157
- <ComponentRef
155
+ ><ComponentRef
158
156
  componentRef={componentRefProps().componentRef}
159
157
  componentOptions={componentRefProps().componentOptions}
160
158
  blockChildren={componentRefProps().blockChildren}
@@ -165,13 +163,12 @@
165
163
  includeBlockProps={componentRefProps().includeBlockProps}
166
164
  isInteractive={componentRefProps().isInteractive}
167
165
  />
168
-
169
166
  {#each childrenWithoutParentComponent() as child (child.id)}
170
167
  <svelte:self
171
168
  block={child}
172
- context={childrenContext}
173
169
  {registeredComponents}
174
170
  {linkComponent}
171
+ {context}
175
172
  />
176
173
  {/each}
177
174
  </BlockWrapper>
@@ -38,7 +38,5 @@
38
38
  localState: $context.localState,
39
39
  context: $context.context,
40
40
  stripPrefix: true,
41
- })}
42
- >
43
- <slot />
44
- </DynamicRenderer>
41
+ })}><slot /></DynamicRenderer
42
+ >
@@ -41,7 +41,5 @@
41
41
  context: $context.context,
42
42
  }),
43
43
  }
44
- : {}}
45
- >
46
- <slot />
47
- </svelte:component>
44
+ : {}}><slot /></svelte:component
45
+ >
@@ -86,10 +86,8 @@
86
86
  on:keypress={(event) => {
87
87
  onClick();
88
88
  }}
89
- {...BlocksWrapperProps}
89
+ {...BlocksWrapperProps}><slot /></svelte:element
90
90
  >
91
- <slot />
92
- </svelte:element>
93
91
 
94
92
  <style>
95
93
  .svelte-element {
@@ -39,5 +39,5 @@
39
39
  componentsContext.registeredComponents}
40
40
  />
41
41
  {/each}
42
- {/if}
43
- </BlocksWrapper>
42
+ {/if}</BlocksWrapper
43
+ >
@@ -130,6 +130,10 @@
130
130
  localState: undefined,
131
131
  rootState: $builderContextSignal.rootState,
132
132
  rootSetState: $builderContextSignal.rootSetState,
133
+ /**
134
+ * We don't want to cache the result of the JS code, since it's arbitrary side effect code.
135
+ */
136
+ enableCache: false,
133
137
  });
134
138
  }
135
139
  }
@@ -153,13 +157,16 @@
153
157
  }
154
158
  function evalExpression(expression: string) {
155
159
  return expression.replace(/{{([^}]+)}}/g, (_match, group) =>
156
- evaluate({
157
- code: group,
158
- context: context || {},
159
- localState: undefined,
160
- rootState: $builderContextSignal.rootState,
161
- rootSetState: $builderContextSignal.rootSetState,
162
- })
160
+ String(
161
+ evaluate({
162
+ code: group,
163
+ context: context || {},
164
+ localState: undefined,
165
+ rootState: $builderContextSignal.rootState,
166
+ rootSetState: $builderContextSignal.rootSetState,
167
+ enableCache: true,
168
+ })
169
+ )
163
170
  );
164
171
  }
165
172
  function handleRequest({ url, key }: { key: string; url: string }) {
@@ -333,15 +340,18 @@
333
340
  }
334
341
 
335
342
  $: onUpdateFn_0(...[content]);
343
+
336
344
  function onUpdateFn_1(..._args: any[]) {}
337
345
 
338
346
  $: onUpdateFn_1(...[shouldSendResetCookie]);
347
+
339
348
  function onUpdateFn_2(..._args: any[]) {
340
349
  evaluateJsCode();
341
350
  }
342
351
  $: onUpdateFn_2_builderContextSignal_content__data__jsCode =
343
352
  $builderContextSignal.content?.data?.jsCode;
344
353
  $: onUpdateFn_2(...[onUpdateFn_2_builderContextSignal_content__data__jsCode]);
354
+
345
355
  function onUpdateFn_3(..._args: any[]) {
346
356
  runHttpRequests();
347
357
  }
@@ -350,12 +360,14 @@
350
360
  $: onUpdateFn_3(
351
361
  ...[onUpdateFn_3_builderContextSignal_content__data__httpRequests]
352
362
  );
363
+
353
364
  function onUpdateFn_4(..._args: any[]) {
354
365
  emitStateUpdate();
355
366
  }
356
367
  $: onUpdateFn_4_builderContextSignal_rootState =
357
368
  $builderContextSignal.rootState;
358
369
  $: onUpdateFn_4(...[onUpdateFn_4_builderContextSignal_rootState]);
370
+
359
371
  function onUpdateFn_5(..._args: any[]) {
360
372
  if (data) {
361
373
  mergeNewRootState(data);
@@ -363,6 +375,7 @@
363
375
  }
364
376
 
365
377
  $: onUpdateFn_5(...[data]);
378
+
366
379
  function onUpdateFn_6(..._args: any[]) {
367
380
  if (locale) {
368
381
  mergeNewRootState({
@@ -411,8 +424,6 @@
411
424
  }}
412
425
  on:initpreviewingbldr={(event) => {
413
426
  elementRef_onInitpreviewingbldr(event);
414
- }}
427
+ }}><slot /></svelte:element
415
428
  >
416
- <slot />
417
- </svelte:element>
418
429
  {/if}
@@ -123,18 +123,16 @@
123
123
  {#if isSsrAbTest}
124
124
  <InlinedScript {scriptStr} />
125
125
  {/if}
126
-
127
126
  {#if TARGET !== "reactNative"}
128
127
  <ContentStyles
129
128
  contentId={$builderContextSignal.content?.id}
130
129
  cssCode={$builderContextSignal.content?.data?.cssCode}
131
130
  customFonts={$builderContextSignal.content?.data?.customFonts}
132
131
  />
133
- {/if}
134
- <Blocks
132
+ {/if}<Blocks
135
133
  blocks={$builderContextSignal.content?.data?.blocks}
136
134
  context={builderContextSignal}
137
135
  {registeredComponents}
138
136
  {linkComponent}
139
- />
140
- </EnableEditor>
137
+ /></EnableEditor
138
+ >