@builder.io/sdk-svelte 0.2.2 → 0.3.1
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/package/--package.json +3 -1
- package/package/CHANGELOG.md +4 -0
- package/package/blocks/columns/columns.svelte +21 -24
- package/package/blocks/columns/columns.svelte.d.ts +1 -1
- package/package/blocks/image/image.svelte +1 -2
- package/package/blocks/image/image.svelte.d.ts +2 -2
- package/package/blocks/symbol/symbol.svelte +1 -3
- package/package/blocks/symbol/symbol.svelte.d.ts +2 -2
- package/package/components/render-block/block-styles.svelte +3 -3
- package/package/components/render-block/block-styles.svelte.d.ts +2 -2
- package/package/components/render-block/render-block.helpers.d.ts +0 -1
- package/package/components/render-block/render-block.helpers.js +8 -20
- package/package/components/render-block/render-block.svelte +22 -19
- package/package/components/render-block/render-block.svelte.d.ts +2 -2
- package/package/components/render-block/render-component.svelte +1 -3
- package/package/components/render-block/render-component.svelte.d.ts +2 -2
- package/package/components/render-block/render-repeated-block.svelte +4 -4
- package/package/components/render-block/render-repeated-block.svelte.d.ts +2 -2
- package/package/components/render-blocks.svelte +0 -1
- package/package/components/render-blocks.svelte.d.ts +1 -1
- package/package/components/render-content/components/render-styles.svelte +8 -9
- package/package/components/render-content/components/render-styles.svelte.d.ts +1 -1
- package/package/components/render-content/render-content.svelte +18 -12
- package/package/components/render-content/render-content.svelte.d.ts +1 -1
- package/package/components/render-inlined-styles.svelte +2 -2
- package/package/constants/sdk-version.d.ts +1 -0
- package/package/constants/sdk-version.js +1 -0
- package/package/context/builder.context.d.ts +3 -2
- package/package/context/builder.context.js +3 -2
- package/package/context/types.d.ts +17 -2
- package/package/functions/evaluate.d.ts +4 -3
- package/package/functions/evaluate.js +23 -2
- package/package/functions/evaluate.test.d.ts +1 -0
- package/package/functions/evaluate.test.js +17 -0
- package/package/functions/get-block-actions-handler.d.ts +1 -1
- package/package/functions/get-block-actions-handler.js +3 -1
- package/package/functions/get-block-actions.d.ts +1 -1
- package/package/functions/get-content/index.js +1 -1
- package/package/functions/get-processed-block.d.ts +2 -2
- package/package/functions/get-processed-block.js +16 -4
- package/package/functions/get-processed-block.test.js +3 -1
- package/package/index.d.ts +1 -0
- package/package/scripts/init-editing.js +2 -0
- package/package.json +1 -4
- package/src/blocks/columns/columns.svelte +26 -30
- package/src/blocks/image/image.svelte +3 -3
- package/src/blocks/symbol/symbol.svelte +3 -3
- package/src/components/render-block/block-styles.svelte +5 -3
- package/src/components/render-block/render-block.helpers.ts +9 -31
- package/src/components/render-block/render-block.svelte +23 -18
- package/src/components/render-block/render-component.svelte +2 -2
- package/src/components/render-block/render-repeated-block.svelte +6 -4
- package/src/components/render-blocks.svelte +1 -1
- package/src/components/render-content/components/render-styles.svelte +9 -9
- package/src/components/render-content/render-content.svelte +25 -12
- package/src/components/render-inlined-styles.svelte +2 -2
- package/src/constants/sdk-version.ts +1 -0
- package/src/context/builder.context.ts +3 -2
- package/src/context/types.ts +17 -2
- package/src/functions/evaluate.test.ts +21 -0
- package/src/functions/evaluate.ts +46 -4
- package/src/functions/get-block-actions-handler.ts +7 -2
- package/src/functions/get-block-actions.ts +4 -1
- package/src/functions/get-content/index.ts +1 -1
- package/src/functions/get-processed-block.test.ts +3 -1
- package/src/functions/get-processed-block.ts +28 -6
- package/src/index.ts +1 -0
- package/src/scripts/init-editing.ts +2 -0
package/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": "0.
|
|
4
|
+
"version": "0.3.1",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"files": [
|
|
7
7
|
"package",
|
|
@@ -81,10 +81,12 @@
|
|
|
81
81
|
"./components/render-inlined-styles.svelte": "./components/render-inlined-styles.svelte",
|
|
82
82
|
"./constants/builder-registered-components": "./constants/builder-registered-components.js",
|
|
83
83
|
"./constants/device-sizes": "./constants/device-sizes.js",
|
|
84
|
+
"./constants/sdk-version": "./constants/sdk-version.js",
|
|
84
85
|
"./constants/target": "./constants/target.js",
|
|
85
86
|
"./context/builder.context": "./context/builder.context.js",
|
|
86
87
|
"./context/types": "./context/types.js",
|
|
87
88
|
"./functions/camel-to-kebab-case": "./functions/camel-to-kebab-case.js",
|
|
89
|
+
"./functions/evaluate.test": "./functions/evaluate.test.js",
|
|
88
90
|
"./functions/evaluate": "./functions/evaluate.js",
|
|
89
91
|
"./functions/event-handler-name": "./functions/event-handler-name.js",
|
|
90
92
|
"./functions/extract-text-styles": "./functions/extract-text-styles.js",
|
package/package/CHANGELOG.md
CHANGED
|
@@ -2,13 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
<script>import { getContext } from "svelte";
|
|
4
4
|
import RenderBlocks from "../../components/render-blocks.svelte";
|
|
5
|
-
import "../../types/builder-block";
|
|
6
5
|
import { getSizesForBreakpoints } from "../../constants/device-sizes";
|
|
7
|
-
import "../../constants/device-sizes";
|
|
8
6
|
import RenderInlinedStyles from "../../components/render-inlined-styles.svelte";
|
|
9
7
|
import { TARGET } from "../../constants/target.js";
|
|
10
8
|
import BuilderContext from "../../context/builder.context.js";
|
|
11
|
-
import "../../types/typescript";
|
|
12
9
|
export let space;
|
|
13
10
|
export let columns;
|
|
14
11
|
export let stackColumnsAt;
|
|
@@ -46,7 +43,7 @@ function columnCssVars(index) {
|
|
|
46
43
|
};
|
|
47
44
|
}
|
|
48
45
|
const width = getColumnCssWidth(index);
|
|
49
|
-
const gutterPixels = `${
|
|
46
|
+
const gutterPixels = `${gutter}px`;
|
|
50
47
|
const mobileWidth = "100%";
|
|
51
48
|
const mobileMarginLeft = 0;
|
|
52
49
|
return {
|
|
@@ -90,30 +87,30 @@ $: columnsCssVars = () => {
|
|
|
90
87
|
};
|
|
91
88
|
$: columnsStyles = () => {
|
|
92
89
|
return `
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
90
|
+
@media (max-width: ${getWidthForBreakpointSize("medium")}px) {
|
|
91
|
+
.${builderBlock.id}-breakpoints {
|
|
92
|
+
flex-direction: var(--flex-dir-tablet);
|
|
93
|
+
align-items: stretch;
|
|
94
|
+
}
|
|
98
95
|
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
96
|
+
.${builderBlock.id}-breakpoints > .builder-column {
|
|
97
|
+
width: var(--column-width-tablet) !important;
|
|
98
|
+
margin-left: var(--column-margin-left-tablet) !important;
|
|
99
|
+
}
|
|
102
100
|
}
|
|
103
|
-
}
|
|
104
101
|
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
102
|
+
@media (max-width: ${getWidthForBreakpointSize("small")}px) {
|
|
103
|
+
.${builderBlock.id}-breakpoints {
|
|
104
|
+
flex-direction: var(--flex-dir);
|
|
105
|
+
align-items: stretch;
|
|
106
|
+
}
|
|
110
107
|
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
108
|
+
.${builderBlock.id}-breakpoints > .builder-column {
|
|
109
|
+
width: var(--column-width-mobile) !important;
|
|
110
|
+
margin-left: var(--column-margin-left-mobile) !important;
|
|
111
|
+
}
|
|
112
|
+
},
|
|
113
|
+
`;
|
|
117
114
|
};
|
|
118
115
|
let gutterSize = typeof space === "number" ? space || 0 : 20;
|
|
119
116
|
let cols = columns || [];
|
|
@@ -11,7 +11,7 @@ export interface ColumnProps {
|
|
|
11
11
|
stackColumnsAt?: StackColumnsAt;
|
|
12
12
|
reverseColumnsWhenStacked?: boolean;
|
|
13
13
|
}
|
|
14
|
-
import { BuilderBlock } from "../../types/builder-block";
|
|
14
|
+
import type { BuilderBlock } from "../../types/builder-block";
|
|
15
15
|
declare const __propDef: {
|
|
16
16
|
props: {
|
|
17
17
|
space: ColumnProps["space"];
|
|
@@ -8,7 +8,7 @@ export interface ImageProps {
|
|
|
8
8
|
height?: number;
|
|
9
9
|
width?: number;
|
|
10
10
|
altText?: string;
|
|
11
|
-
backgroundSize?:
|
|
11
|
+
backgroundSize?: "cover" | "contain";
|
|
12
12
|
backgroundPosition?: string;
|
|
13
13
|
srcset?: string;
|
|
14
14
|
aspectRatio?: number;
|
|
@@ -18,7 +18,7 @@ export interface ImageProps {
|
|
|
18
18
|
noWebp?: boolean;
|
|
19
19
|
src?: string;
|
|
20
20
|
}
|
|
21
|
-
import { BuilderBlock } from "../../types/builder-block.js";
|
|
21
|
+
import type { BuilderBlock } from "../../types/builder-block.js";
|
|
22
22
|
declare const __propDef: {
|
|
23
23
|
props: {
|
|
24
24
|
image: ImageProps["image"];
|
|
@@ -4,8 +4,6 @@
|
|
|
4
4
|
import RenderContent from "../../components/render-content/render-content.svelte";
|
|
5
5
|
import BuilderContext from "../../context/builder.context.js";
|
|
6
6
|
import { getContent } from "../../functions/get-content/index.js";
|
|
7
|
-
import "../../types/builder-content.js";
|
|
8
|
-
import "../../types/builder-block.js";
|
|
9
7
|
import { TARGET } from "../../constants/target";
|
|
10
8
|
import { logger } from "../../helpers/logger";
|
|
11
9
|
const isEvent = (attr) => attr.startsWith("on:");
|
|
@@ -106,7 +104,7 @@ $: onUpdateFn_0(...[symbol]);
|
|
|
106
104
|
customComponents={Object.values(builderContext.registeredComponents)}
|
|
107
105
|
data={{
|
|
108
106
|
...symbol?.data,
|
|
109
|
-
...builderContext.
|
|
107
|
+
...builderContext.localState,
|
|
110
108
|
...contentToUse?.data?.state,
|
|
111
109
|
}}
|
|
112
110
|
model={symbol?.model}
|
|
@@ -15,8 +15,8 @@ export interface SymbolProps {
|
|
|
15
15
|
attributes?: any;
|
|
16
16
|
inheritState?: boolean;
|
|
17
17
|
}
|
|
18
|
-
import { BuilderContent } from "../../types/builder-content.js";
|
|
19
|
-
import { BuilderBlock } from "../../types/builder-block.js";
|
|
18
|
+
import type { BuilderContent } from "../../types/builder-content.js";
|
|
19
|
+
import type { BuilderBlock } from "../../types/builder-block.js";
|
|
20
20
|
declare const __propDef: {
|
|
21
21
|
props: {
|
|
22
22
|
attributes: SymbolProps["attributes"];
|
|
@@ -2,18 +2,18 @@
|
|
|
2
2
|
|
|
3
3
|
<script>import { getMaxWidthQueryForSize, getSizesForBreakpoints, } from "../../constants/device-sizes.js";
|
|
4
4
|
import { TARGET } from "../../constants/target.js";
|
|
5
|
-
import "../../context/types.js";
|
|
6
5
|
import { getProcessedBlock } from "../../functions/get-processed-block.js";
|
|
7
6
|
import { createCssClass } from "../../helpers/css.js";
|
|
8
7
|
import { checkIsDefined } from "../../helpers/nullable.js";
|
|
9
|
-
import "../../types/builder-block.js";
|
|
10
8
|
import RenderInlinedStyles from "../render-inlined-styles.svelte";
|
|
11
9
|
export let block;
|
|
12
10
|
export let context;
|
|
13
11
|
$: useBlock = () => {
|
|
14
12
|
return getProcessedBlock({
|
|
15
13
|
block: block,
|
|
16
|
-
|
|
14
|
+
localState: context.localState,
|
|
15
|
+
rootState: context.rootState,
|
|
16
|
+
rootSetState: context.rootSetState,
|
|
17
17
|
context: context.context,
|
|
18
18
|
shouldEvaluateBindings: true,
|
|
19
19
|
});
|
|
@@ -3,8 +3,8 @@ export type BlockStylesProps = {
|
|
|
3
3
|
block: BuilderBlock;
|
|
4
4
|
context: BuilderContextInterface;
|
|
5
5
|
};
|
|
6
|
-
import { BuilderContextInterface } from "../../context/types.js";
|
|
7
|
-
import { BuilderBlock } from "../../types/builder-block.js";
|
|
6
|
+
import type { BuilderContextInterface } from "../../context/types.js";
|
|
7
|
+
import type { BuilderBlock } from "../../types/builder-block.js";
|
|
8
8
|
declare const __propDef: {
|
|
9
9
|
props: {
|
|
10
10
|
block: BlockStylesProps["block"];
|
|
@@ -27,7 +27,9 @@ export const isEmptyHtmlElement = (tagName) => {
|
|
|
27
27
|
export const getComponent = ({ block, context, }) => {
|
|
28
28
|
const componentName = getProcessedBlock({
|
|
29
29
|
block,
|
|
30
|
-
|
|
30
|
+
localState: context.localState,
|
|
31
|
+
rootState: context.rootState,
|
|
32
|
+
rootSetState: context.rootSetState,
|
|
31
33
|
context: context.context,
|
|
32
34
|
shouldEvaluateBindings: false,
|
|
33
35
|
}).component?.name;
|
|
@@ -57,7 +59,9 @@ export const getRepeatItemData = ({ block, context, }) => {
|
|
|
57
59
|
}
|
|
58
60
|
const itemsArray = evaluate({
|
|
59
61
|
code: repeat.collection,
|
|
60
|
-
|
|
62
|
+
localState: context.localState,
|
|
63
|
+
rootState: context.rootState,
|
|
64
|
+
rootSetState: context.rootSetState,
|
|
61
65
|
context: context.context,
|
|
62
66
|
});
|
|
63
67
|
if (!Array.isArray(itemsArray)) {
|
|
@@ -68,8 +72,8 @@ export const getRepeatItemData = ({ block, context, }) => {
|
|
|
68
72
|
const repeatArray = itemsArray.map((item, index) => ({
|
|
69
73
|
context: {
|
|
70
74
|
...context,
|
|
71
|
-
|
|
72
|
-
...context.
|
|
75
|
+
localState: {
|
|
76
|
+
...context.localState,
|
|
73
77
|
$index: index,
|
|
74
78
|
$item: item,
|
|
75
79
|
[itemNameToUse]: item,
|
|
@@ -80,19 +84,3 @@ export const getRepeatItemData = ({ block, context, }) => {
|
|
|
80
84
|
}));
|
|
81
85
|
return repeatArray;
|
|
82
86
|
};
|
|
83
|
-
export const getProxyState = (context) => {
|
|
84
|
-
if (typeof Proxy === 'undefined') {
|
|
85
|
-
console.error('no Proxy available in this environment, cannot proxy state.');
|
|
86
|
-
return context.state;
|
|
87
|
-
}
|
|
88
|
-
const useState = new Proxy(context.state, {
|
|
89
|
-
set: (obj, prop, value) => {
|
|
90
|
-
// set the value on the state object, so that the event handler instantly gets the update.
|
|
91
|
-
obj[prop] = value;
|
|
92
|
-
// set the value in the context, so that the rest of the app gets the update.
|
|
93
|
-
context.setState?.(obj);
|
|
94
|
-
return true;
|
|
95
|
-
},
|
|
96
|
-
});
|
|
97
|
-
return useState;
|
|
98
|
-
};
|
|
@@ -1,14 +1,11 @@
|
|
|
1
1
|
<script context="module"></script>
|
|
2
2
|
|
|
3
|
-
<script>import "../../
|
|
4
|
-
import { getBlockActions } from "../../functions/get-block-actions.js";
|
|
3
|
+
<script>import { getBlockActions } from "../../functions/get-block-actions.js";
|
|
5
4
|
import { getBlockComponentOptions } from "../../functions/get-block-component-options.js";
|
|
6
5
|
import { getBlockProperties } from "../../functions/get-block-properties.js";
|
|
7
6
|
import { getProcessedBlock } from "../../functions/get-processed-block.js";
|
|
8
|
-
import "../../types/builder-block.js";
|
|
9
7
|
import BlockStyles from "./block-styles.svelte";
|
|
10
|
-
import { getComponent,
|
|
11
|
-
import "./render-component.svelte";
|
|
8
|
+
import { getComponent, getRepeatItemData, isEmptyHtmlElement, } from "./render-block.helpers.js";
|
|
12
9
|
import RenderRepeatedBlock from "./render-repeated-block.svelte";
|
|
13
10
|
import { TARGET } from "../../constants/target.js";
|
|
14
11
|
import { extractTextStyles } from "../../functions/extract-text-styles.js";
|
|
@@ -32,12 +29,20 @@ const setAttrs = (node, attrs = {}) => {
|
|
|
32
29
|
};
|
|
33
30
|
export let block;
|
|
34
31
|
export let context;
|
|
32
|
+
$: repeatItem = () => {
|
|
33
|
+
return getRepeatItemData({
|
|
34
|
+
block: block,
|
|
35
|
+
context: context,
|
|
36
|
+
});
|
|
37
|
+
};
|
|
35
38
|
$: useBlock = () => {
|
|
36
|
-
return
|
|
39
|
+
return repeatItem()
|
|
37
40
|
? block
|
|
38
41
|
: getProcessedBlock({
|
|
39
42
|
block: block,
|
|
40
|
-
|
|
43
|
+
localState: context.localState,
|
|
44
|
+
rootState: context.rootState,
|
|
45
|
+
rootSetState: context.rootSetState,
|
|
41
46
|
context: context.context,
|
|
42
47
|
shouldEvaluateBindings: true,
|
|
43
48
|
});
|
|
@@ -54,7 +59,9 @@ $: canShowBlock = () => {
|
|
|
54
59
|
$: actions = () => {
|
|
55
60
|
return getBlockActions({
|
|
56
61
|
block: useBlock(),
|
|
57
|
-
|
|
62
|
+
rootState: context.rootState,
|
|
63
|
+
rootSetState: context.rootSetState,
|
|
64
|
+
localState: context.localState,
|
|
58
65
|
context: context.context,
|
|
59
66
|
});
|
|
60
67
|
};
|
|
@@ -80,7 +87,7 @@ $: childrenWithoutParentComponent = () => {
|
|
|
80
87
|
* NOTE: We make sure not to render this if `repeatItemData` is non-null, because that means we are rendering an array of
|
|
81
88
|
* blocks, and the children will be repeated within those blocks.
|
|
82
89
|
*/
|
|
83
|
-
const shouldRenderChildrenOutsideRef = !component?.component && !
|
|
90
|
+
const shouldRenderChildrenOutsideRef = !component?.component && !repeatItem();
|
|
84
91
|
return shouldRenderChildrenOutsideRef ? useBlock().children ?? [] : [];
|
|
85
92
|
};
|
|
86
93
|
$: childrenContext = () => {
|
|
@@ -97,10 +104,11 @@ $: childrenContext = () => {
|
|
|
97
104
|
return {
|
|
98
105
|
apiKey: context.apiKey,
|
|
99
106
|
apiVersion: context.apiVersion,
|
|
100
|
-
|
|
107
|
+
localState: context.localState,
|
|
108
|
+
rootState: context.rootState,
|
|
109
|
+
rootSetState: context.rootSetState,
|
|
101
110
|
content: context.content,
|
|
102
111
|
context: context.context,
|
|
103
|
-
setState: context.setState,
|
|
104
112
|
registeredComponents: context.registeredComponents,
|
|
105
113
|
inheritedStyles: getInheritedTextStyles(),
|
|
106
114
|
};
|
|
@@ -131,12 +139,7 @@ let component = getComponent({
|
|
|
131
139
|
block: block,
|
|
132
140
|
context: context,
|
|
133
141
|
});
|
|
134
|
-
let repeatItemData = getRepeatItemData({
|
|
135
|
-
block: block,
|
|
136
|
-
context: context,
|
|
137
|
-
});
|
|
138
142
|
let tag = block.tagName || "div";
|
|
139
|
-
let proxyState = getProxyState(context);
|
|
140
143
|
</script>
|
|
141
144
|
|
|
142
145
|
{#if canShowBlock()}
|
|
@@ -145,13 +148,13 @@ let proxyState = getProxyState(context);
|
|
|
145
148
|
<svelte:element this={tag} {...attributes()} use:setAttrs={actions()} />
|
|
146
149
|
{/if}
|
|
147
150
|
|
|
148
|
-
{#if !isEmptyHtmlElement(tag) &&
|
|
149
|
-
{#each
|
|
151
|
+
{#if !isEmptyHtmlElement(tag) && repeatItem()}
|
|
152
|
+
{#each repeatItem() as data, index (index)}
|
|
150
153
|
<RenderRepeatedBlock repeatContext={data.context} block={data.block} />
|
|
151
154
|
{/each}
|
|
152
155
|
{/if}
|
|
153
156
|
|
|
154
|
-
{#if !isEmptyHtmlElement(tag) && !
|
|
157
|
+
{#if !isEmptyHtmlElement(tag) && !repeatItem()}
|
|
155
158
|
<svelte:element this={tag} {...attributes()} use:setAttrs={actions()}>
|
|
156
159
|
<RenderComponent {...renderComponentProps()} />
|
|
157
160
|
|
|
@@ -3,8 +3,8 @@ export type RenderBlockProps = {
|
|
|
3
3
|
block: BuilderBlock;
|
|
4
4
|
context: BuilderContextInterface;
|
|
5
5
|
};
|
|
6
|
-
import { BuilderContextInterface } from "../../context/types.js";
|
|
7
|
-
import { BuilderBlock } from "../../types/builder-block.js";
|
|
6
|
+
import type { BuilderContextInterface } from "../../context/types.js";
|
|
7
|
+
import type { BuilderBlock } from "../../types/builder-block.js";
|
|
8
8
|
declare const __propDef: {
|
|
9
9
|
props: {
|
|
10
10
|
block: RenderBlockProps["block"];
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
<script context="module"></script>
|
|
2
2
|
|
|
3
|
-
<script>import "
|
|
4
|
-
import BlockStyles from "./block-styles.svelte";
|
|
3
|
+
<script>import BlockStyles from "./block-styles.svelte";
|
|
5
4
|
import RenderBlock from "./render-block.svelte";
|
|
6
|
-
import "../../context/types.js";
|
|
7
5
|
export let componentRef;
|
|
8
6
|
export let componentOptions;
|
|
9
7
|
export let blockChildren;
|
|
@@ -11,8 +11,8 @@ export interface RenderComponentProps {
|
|
|
11
11
|
blockChildren: BuilderBlock[];
|
|
12
12
|
context: BuilderContextInterface;
|
|
13
13
|
}
|
|
14
|
-
import { BuilderBlock } from "../../types/builder-block.js";
|
|
15
|
-
import { BuilderContextInterface } from "../../context/types.js";
|
|
14
|
+
import type { BuilderBlock } from "../../types/builder-block.js";
|
|
15
|
+
import type { BuilderContextInterface } from "../../context/types.js";
|
|
16
16
|
declare const __propDef: {
|
|
17
17
|
props: {
|
|
18
18
|
componentRef: RenderComponentProps["componentRef"];
|
|
@@ -11,19 +11,19 @@
|
|
|
11
11
|
|
|
12
12
|
<script>import { setContext } from "svelte";
|
|
13
13
|
import BuilderContext from "../../context/builder.context.js";
|
|
14
|
-
import "../../context/types.js";
|
|
15
|
-
import "../../types/builder-block";
|
|
16
14
|
import RenderBlock from "./render-block.svelte";
|
|
17
15
|
export let block;
|
|
18
16
|
export let repeatContext;
|
|
19
17
|
setContext(BuilderContext.key, {
|
|
20
18
|
content: repeatContext.content,
|
|
21
|
-
|
|
22
|
-
|
|
19
|
+
localState: repeatContext.localState,
|
|
20
|
+
rootState: repeatContext.rootState,
|
|
21
|
+
rootSetState: repeatContext.rootSetState,
|
|
23
22
|
context: repeatContext.context,
|
|
24
23
|
apiKey: repeatContext.apiKey,
|
|
25
24
|
registeredComponents: repeatContext.registeredComponents,
|
|
26
25
|
inheritedStyles: repeatContext.inheritedStyles,
|
|
26
|
+
apiVersion: repeatContext.apiVersion,
|
|
27
27
|
});
|
|
28
28
|
</script>
|
|
29
29
|
|
|
@@ -3,8 +3,8 @@ type Props = {
|
|
|
3
3
|
block: BuilderBlock;
|
|
4
4
|
repeatContext: BuilderContextInterface;
|
|
5
5
|
};
|
|
6
|
-
import { BuilderContextInterface } from "../../context/types.js";
|
|
7
|
-
import { BuilderBlock } from "../../types/builder-block";
|
|
6
|
+
import type { BuilderContextInterface } from "../../context/types.js";
|
|
7
|
+
import type { BuilderBlock } from "../../types/builder-block";
|
|
8
8
|
declare const __propDef: {
|
|
9
9
|
props: {
|
|
10
10
|
block: Props["block"];
|
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
<script>import { getContext } from "svelte";
|
|
4
4
|
import BuilderContext from "../context/builder.context.js";
|
|
5
5
|
import { isEditing } from "../functions/is-editing.js";
|
|
6
|
-
import "../types/builder-block.js";
|
|
7
6
|
import BlockStyles from "./render-block/block-styles.svelte";
|
|
8
7
|
import RenderBlock from "./render-block/render-block.svelte";
|
|
9
8
|
export let blocks;
|
|
@@ -5,7 +5,7 @@ export type RenderBlockProps = {
|
|
|
5
5
|
path?: string;
|
|
6
6
|
styleProp?: Record<string, any>;
|
|
7
7
|
};
|
|
8
|
-
import { BuilderBlock } from "../types/builder-block.js";
|
|
8
|
+
import type { BuilderBlock } from "../types/builder-block.js";
|
|
9
9
|
declare const __propDef: {
|
|
10
10
|
props: {
|
|
11
11
|
blocks: RenderBlockProps["blocks"];
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
<script context="module"></script>
|
|
2
2
|
|
|
3
3
|
<script>import RenderInlinedStyles from "../../render-inlined-styles.svelte";
|
|
4
|
-
import "./render-styles.helpers";
|
|
5
4
|
import { getCss } from "./render-styles.helpers";
|
|
6
5
|
import { getFontCss } from "./render-styles.helpers";
|
|
7
6
|
export let cssCode;
|
|
@@ -17,16 +16,16 @@ ${getFontCss({
|
|
|
17
16
|
})}
|
|
18
17
|
|
|
19
18
|
.builder-text > p:first-of-type, .builder-text > .builder-paragraph:first-of-type {
|
|
20
|
-
margin: 0;
|
|
19
|
+
margin: 0;
|
|
21
20
|
}
|
|
22
21
|
.builder-text > p, .builder-text > .builder-paragraph {
|
|
23
|
-
color: inherit;
|
|
24
|
-
line-height: inherit;
|
|
25
|
-
letter-spacing: inherit;
|
|
26
|
-
font-weight: inherit;
|
|
27
|
-
font-size: inherit;
|
|
28
|
-
text-align: inherit;
|
|
29
|
-
font-family: inherit;
|
|
22
|
+
color: inherit;
|
|
23
|
+
line-height: inherit;
|
|
24
|
+
letter-spacing: inherit;
|
|
25
|
+
font-weight: inherit;
|
|
26
|
+
font-size: inherit;
|
|
27
|
+
text-align: inherit;
|
|
28
|
+
font-family: inherit;
|
|
30
29
|
}
|
|
31
30
|
`;
|
|
32
31
|
</script>
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
<script>import { onDestroy, onMount, setContext } from "svelte";
|
|
2
2
|
import { getDefaultRegisteredComponents } from "../../constants/builder-registered-components.js";
|
|
3
|
-
import "../../context/types.js";
|
|
4
3
|
import { evaluate } from "../../functions/evaluate.js";
|
|
5
4
|
import { getContent } from "../../functions/get-content/index.js";
|
|
6
5
|
import { fetch } from "../../functions/get-fetch.js";
|
|
@@ -9,15 +8,12 @@ import { isEditing } from "../../functions/is-editing.js";
|
|
|
9
8
|
import { isPreviewing } from "../../functions/is-previewing.js";
|
|
10
9
|
import { components, createRegisterComponentMessage, } from "../../functions/register-component.js";
|
|
11
10
|
import { _track } from "../../functions/track/index.js";
|
|
12
|
-
import "../../types/builder-content.js";
|
|
13
|
-
import "../../types/typescript.js";
|
|
14
11
|
import RenderBlocks from "../render-blocks.svelte";
|
|
15
12
|
import RenderContentStyles from "./components/render-styles.svelte";
|
|
16
13
|
import builderContext from "../../context/builder.context.js";
|
|
17
14
|
import { registerInsertMenu, setupBrowserForEditing, } from "../../scripts/init-editing.js";
|
|
18
15
|
import { checkIsDefined } from "../../helpers/nullable.js";
|
|
19
16
|
import { getInteractionPropertiesForEvent } from "../../functions/track/interaction.js";
|
|
20
|
-
import "./render-content.types.js";
|
|
21
17
|
import { getContentInitialValue, getContextStateInitialValue, } from "./render-content.helpers.js";
|
|
22
18
|
import { TARGET } from "../../constants/target.js";
|
|
23
19
|
import { logger } from "../../helpers/logger.js";
|
|
@@ -55,8 +51,8 @@ function setBreakpoints(breakpoints) {
|
|
|
55
51
|
},
|
|
56
52
|
};
|
|
57
53
|
}
|
|
58
|
-
function
|
|
59
|
-
contentState =
|
|
54
|
+
function contentSetState(newRootState) {
|
|
55
|
+
contentState = newRootState;
|
|
60
56
|
}
|
|
61
57
|
function processMessage(event) {
|
|
62
58
|
const { data } = event;
|
|
@@ -101,7 +97,9 @@ function evaluateJsCode() {
|
|
|
101
97
|
evaluate({
|
|
102
98
|
code: jsCode,
|
|
103
99
|
context: context || {},
|
|
104
|
-
|
|
100
|
+
localState: undefined,
|
|
101
|
+
rootState: contentState,
|
|
102
|
+
rootSetState: contentSetState,
|
|
105
103
|
});
|
|
106
104
|
}
|
|
107
105
|
}
|
|
@@ -127,7 +125,9 @@ function evalExpression(expression) {
|
|
|
127
125
|
return expression.replace(/{{([^}]+)}}/g, (_match, group) => evaluate({
|
|
128
126
|
code: group,
|
|
129
127
|
context: context || {},
|
|
130
|
-
|
|
128
|
+
localState: undefined,
|
|
129
|
+
rootState: contentState,
|
|
130
|
+
rootSetState: contentSetState,
|
|
131
131
|
}));
|
|
132
132
|
}
|
|
133
133
|
function handleRequest({ url, key }) {
|
|
@@ -138,7 +138,7 @@ function handleRequest({ url, key }) {
|
|
|
138
138
|
...contentState,
|
|
139
139
|
[key]: json,
|
|
140
140
|
};
|
|
141
|
-
|
|
141
|
+
contentSetState(newState);
|
|
142
142
|
})
|
|
143
143
|
.catch((err) => {
|
|
144
144
|
console.error("error fetching dynamic data", url, err);
|
|
@@ -291,11 +291,14 @@ setContext(builderContext.key, {
|
|
|
291
291
|
get content() {
|
|
292
292
|
return useContent;
|
|
293
293
|
},
|
|
294
|
-
get
|
|
294
|
+
get localState() {
|
|
295
|
+
return undefined;
|
|
296
|
+
},
|
|
297
|
+
get rootState() {
|
|
295
298
|
return contentState;
|
|
296
299
|
},
|
|
297
|
-
get
|
|
298
|
-
return
|
|
300
|
+
get rootSetState() {
|
|
301
|
+
return TARGET === "qwik" ? undefined : contentSetState;
|
|
299
302
|
},
|
|
300
303
|
get context() {
|
|
301
304
|
return context || {};
|
|
@@ -309,6 +312,9 @@ setContext(builderContext.key, {
|
|
|
309
312
|
get registeredComponents() {
|
|
310
313
|
return allRegisteredComponents;
|
|
311
314
|
},
|
|
315
|
+
get inheritedStyles() {
|
|
316
|
+
return {};
|
|
317
|
+
},
|
|
312
318
|
});
|
|
313
319
|
onDestroy(() => {
|
|
314
320
|
if (isBrowser()) {
|
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
<script>import { TARGET } from "../constants/target.js";
|
|
4
4
|
export let styles;
|
|
5
5
|
$: tag = () => {
|
|
6
|
-
// NOTE: we have to
|
|
6
|
+
// NOTE: we have to obfuscate the name of the tag due to a limitation in the svelte-preprocessor plugin.
|
|
7
7
|
// https://github.com/sveltejs/vite-plugin-svelte/issues/315#issuecomment-1109000027
|
|
8
|
-
return "sty" + "le";
|
|
8
|
+
return ("sty" + "le");
|
|
9
9
|
};
|
|
10
10
|
$: injectedStyleScript = () => {
|
|
11
11
|
return `<${tag()}>${styles}</${tag()}>`;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const SDK_VERSION = "0.3.1";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const SDK_VERSION = "0.3.1";
|