@builder.io/sdk-svelte 1.0.11 → 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.
- 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/symbol/symbol.svelte +1 -1
- 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/components/enable-editor.svelte.d.ts +1 -1
- package/lib/browser/components/content/components/styles.helpers.d.ts +1 -0
- package/lib/browser/components/content/components/styles.helpers.js +21 -0
- package/lib/browser/components/content/components/styles.svelte +3 -18
- package/lib/browser/components/content/components/styles.svelte.d.ts +2 -0
- package/lib/browser/components/content/content.svelte +5 -5
- package/lib/browser/components/content/content.svelte.d.ts +1 -0
- package/lib/browser/components/content/contentProps.types.d.ts +6 -1
- package/lib/browser/components/content-variants/content-variants.svelte +4 -4
- package/lib/browser/components/content-variants/content-variants.svelte.d.ts +2 -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/symbol/symbol.svelte +1 -1
- 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/components/enable-editor.svelte.d.ts +1 -1
- package/lib/edge/components/content/components/styles.helpers.d.ts +1 -0
- package/lib/edge/components/content/components/styles.helpers.js +21 -0
- package/lib/edge/components/content/components/styles.svelte +3 -18
- package/lib/edge/components/content/components/styles.svelte.d.ts +2 -0
- package/lib/edge/components/content/content.svelte +5 -5
- package/lib/edge/components/content/content.svelte.d.ts +1 -0
- package/lib/edge/components/content/contentProps.types.d.ts +6 -1
- package/lib/edge/components/content-variants/content-variants.svelte +4 -4
- package/lib/edge/components/content-variants/content-variants.svelte.d.ts +2 -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/symbol/symbol.svelte +1 -1
- 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/components/enable-editor.svelte.d.ts +1 -1
- package/lib/node/components/content/components/styles.helpers.d.ts +1 -0
- package/lib/node/components/content/components/styles.helpers.js +21 -0
- package/lib/node/components/content/components/styles.svelte +3 -18
- package/lib/node/components/content/components/styles.svelte.d.ts +2 -0
- package/lib/node/components/content/content.svelte +5 -5
- package/lib/node/components/content/content.svelte.d.ts +1 -0
- package/lib/node/components/content/contentProps.types.d.ts +6 -1
- package/lib/node/components/content-variants/content-variants.svelte +4 -4
- package/lib/node/components/content-variants/content-variants.svelte.d.ts +2 -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/symbol/symbol.svelte +1 -1
- 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 +22 -10
- package/src/components/content/components/styles.helpers.ts +21 -0
- package/src/components/content/components/styles.svelte +4 -18
- package/src/components/content/content.svelte +5 -5
- package/src/components/content/contentProps.types.ts +6 -1
- package/src/components/content-variants/content-variants.svelte +5 -5
- 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
|
@@ -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, {
|
|
@@ -16,6 +16,4 @@ function mitosis_styling(node, vars) {
|
|
|
16
16
|
let builderContext = getContext(BuilderContext.key);
|
|
17
17
|
</script>
|
|
18
18
|
|
|
19
|
-
<span use:mitosis_styling={$builderContext.inheritedStyles}>
|
|
20
|
-
{text}
|
|
21
|
-
</span>
|
|
19
|
+
<span use:mitosis_styling={$builderContext.inheritedStyles}>{text}</span>
|
|
@@ -131,7 +131,6 @@ let flexDir = stackColumnsAt === "never"
|
|
|
131
131
|
{#if TARGET !== "reactNative"}
|
|
132
132
|
<InlinedStyles styles={columnsStyles()} />
|
|
133
133
|
{/if}
|
|
134
|
-
|
|
135
134
|
{#each columns as column, index (index)}
|
|
136
135
|
<DynamicRenderer
|
|
137
136
|
TagName={column.link ? builderLinkComponent || "a" : "div"}
|
|
@@ -146,8 +145,7 @@ let flexDir = stackColumnsAt === "never"
|
|
|
146
145
|
[getClassPropName()]: "builder-column",
|
|
147
146
|
style: mapStyleObjToStrIfNeeded(columnCssVars(index)),
|
|
148
147
|
}}
|
|
149
|
-
|
|
150
|
-
<Blocks
|
|
148
|
+
><Blocks
|
|
151
149
|
path={`component.options.columns.${index}.blocks`}
|
|
152
150
|
parent={builderBlock.id}
|
|
153
151
|
styleProp={{
|
|
@@ -157,8 +155,8 @@ let flexDir = stackColumnsAt === "never"
|
|
|
157
155
|
registeredComponents={builderComponents}
|
|
158
156
|
linkComponent={builderLinkComponent}
|
|
159
157
|
blocks={column.blocks}
|
|
160
|
-
|
|
161
|
-
|
|
158
|
+
/></DynamicRenderer
|
|
159
|
+
>
|
|
162
160
|
{/each}
|
|
163
161
|
</div>
|
|
164
162
|
|
|
@@ -261,7 +261,6 @@ let formErrorMessage = "";
|
|
|
261
261
|
/>
|
|
262
262
|
{/each}
|
|
263
263
|
{/if}
|
|
264
|
-
|
|
265
264
|
{#if submissionState() === "error"}
|
|
266
265
|
<Blocks
|
|
267
266
|
path="errorMessage"
|
|
@@ -269,7 +268,6 @@ let formErrorMessage = "";
|
|
|
269
268
|
context={builderContext}
|
|
270
269
|
/>
|
|
271
270
|
{/if}
|
|
272
|
-
|
|
273
271
|
{#if submissionState() === "sending"}
|
|
274
272
|
<Blocks
|
|
275
273
|
path="sendingMessage"
|
|
@@ -277,13 +275,13 @@ let formErrorMessage = "";
|
|
|
277
275
|
context={builderContext}
|
|
278
276
|
/>
|
|
279
277
|
{/if}
|
|
280
|
-
|
|
281
278
|
{#if submissionState() === "error" && responseData}
|
|
282
|
-
<pre class="builder-form-error-text pre">
|
|
283
|
-
|
|
284
|
-
|
|
279
|
+
<pre class="builder-form-error-text pre">{JSON.stringify(
|
|
280
|
+
responseData,
|
|
281
|
+
null,
|
|
282
|
+
2
|
|
283
|
+
)}</pre>
|
|
285
284
|
{/if}
|
|
286
|
-
|
|
287
285
|
{#if submissionState() === "success"}
|
|
288
286
|
<Blocks
|
|
289
287
|
path="successMessage"
|
|
@@ -65,8 +65,7 @@ $: aspectRatioCss = () => {
|
|
|
65
65
|
<picture>
|
|
66
66
|
{#if webpSrcSet()}
|
|
67
67
|
<source type="image/webp" srcset={webpSrcSet()} />
|
|
68
|
-
{/if}
|
|
69
|
-
<img
|
|
68
|
+
{/if}<img
|
|
70
69
|
use:mitosis_styling={{
|
|
71
70
|
objectPosition: backgroundPosition || "center",
|
|
72
71
|
objectFit: backgroundSize || "cover",
|
|
@@ -79,8 +78,8 @@ $: aspectRatioCss = () => {
|
|
|
79
78
|
src={image}
|
|
80
79
|
srcset={srcSetToUse()}
|
|
81
80
|
{sizes}
|
|
82
|
-
|
|
83
|
-
|
|
81
|
+
/></picture
|
|
82
|
+
>
|
|
84
83
|
|
|
85
84
|
{#if aspectRatio && !(builderBlock?.children?.length && fitContent)}
|
|
86
85
|
<div
|
|
@@ -96,9 +95,7 @@ $: aspectRatioCss = () => {
|
|
|
96
95
|
{/if}
|
|
97
96
|
|
|
98
97
|
{#if !fitContent && $$slots.default}
|
|
99
|
-
<div class="div-2">
|
|
100
|
-
<slot />
|
|
101
|
-
</div>
|
|
98
|
+
<div class="div-2"><slot /></div>
|
|
102
99
|
{/if}
|
|
103
100
|
|
|
104
101
|
<style>
|
|
@@ -89,9 +89,8 @@ $: spreadProps = () => {
|
|
|
89
89
|
>
|
|
90
90
|
{#if !lazyLoad}
|
|
91
91
|
<source type="video/mp4" src={video} />
|
|
92
|
-
{/if}
|
|
93
|
-
|
|
94
|
-
|
|
92
|
+
{/if}</video
|
|
93
|
+
>
|
|
95
94
|
{#if aspectRatio && !(fitContent && builderBlock?.children?.length)}
|
|
96
95
|
<div
|
|
97
96
|
use:mitosis_styling={{
|
|
@@ -102,7 +101,6 @@ $: spreadProps = () => {
|
|
|
102
101
|
}}
|
|
103
102
|
/>
|
|
104
103
|
{/if}
|
|
105
|
-
|
|
106
104
|
{#if builderBlock?.children?.length && fitContent}
|
|
107
105
|
<div
|
|
108
106
|
use:mitosis_styling={{
|
|
@@ -114,7 +112,6 @@ $: spreadProps = () => {
|
|
|
114
112
|
<slot />
|
|
115
113
|
</div>
|
|
116
114
|
{/if}
|
|
117
|
-
|
|
118
115
|
{#if builderBlock?.children?.length && !fitContent}
|
|
119
116
|
<div
|
|
120
117
|
use:mitosis_styling={{
|
|
@@ -10,3 +10,7 @@ export declare const getRepeatItemData: ({ block, context }: {
|
|
|
10
10
|
block: BuilderBlock;
|
|
11
11
|
context: BuilderContextInterface;
|
|
12
12
|
}) => RepeatData[] | undefined;
|
|
13
|
+
export declare const getInheritedStyles: ({ block, context }: {
|
|
14
|
+
block: BuilderBlock;
|
|
15
|
+
context: BuilderContextInterface;
|
|
16
|
+
}) => Partial<CSSStyleDeclaration>;
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { evaluate } from '../../functions/evaluate/index.js';
|
|
2
|
+
import { extractTextStyles } from '../../functions/extract-text-styles.js';
|
|
2
3
|
import { getProcessedBlock } from '../../functions/get-processed-block.js';
|
|
4
|
+
import { getStyle } from '../../functions/get-style.js';
|
|
3
5
|
export const getComponent = ({ block, context, registeredComponents }) => {
|
|
4
6
|
const componentName = getProcessedBlock({
|
|
5
7
|
block,
|
|
@@ -38,7 +40,8 @@ export const getRepeatItemData = ({ block, context }) => {
|
|
|
38
40
|
localState: context.localState,
|
|
39
41
|
rootState: context.rootState,
|
|
40
42
|
rootSetState: context.rootSetState,
|
|
41
|
-
context: context.context
|
|
43
|
+
context: context.context,
|
|
44
|
+
enableCache: true
|
|
42
45
|
});
|
|
43
46
|
if (!Array.isArray(itemsArray)) {
|
|
44
47
|
return undefined;
|
|
@@ -60,3 +63,13 @@ export const getRepeatItemData = ({ block, context }) => {
|
|
|
60
63
|
}));
|
|
61
64
|
return repeatArray;
|
|
62
65
|
};
|
|
66
|
+
export const getInheritedStyles = ({ block, context }) => {
|
|
67
|
+
const style = getStyle({
|
|
68
|
+
block,
|
|
69
|
+
context
|
|
70
|
+
});
|
|
71
|
+
if (!style) {
|
|
72
|
+
return {};
|
|
73
|
+
}
|
|
74
|
+
return extractTextStyles(style);
|
|
75
|
+
};
|
|
@@ -1,13 +1,10 @@
|
|
|
1
1
|
<script context="module"></script>
|
|
2
2
|
|
|
3
3
|
<script>import { onMount } from "svelte";
|
|
4
|
-
import { writable } from "svelte/store";
|
|
5
|
-
import "../../functions/extract-text-styles.js";
|
|
6
4
|
import { getBlockComponentOptions } from "../../functions/get-block-component-options.js";
|
|
7
5
|
import { getProcessedBlock } from "../../functions/get-processed-block.js";
|
|
8
|
-
import "../../functions/get-style.js";
|
|
9
6
|
import { bindAnimations } from "./animator.js";
|
|
10
|
-
import { getComponent, getRepeatItemData } from "./block.helpers.js";
|
|
7
|
+
import { getComponent, getRepeatItemData, } from "./block.helpers.js";
|
|
11
8
|
import BlockStyles from "./components/block-styles.svelte";
|
|
12
9
|
import BlockWrapper from "./components/block-wrapper.svelte";
|
|
13
10
|
import ComponentRef from "./components/component-ref/component-ref.svelte";
|
|
@@ -95,7 +92,7 @@ $: componentRefProps = () => {
|
|
|
95
92
|
}
|
|
96
93
|
: {}),
|
|
97
94
|
},
|
|
98
|
-
context:
|
|
95
|
+
context: context,
|
|
99
96
|
linkComponent: linkComponent,
|
|
100
97
|
registeredComponents: registeredComponents,
|
|
101
98
|
builderBlock: processedBlock(),
|
|
@@ -103,7 +100,6 @@ $: componentRefProps = () => {
|
|
|
103
100
|
isInteractive: !blockComponent?.()?.isRSC,
|
|
104
101
|
};
|
|
105
102
|
};
|
|
106
|
-
let childrenContext = writable($context);
|
|
107
103
|
onMount(() => {
|
|
108
104
|
const blockId = processedBlock().id;
|
|
109
105
|
const animations = processedBlock().animations;
|
|
@@ -128,8 +124,7 @@ onMount(() => {
|
|
|
128
124
|
block={processedBlock()}
|
|
129
125
|
{context}
|
|
130
126
|
{linkComponent}
|
|
131
|
-
|
|
132
|
-
<ComponentRef
|
|
127
|
+
><ComponentRef
|
|
133
128
|
componentRef={componentRefProps().componentRef}
|
|
134
129
|
componentOptions={componentRefProps().componentOptions}
|
|
135
130
|
blockChildren={componentRefProps().blockChildren}
|
|
@@ -140,13 +135,12 @@ onMount(() => {
|
|
|
140
135
|
includeBlockProps={componentRefProps().includeBlockProps}
|
|
141
136
|
isInteractive={componentRefProps().isInteractive}
|
|
142
137
|
/>
|
|
143
|
-
|
|
144
138
|
{#each childrenWithoutParentComponent() as child (child.id)}
|
|
145
139
|
<svelte:self
|
|
146
140
|
block={child}
|
|
147
|
-
context={childrenContext}
|
|
148
141
|
{registeredComponents}
|
|
149
142
|
{linkComponent}
|
|
143
|
+
{context}
|
|
150
144
|
/>
|
|
151
145
|
{/each}
|
|
152
146
|
</BlockWrapper>
|
|
@@ -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}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { SvelteComponent } from "svelte";
|
|
2
|
-
type BuilderEditorProps = Omit<ContentProps, "customComponents" | "apiVersion" | "isSsrAbTest" | "blocksWrapper" | "blocksWrapperProps"> & {
|
|
2
|
+
type BuilderEditorProps = Omit<ContentProps, "customComponents" | "apiVersion" | "isSsrAbTest" | "blocksWrapper" | "blocksWrapperProps" | "isNestedRender"> & {
|
|
3
3
|
builderContextSignal: Writable<BuilderContextInterface>;
|
|
4
4
|
setBuilderContextSignal?: (signal: any) => any;
|
|
5
5
|
children?: any;
|
|
@@ -13,3 +13,4 @@ export declare const getCss: ({ cssCode, contentId }: {
|
|
|
13
13
|
cssCode?: string | undefined;
|
|
14
14
|
contentId?: string | undefined;
|
|
15
15
|
}) => string;
|
|
16
|
+
export declare const getDefaultStyles: (isNested: boolean | undefined) => "" | "\n.builder-button {\n all: unset;\n}\n\n.builder-text > p:first-of-type, .builder-text > .builder-paragraph:first-of-type {\n margin: 0;\n}\n.builder-text > p, .builder-text > .builder-paragraph {\n color: inherit;\n line-height: inherit;\n letter-spacing: inherit;\n font-weight: inherit;\n font-size: inherit;\n text-align: inherit;\n font-family: inherit;\n}\n";
|
|
@@ -56,3 +56,24 @@ export const getCss = ({ cssCode, contentId }) => {
|
|
|
56
56
|
// TODO: handle if '&' is within a string like `content: "&"`
|
|
57
57
|
return cssCode?.replace(/&/g, `div[builder-content-id="${contentId}"]`) || '';
|
|
58
58
|
};
|
|
59
|
+
const DEFAULT_STYLES = `
|
|
60
|
+
.builder-button {
|
|
61
|
+
all: unset;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
.builder-text > p:first-of-type, .builder-text > .builder-paragraph:first-of-type {
|
|
65
|
+
margin: 0;
|
|
66
|
+
}
|
|
67
|
+
.builder-text > p, .builder-text > .builder-paragraph {
|
|
68
|
+
color: inherit;
|
|
69
|
+
line-height: inherit;
|
|
70
|
+
letter-spacing: inherit;
|
|
71
|
+
font-weight: inherit;
|
|
72
|
+
font-size: inherit;
|
|
73
|
+
text-align: inherit;
|
|
74
|
+
font-family: inherit;
|
|
75
|
+
}
|
|
76
|
+
`;
|
|
77
|
+
export const getDefaultStyles = (isNested) => {
|
|
78
|
+
return !isNested ? DEFAULT_STYLES : '';
|
|
79
|
+
};
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
<script context="module"></script>
|
|
2
2
|
|
|
3
3
|
<script>import InlinedStyles from "../../inlined-styles.svelte";
|
|
4
|
-
import { getCss, getFontCss } from "./styles.helpers.js";
|
|
4
|
+
import { getCss, getDefaultStyles, getFontCss } from "./styles.helpers.js";
|
|
5
5
|
export let cssCode = undefined;
|
|
6
6
|
export let contentId = undefined;
|
|
7
7
|
export let customFonts = undefined;
|
|
8
|
+
export let isNestedRender = undefined;
|
|
8
9
|
let injectedStyles = `
|
|
9
10
|
${getCss({
|
|
10
11
|
cssCode: cssCode,
|
|
@@ -13,23 +14,7 @@ ${getCss({
|
|
|
13
14
|
${getFontCss({
|
|
14
15
|
customFonts: customFonts,
|
|
15
16
|
})}
|
|
16
|
-
|
|
17
|
-
.builder-button {
|
|
18
|
-
all: unset;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
.builder-text > p:first-of-type, .builder-text > .builder-paragraph:first-of-type {
|
|
22
|
-
margin: 0;
|
|
23
|
-
}
|
|
24
|
-
.builder-text > p, .builder-text > .builder-paragraph {
|
|
25
|
-
color: inherit;
|
|
26
|
-
line-height: inherit;
|
|
27
|
-
letter-spacing: inherit;
|
|
28
|
-
font-weight: inherit;
|
|
29
|
-
font-size: inherit;
|
|
30
|
-
text-align: inherit;
|
|
31
|
-
font-family: inherit;
|
|
32
|
-
}
|
|
17
|
+
${getDefaultStyles(isNestedRender)}
|
|
33
18
|
`.trim();
|
|
34
19
|
</script>
|
|
35
20
|
|
|
@@ -3,6 +3,7 @@ interface Props {
|
|
|
3
3
|
cssCode?: string;
|
|
4
4
|
customFonts?: CustomFont[];
|
|
5
5
|
contentId?: string;
|
|
6
|
+
isNestedRender?: boolean;
|
|
6
7
|
}
|
|
7
8
|
import type { CustomFont } from "./styles.helpers.js";
|
|
8
9
|
declare const __propDef: {
|
|
@@ -10,6 +11,7 @@ declare const __propDef: {
|
|
|
10
11
|
cssCode?: Props["cssCode"];
|
|
11
12
|
contentId?: Props["contentId"];
|
|
12
13
|
customFonts?: Props["customFonts"];
|
|
14
|
+
isNestedRender?: Props["isNestedRender"];
|
|
13
15
|
};
|
|
14
16
|
events: {
|
|
15
17
|
[evt: string]: CustomEvent<any>;
|
|
@@ -29,6 +29,7 @@ export let contentWrapperProps = undefined;
|
|
|
29
29
|
export let linkComponent = undefined;
|
|
30
30
|
export let trustedHosts = undefined;
|
|
31
31
|
export let isSsrAbTest;
|
|
32
|
+
export let isNestedRender = undefined;
|
|
32
33
|
function contentSetState(newRootState) {
|
|
33
34
|
$builderContextSignal.rootState = newRootState;
|
|
34
35
|
}
|
|
@@ -99,18 +100,17 @@ setContext(ComponentsContext.key, {
|
|
|
99
100
|
{#if isSsrAbTest}
|
|
100
101
|
<InlinedScript {scriptStr} />
|
|
101
102
|
{/if}
|
|
102
|
-
|
|
103
103
|
{#if TARGET !== "reactNative"}
|
|
104
104
|
<ContentStyles
|
|
105
|
+
{isNestedRender}
|
|
105
106
|
contentId={$builderContextSignal.content?.id}
|
|
106
107
|
cssCode={$builderContextSignal.content?.data?.cssCode}
|
|
107
108
|
customFonts={$builderContextSignal.content?.data?.customFonts}
|
|
108
109
|
/>
|
|
109
|
-
{/if}
|
|
110
|
-
<Blocks
|
|
110
|
+
{/if}<Blocks
|
|
111
111
|
blocks={$builderContextSignal.content?.data?.blocks}
|
|
112
112
|
context={builderContextSignal}
|
|
113
113
|
{registeredComponents}
|
|
114
114
|
{linkComponent}
|
|
115
|
-
|
|
116
|
-
|
|
115
|
+
/></EnableEditor
|
|
116
|
+
>
|
|
@@ -20,6 +20,7 @@ declare const __propDef: {
|
|
|
20
20
|
linkComponent?: ContentProps["linkComponent"];
|
|
21
21
|
trustedHosts?: ContentProps["trustedHosts"];
|
|
22
22
|
isSsrAbTest: ContentProps["isSsrAbTest"];
|
|
23
|
+
isNestedRender?: ContentProps["isNestedRender"];
|
|
23
24
|
};
|
|
24
25
|
events: {
|
|
25
26
|
[evt: string]: CustomEvent<any>;
|
|
@@ -8,5 +8,10 @@ interface InternalRenderProps {
|
|
|
8
8
|
* This is in a separate file so that we can override it (most notably in Vue,
|
|
9
9
|
* where prop types cannot be wrapped by generics like `EnforcePartials`).
|
|
10
10
|
*/
|
|
11
|
-
export type ContentProps = InternalRenderProps & EnforcePartials<ContentVariantsPrps
|
|
11
|
+
export type ContentProps = InternalRenderProps & EnforcePartials<ContentVariantsPrps> & {
|
|
12
|
+
/**
|
|
13
|
+
* For internal use only. Do not provide this prop.
|
|
14
|
+
*/
|
|
15
|
+
isNestedRender?: boolean;
|
|
16
|
+
};
|
|
12
17
|
export {};
|
|
@@ -10,7 +10,7 @@ import InlinedStyles from "../inlined-styles.svelte";
|
|
|
10
10
|
import { checkShouldRenderVariants, getScriptString, getUpdateCookieAndStylesScript, getVariants, } from "./helpers.js";
|
|
11
11
|
export let canTrack = undefined;
|
|
12
12
|
export let content = undefined;
|
|
13
|
-
export let
|
|
13
|
+
export let isNestedRender = undefined;
|
|
14
14
|
export let model = undefined;
|
|
15
15
|
export let data = undefined;
|
|
16
16
|
export let context = undefined;
|
|
@@ -59,7 +59,7 @@ onMount(() => {
|
|
|
59
59
|
});
|
|
60
60
|
</script>
|
|
61
61
|
|
|
62
|
-
{#if !
|
|
62
|
+
{#if !isNestedRender && TARGET !== "reactNative"}
|
|
63
63
|
<InlinedScript scriptStr={getScriptString()} />
|
|
64
64
|
{/if}
|
|
65
65
|
|
|
@@ -68,11 +68,11 @@ 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)}
|
|
75
74
|
<ContentComponent
|
|
75
|
+
{isNestedRender}
|
|
76
76
|
content={variant}
|
|
77
77
|
showContent={false}
|
|
78
78
|
{model}
|
|
@@ -94,8 +94,8 @@ onMount(() => {
|
|
|
94
94
|
/>
|
|
95
95
|
{/each}
|
|
96
96
|
{/if}
|
|
97
|
-
|
|
98
97
|
<ContentComponent
|
|
98
|
+
{isNestedRender}
|
|
99
99
|
{...{}}
|
|
100
100
|
content={defaultContent()}
|
|
101
101
|
showContent={true}
|
|
@@ -3,14 +3,14 @@ type VariantsProviderProps = ContentVariantsPrps & {
|
|
|
3
3
|
/**
|
|
4
4
|
* For internal use only. Do not provide this prop.
|
|
5
5
|
*/
|
|
6
|
-
|
|
6
|
+
isNestedRender?: boolean;
|
|
7
7
|
};
|
|
8
8
|
import type { ContentVariantsPrps } from "./content-variants.types.js";
|
|
9
9
|
declare const __propDef: {
|
|
10
10
|
props: {
|
|
11
11
|
canTrack?: VariantsProviderProps["canTrack"];
|
|
12
12
|
content?: VariantsProviderProps["content"];
|
|
13
|
-
|
|
13
|
+
isNestedRender?: VariantsProviderProps["isNestedRender"];
|
|
14
14
|
model?: VariantsProviderProps["model"];
|
|
15
15
|
data?: VariantsProviderProps["data"];
|
|
16
16
|
context?: VariantsProviderProps["context"];
|
|
@@ -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.13";
|