@builder.io/sdk-svelte 1.0.11 → 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.
- package/lib/browser/blocks/BaseText.svelte +1 -3
- package/lib/browser/blocks/button/button.svelte +2 -3
- package/lib/browser/blocks/columns/columns.svelte +3 -5
- package/lib/browser/blocks/form/form/form.svelte +5 -7
- package/lib/browser/blocks/form/submit-button/submit-button.svelte +2 -4
- package/lib/browser/blocks/image/image.svelte +4 -7
- package/lib/browser/blocks/video/video.svelte +2 -5
- package/lib/browser/components/block/block.helpers.d.ts +4 -0
- package/lib/browser/components/block/block.helpers.js +14 -1
- package/lib/browser/components/block/block.svelte +4 -10
- package/lib/browser/components/block/components/block-wrapper.svelte +2 -4
- package/lib/browser/components/block/components/interactive-element.svelte +2 -4
- package/lib/browser/components/blocks/blocks-wrapper.svelte +1 -3
- package/lib/browser/components/blocks/blocks.svelte +2 -2
- package/lib/browser/components/content/components/enable-editor.svelte +8 -5
- package/lib/browser/components/content/content.svelte +3 -5
- package/lib/browser/components/content-variants/content-variants.svelte +0 -2
- package/lib/browser/components/dynamic-renderer/dynamic-renderer.svelte +4 -6
- package/lib/browser/constants/sdk-version.d.ts +1 -1
- package/lib/browser/constants/sdk-version.js +1 -1
- package/lib/browser/functions/evaluate/browser-runtime/browser.js +1 -1
- package/lib/browser/functions/evaluate/evaluate.d.ts +3 -1
- package/lib/browser/functions/evaluate/evaluate.js +39 -3
- package/lib/browser/functions/evaluate/helpers.d.ts +1 -0
- package/lib/browser/functions/get-block-actions-handler.js +2 -1
- package/lib/browser/functions/get-processed-block.js +2 -1
- package/lib/edge/blocks/BaseText.svelte +1 -3
- package/lib/edge/blocks/button/button.svelte +2 -3
- package/lib/edge/blocks/columns/columns.svelte +3 -5
- package/lib/edge/blocks/form/form/form.svelte +5 -7
- package/lib/edge/blocks/form/submit-button/submit-button.svelte +2 -4
- package/lib/edge/blocks/image/image.svelte +4 -7
- package/lib/edge/blocks/video/video.svelte +2 -5
- package/lib/edge/components/block/block.helpers.d.ts +4 -0
- package/lib/edge/components/block/block.helpers.js +14 -1
- package/lib/edge/components/block/block.svelte +4 -10
- package/lib/edge/components/block/components/block-wrapper.svelte +2 -4
- package/lib/edge/components/block/components/interactive-element.svelte +2 -4
- package/lib/edge/components/blocks/blocks-wrapper.svelte +1 -3
- package/lib/edge/components/blocks/blocks.svelte +2 -2
- package/lib/edge/components/content/components/enable-editor.svelte +8 -5
- package/lib/edge/components/content/content.svelte +3 -5
- package/lib/edge/components/content-variants/content-variants.svelte +0 -2
- package/lib/edge/components/dynamic-renderer/dynamic-renderer.svelte +4 -6
- package/lib/edge/constants/sdk-version.d.ts +1 -1
- package/lib/edge/constants/sdk-version.js +1 -1
- package/lib/edge/functions/evaluate/browser-runtime/browser.js +1 -1
- package/lib/edge/functions/evaluate/evaluate.d.ts +3 -1
- package/lib/edge/functions/evaluate/evaluate.js +39 -3
- package/lib/edge/functions/evaluate/helpers.d.ts +1 -0
- package/lib/edge/functions/get-block-actions-handler.js +2 -1
- package/lib/edge/functions/get-processed-block.js +2 -1
- package/lib/node/blocks/BaseText.svelte +1 -3
- package/lib/node/blocks/button/button.svelte +2 -3
- package/lib/node/blocks/columns/columns.svelte +3 -5
- package/lib/node/blocks/form/form/form.svelte +5 -7
- package/lib/node/blocks/form/submit-button/submit-button.svelte +2 -4
- package/lib/node/blocks/image/image.svelte +4 -7
- package/lib/node/blocks/video/video.svelte +2 -5
- package/lib/node/components/block/block.helpers.d.ts +4 -0
- package/lib/node/components/block/block.helpers.js +14 -1
- package/lib/node/components/block/block.svelte +4 -10
- package/lib/node/components/block/components/block-wrapper.svelte +2 -4
- package/lib/node/components/block/components/interactive-element.svelte +2 -4
- package/lib/node/components/blocks/blocks-wrapper.svelte +1 -3
- package/lib/node/components/blocks/blocks.svelte +2 -2
- package/lib/node/components/content/components/enable-editor.svelte +8 -5
- package/lib/node/components/content/content.svelte +3 -5
- package/lib/node/components/content-variants/content-variants.svelte +0 -2
- package/lib/node/components/dynamic-renderer/dynamic-renderer.svelte +4 -6
- package/lib/node/constants/sdk-version.d.ts +1 -1
- package/lib/node/constants/sdk-version.js +1 -1
- package/lib/node/functions/evaluate/browser-runtime/browser.js +1 -1
- package/lib/node/functions/evaluate/evaluate.d.ts +3 -1
- package/lib/node/functions/evaluate/evaluate.js +39 -3
- package/lib/node/functions/evaluate/helpers.d.ts +1 -0
- package/lib/node/functions/get-block-actions-handler.js +2 -1
- package/lib/node/functions/get-processed-block.js +2 -1
- package/package.json +1 -1
- package/src/blocks/BaseText.svelte +1 -3
- package/src/blocks/button/button.svelte +2 -3
- package/src/blocks/columns/columns.svelte +3 -5
- package/src/blocks/form/form/form.svelte +5 -7
- package/src/blocks/form/submit-button/submit-button.svelte +2 -4
- package/src/blocks/image/image.svelte +4 -7
- package/src/blocks/video/video.svelte +2 -5
- package/src/components/block/block.helpers.ts +20 -1
- package/src/components/block/block.svelte +8 -11
- package/src/components/block/components/block-wrapper.svelte +2 -4
- package/src/components/block/components/interactive-element.svelte +2 -4
- package/src/components/blocks/blocks-wrapper.svelte +1 -3
- package/src/components/blocks/blocks.svelte +2 -2
- package/src/components/content/components/enable-editor.svelte +21 -10
- package/src/components/content/content.svelte +3 -5
- package/src/components/content-variants/content-variants.svelte +0 -2
- package/src/components/dynamic-renderer/dynamic-renderer.svelte +4 -6
- package/src/constants/sdk-version.ts +1 -1
- package/src/functions/evaluate/browser-runtime/browser.ts +1 -1
- package/src/functions/evaluate/evaluate.ts +44 -4
- package/src/functions/evaluate/helpers.ts +1 -0
- package/src/functions/get-block-actions-handler.ts +2 -1
- package/src/functions/get-processed-block.ts +2 -1
|
@@ -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
|
-
|
|
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
|
-
|
|
22
|
-
|
|
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.
|
|
1
|
+
export declare const SDK_VERSION = "1.0.12";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export const SDK_VERSION = "1.0.
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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, {
|
package/package.json
CHANGED
|
@@ -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
|
-
|
|
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
|
-
|
|
340
|
-
|
|
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"
|
|
@@ -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",
|
|
@@ -83,8 +82,8 @@
|
|
|
83
82
|
src={image}
|
|
84
83
|
srcset={srcSetToUse()}
|
|
85
84
|
{sizes}
|
|
86
|
-
|
|
87
|
-
|
|
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
|
-
|
|
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 {
|
|
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:
|
|
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>
|
|
@@ -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
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
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
|
-
|
|
137
|
+
/></EnableEditor
|
|
138
|
+
>
|
|
@@ -95,7 +95,6 @@
|
|
|
95
95
|
id={`variants-styles-${content?.id}`}
|
|
96
96
|
styles={hideVariantsStyleString()}
|
|
97
97
|
/>
|
|
98
|
-
|
|
99
98
|
<InlinedScript scriptStr={updateCookieAndStylesScriptStr()} />
|
|
100
99
|
|
|
101
100
|
{#each getVariants(content) as variant (variant.testVariationId)}
|
|
@@ -121,7 +120,6 @@
|
|
|
121
120
|
/>
|
|
122
121
|
{/each}
|
|
123
122
|
{/if}
|
|
124
|
-
|
|
125
123
|
<ContentComponent
|
|
126
124
|
{...{}}
|
|
127
125
|
content={defaultContent()}
|
|
@@ -21,14 +21,12 @@
|
|
|
21
21
|
<svelte:element
|
|
22
22
|
this={TagName}
|
|
23
23
|
{...attributes}
|
|
24
|
-
use:setAttrs={actionAttributes}
|
|
24
|
+
use:setAttrs={actionAttributes}><slot /></svelte:element
|
|
25
25
|
>
|
|
26
|
-
<slot />
|
|
27
|
-
</svelte:element>
|
|
28
26
|
{:else}
|
|
29
|
-
<svelte:component this={TagName} {...attributes} {...actionAttributes}
|
|
30
|
-
|
|
31
|
-
|
|
27
|
+
<svelte:component this={TagName} {...attributes} {...actionAttributes}
|
|
28
|
+
><slot /></svelte:component
|
|
29
|
+
>
|
|
32
30
|
{/if}
|
|
33
31
|
{:else}
|
|
34
32
|
<svelte:element
|