@builder.io/sdk-svelte 1.0.31 → 1.0.33
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/image/component-info.js +5 -0
- package/lib/browser/blocks/image/image.svelte +3 -1
- package/lib/browser/blocks/image/image.svelte.d.ts +1 -0
- package/lib/browser/blocks/image/image.types.d.ts +1 -0
- package/lib/browser/components/block/block.helpers.d.ts +22 -2
- package/lib/browser/components/block/block.helpers.js +22 -4
- package/lib/browser/components/block/block.svelte +6 -17
- package/lib/browser/components/block/components/block-wrapper.svelte.d.ts +0 -1
- package/lib/browser/components/content/components/enable-editor.svelte.d.ts +1 -1
- package/lib/browser/components/content/content.svelte +1 -2
- package/lib/browser/components/content/content.svelte.d.ts +1 -1
- package/lib/browser/constants/sdk-version.d.ts +1 -1
- package/lib/browser/constants/sdk-version.js +1 -1
- package/lib/browser/functions/evaluate/edge-runtime/edge-runtime.js +4 -12
- package/lib/browser/functions/get-block-component-options.js +1 -5
- package/lib/browser/functions/is-from-trusted-host.js +3 -0
- package/lib/edge/blocks/image/component-info.js +5 -0
- package/lib/edge/blocks/image/image.svelte +3 -1
- package/lib/edge/blocks/image/image.svelte.d.ts +1 -0
- package/lib/edge/blocks/image/image.types.d.ts +1 -0
- package/lib/edge/components/block/block.helpers.d.ts +22 -2
- package/lib/edge/components/block/block.helpers.js +22 -4
- package/lib/edge/components/block/block.svelte +6 -17
- package/lib/edge/components/block/components/block-wrapper.svelte.d.ts +0 -1
- package/lib/edge/components/content/components/enable-editor.svelte.d.ts +1 -1
- package/lib/edge/components/content/content.svelte +1 -2
- package/lib/edge/components/content/content.svelte.d.ts +1 -1
- package/lib/edge/constants/sdk-version.d.ts +1 -1
- package/lib/edge/constants/sdk-version.js +1 -1
- package/lib/edge/functions/evaluate/edge-runtime/edge-runtime.js +4 -12
- package/lib/edge/functions/get-block-component-options.js +1 -5
- package/lib/edge/functions/is-from-trusted-host.js +3 -0
- package/lib/node/blocks/image/component-info.js +5 -0
- package/lib/node/blocks/image/image.svelte +3 -1
- package/lib/node/blocks/image/image.svelte.d.ts +1 -0
- package/lib/node/blocks/image/image.types.d.ts +1 -0
- package/lib/node/components/block/block.helpers.d.ts +22 -2
- package/lib/node/components/block/block.helpers.js +22 -4
- package/lib/node/components/block/block.svelte +6 -17
- package/lib/node/components/block/components/block-wrapper.svelte.d.ts +0 -1
- package/lib/node/components/content/components/enable-editor.svelte.d.ts +1 -1
- package/lib/node/components/content/content.svelte +1 -2
- package/lib/node/components/content/content.svelte.d.ts +1 -1
- package/lib/node/constants/sdk-version.d.ts +1 -1
- package/lib/node/constants/sdk-version.js +1 -1
- package/lib/node/functions/evaluate/edge-runtime/edge-runtime.js +4 -12
- package/lib/node/functions/get-block-component-options.js +1 -5
- package/lib/node/functions/is-from-trusted-host.js +3 -0
- package/package.json +1 -1
- package/src/blocks/image/component-info.ts +5 -0
- package/src/blocks/image/image.svelte +3 -1
- package/src/blocks/image/image.types.ts +1 -0
- package/src/components/block/block.helpers.ts +23 -4
- package/src/components/block/block.svelte +9 -18
- package/src/components/block/components/block-wrapper.svelte +0 -1
- package/src/components/content/components/enable-editor.svelte +1 -0
- package/src/components/content/content.svelte +1 -2
- package/src/constants/sdk-version.ts +1 -1
- package/src/functions/evaluate/edge-runtime/edge-runtime.ts +4 -11
- package/src/functions/get-block-component-options.ts +1 -5
- package/src/functions/is-from-trusted-host.ts +3 -0
|
@@ -112,6 +112,11 @@ export const componentInfo = {
|
|
|
112
112
|
type: 'boolean',
|
|
113
113
|
helperText: "When child blocks are provided, fit to them instead of using the image's aspect ratio",
|
|
114
114
|
defaultValue: true
|
|
115
|
+
}, {
|
|
116
|
+
name: 'highPriority',
|
|
117
|
+
type: 'boolean',
|
|
118
|
+
advanced: true,
|
|
119
|
+
helperText: 'Mark this image as high priority compared to other images on the page. This prevents lazy loading of the image and tells the browser to load this image before others on the page.'
|
|
115
120
|
}, {
|
|
116
121
|
name: 'aspectRatio',
|
|
117
122
|
type: 'number',
|
|
@@ -4,6 +4,7 @@ export let src = undefined;
|
|
|
4
4
|
export let srcset = undefined;
|
|
5
5
|
export let noWebp = undefined;
|
|
6
6
|
export let aspectRatio = undefined;
|
|
7
|
+
export let highPriority = undefined;
|
|
7
8
|
export let altText = undefined;
|
|
8
9
|
export let backgroundPosition = undefined;
|
|
9
10
|
export let backgroundSize = undefined;
|
|
@@ -71,7 +72,8 @@ $: aspectRatioCss = () => {
|
|
|
71
72
|
objectFit: backgroundSize || "cover",
|
|
72
73
|
...aspectRatioCss(),
|
|
73
74
|
})}
|
|
74
|
-
loading="lazy"
|
|
75
|
+
loading={highPriority ? "eager" : "lazy"}
|
|
76
|
+
fetchpriority={highPriority ? "high" : "auto"}
|
|
75
77
|
alt={altText}
|
|
76
78
|
role={altText ? undefined : "presentation"}
|
|
77
79
|
class={"builder-image" + (className ? " " + className : "") + " img"}
|
|
@@ -7,6 +7,7 @@ declare const __propDef: {
|
|
|
7
7
|
srcset?: ImageProps["srcset"];
|
|
8
8
|
noWebp?: ImageProps["noWebp"];
|
|
9
9
|
aspectRatio?: ImageProps["aspectRatio"];
|
|
10
|
+
highPriority?: ImageProps["highPriority"];
|
|
10
11
|
altText?: ImageProps["altText"];
|
|
11
12
|
backgroundPosition?: ImageProps["backgroundPosition"];
|
|
12
13
|
backgroundSize?: ImageProps["backgroundSize"];
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
/// <reference types="svelte" />
|
|
2
|
+
import type { Writable } from "svelte/store";
|
|
1
3
|
import type { BuilderContextInterface, RegisteredComponent, RegisteredComponents } from '../../context/types';
|
|
2
4
|
import type { BuilderBlock } from '../../types/builder-block';
|
|
3
5
|
import type { RepeatData } from './types';
|
|
@@ -14,5 +16,23 @@ export declare const getInheritedStyles: ({ block, context }: {
|
|
|
14
16
|
block: BuilderBlock;
|
|
15
17
|
context: BuilderContextInterface;
|
|
16
18
|
}) => Partial<CSSStyleDeclaration>;
|
|
17
|
-
export declare const
|
|
18
|
-
|
|
19
|
+
export declare const provideLinkComponent: (block: RegisteredComponent | null | undefined, linkComponent: any) => {
|
|
20
|
+
builderLinkComponent: any;
|
|
21
|
+
} | {
|
|
22
|
+
builderLinkComponent?: undefined;
|
|
23
|
+
};
|
|
24
|
+
export declare const provideRegisteredComponents: (block: RegisteredComponent | null | undefined, registeredComponents: RegisteredComponents) => {
|
|
25
|
+
builderComponents: RegisteredComponents;
|
|
26
|
+
} | {
|
|
27
|
+
builderComponents?: undefined;
|
|
28
|
+
};
|
|
29
|
+
export declare const provideBuilderBlock: (block: RegisteredComponent | null | undefined, builderBlock: BuilderBlock) => {
|
|
30
|
+
builderBlock: BuilderBlock;
|
|
31
|
+
} | {
|
|
32
|
+
builderBlock?: undefined;
|
|
33
|
+
};
|
|
34
|
+
export declare const provideBuilderContext: (block: RegisteredComponent | null | undefined, context: Writable<BuilderContextInterface>) => {
|
|
35
|
+
builderContext: Writable<BuilderContextInterface>;
|
|
36
|
+
} | {
|
|
37
|
+
builderContext?: undefined;
|
|
38
|
+
};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { TARGET } from '../../constants/target';
|
|
1
2
|
import { evaluate } from '../../functions/evaluate/index';
|
|
2
3
|
import { extractTextStyles } from '../../functions/extract-text-styles';
|
|
3
4
|
import { getProcessedBlock } from '../../functions/get-processed-block';
|
|
@@ -73,9 +74,26 @@ export const getInheritedStyles = ({ block, context }) => {
|
|
|
73
74
|
}
|
|
74
75
|
return extractTextStyles(style);
|
|
75
76
|
};
|
|
76
|
-
export const
|
|
77
|
-
return block && (block.isRSC || ['Core:Button', 'Symbol', 'Columns', 'Form:Form', 'Builder: Tabs', 'Builder:Accordion'].includes(block.name))
|
|
77
|
+
export const provideLinkComponent = (block, linkComponent) => {
|
|
78
|
+
return block && (block.isRSC && TARGET === 'rsc' || ['Core:Button', 'Symbol', 'Columns', 'Form:Form', 'Builder: Tabs', 'Builder:Accordion'].includes(block.name)) ? {
|
|
79
|
+
builderLinkComponent: linkComponent
|
|
80
|
+
} : {};
|
|
78
81
|
};
|
|
79
|
-
export const
|
|
80
|
-
return block && (block.isRSC || ['Symbol', 'Columns', 'Form:Form', 'Builder: Tabs', 'Builder:Accordion'].includes(block.name))
|
|
82
|
+
export const provideRegisteredComponents = (block, registeredComponents) => {
|
|
83
|
+
return block && (block.isRSC && TARGET === 'rsc' || ['Symbol', 'Columns', 'Form:Form', 'Builder: Tabs', 'Builder:Accordion'].includes(block.name)) ? {
|
|
84
|
+
builderComponents: registeredComponents
|
|
85
|
+
} : {};
|
|
86
|
+
};
|
|
87
|
+
export const provideBuilderBlock = (block, builderBlock) => {
|
|
88
|
+
/**
|
|
89
|
+
* Our built-in components frequently make use of the block, so we provide all of it under `builderBlock`
|
|
90
|
+
*/
|
|
91
|
+
return block && (block.isRSC && TARGET === 'rsc' || TARGET === 'reactNative' && block.name === 'Text' || ['Builder:Accordion', 'Columns', 'Form:Form', 'Builder: Tabs', 'Symbol', 'Image', 'Video'].includes(block.name)) ? {
|
|
92
|
+
builderBlock
|
|
93
|
+
} : {};
|
|
94
|
+
};
|
|
95
|
+
export const provideBuilderContext = (block, context) => {
|
|
96
|
+
return block && (block.isRSC && TARGET === 'rsc' || ['Builder:Accordion', 'Columns', 'Form:Form', 'Builder: Tabs', 'Symbol', 'Slot'].includes(block.name)) ? {
|
|
97
|
+
builderContext: context
|
|
98
|
+
} : {};
|
|
81
99
|
};
|
|
@@ -5,7 +5,7 @@ import { getBlockComponentOptions } from "../../functions/get-block-component-op
|
|
|
5
5
|
import { getProcessedBlock } from "../../functions/get-processed-block";
|
|
6
6
|
import "../dynamic-div.svelte";
|
|
7
7
|
import { bindAnimations } from "./animator";
|
|
8
|
-
import { getComponent, getRepeatItemData,
|
|
8
|
+
import { getComponent, getRepeatItemData, provideBuilderBlock, provideBuilderContext, provideLinkComponent, provideRegisteredComponents, } from "./block.helpers";
|
|
9
9
|
import BlockStyles from "./components/block-styles.svelte";
|
|
10
10
|
import BlockWrapper from "./components/block-wrapper.svelte";
|
|
11
11
|
import ComponentRef from "./components/component-ref/component-ref.svelte";
|
|
@@ -76,17 +76,10 @@ $: componentRefProps = () => {
|
|
|
76
76
|
componentRef: blockComponent?.()?.component,
|
|
77
77
|
componentOptions: {
|
|
78
78
|
...getBlockComponentOptions(processedBlock()),
|
|
79
|
-
|
|
80
|
-
...(
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
}
|
|
84
|
-
: {}),
|
|
85
|
-
...(shouldPassRegisteredComponents(blockComponent())
|
|
86
|
-
? {
|
|
87
|
-
builderComponents: registeredComponents,
|
|
88
|
-
}
|
|
89
|
-
: {}),
|
|
79
|
+
...provideBuilderBlock(blockComponent(), processedBlock()),
|
|
80
|
+
...provideBuilderContext(blockComponent(), context),
|
|
81
|
+
...provideLinkComponent(blockComponent(), linkComponent),
|
|
82
|
+
...provideRegisteredComponents(blockComponent(), registeredComponents),
|
|
90
83
|
},
|
|
91
84
|
context: context,
|
|
92
85
|
linkComponent: linkComponent,
|
|
@@ -113,11 +106,7 @@ onMount(() => {
|
|
|
113
106
|
|
|
114
107
|
{#if !blockComponent?.()?.noWrap}
|
|
115
108
|
{#if !repeatItem()}
|
|
116
|
-
<BlockWrapper
|
|
117
|
-
Wrapper={Tag()}
|
|
118
|
-
block={processedBlock()}
|
|
119
|
-
{context}
|
|
120
|
-
{linkComponent}
|
|
109
|
+
<BlockWrapper Wrapper={Tag()} block={processedBlock()} {context}
|
|
121
110
|
><ComponentRef
|
|
122
111
|
componentRef={componentRefProps().componentRef}
|
|
123
112
|
componentOptions={componentRefProps().componentOptions}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { SvelteComponent } from "svelte";
|
|
2
|
-
type BuilderEditorProps = Omit<ContentProps, "customComponents" | "apiVersion" | "isSsrAbTest" | "blocksWrapper" | "blocksWrapperProps" | "isNestedRender"> & {
|
|
2
|
+
type BuilderEditorProps = Omit<ContentProps, "customComponents" | "apiVersion" | "isSsrAbTest" | "blocksWrapper" | "blocksWrapperProps" | "isNestedRender" | "linkComponent"> & {
|
|
3
3
|
builderContextSignal: Writable<BuilderContextInterface>;
|
|
4
4
|
setBuilderContextSignal?: (signal: any) => any;
|
|
5
5
|
children?: any;
|
|
@@ -27,10 +27,10 @@ export let enrich = undefined;
|
|
|
27
27
|
export let showContent;
|
|
28
28
|
export let contentWrapper = undefined;
|
|
29
29
|
export let contentWrapperProps = undefined;
|
|
30
|
-
export let linkComponent = undefined;
|
|
31
30
|
export let trustedHosts = undefined;
|
|
32
31
|
export let isSsrAbTest;
|
|
33
32
|
export let isNestedRender = undefined;
|
|
33
|
+
export let linkComponent = undefined;
|
|
34
34
|
function contentSetState(newRootState) {
|
|
35
35
|
$builderContextSignal.rootState = newRootState;
|
|
36
36
|
}
|
|
@@ -95,7 +95,6 @@ setContext(ComponentsContext.key, {
|
|
|
95
95
|
{builderContextSignal}
|
|
96
96
|
{contentWrapper}
|
|
97
97
|
{contentWrapperProps}
|
|
98
|
-
{linkComponent}
|
|
99
98
|
{trustedHosts}
|
|
100
99
|
{...{}}
|
|
101
100
|
>
|
|
@@ -17,10 +17,10 @@ declare const __propDef: {
|
|
|
17
17
|
showContent: ContentProps["showContent"];
|
|
18
18
|
contentWrapper?: ContentProps["contentWrapper"];
|
|
19
19
|
contentWrapperProps?: ContentProps["contentWrapperProps"];
|
|
20
|
-
linkComponent?: ContentProps["linkComponent"];
|
|
21
20
|
trustedHosts?: ContentProps["trustedHosts"];
|
|
22
21
|
isSsrAbTest: ContentProps["isSsrAbTest"];
|
|
23
22
|
isNestedRender?: ContentProps["isNestedRender"];
|
|
23
|
+
linkComponent?: ContentProps["linkComponent"];
|
|
24
24
|
};
|
|
25
25
|
events: {
|
|
26
26
|
[evt: string]: CustomEvent<any>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const SDK_VERSION = "1.0.
|
|
1
|
+
export declare const SDK_VERSION = "1.0.33";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export const SDK_VERSION = "1.0.
|
|
1
|
+
export const SDK_VERSION = "1.0.33";
|
|
@@ -71,16 +71,8 @@ theFunction();
|
|
|
71
71
|
*/
|
|
72
72
|
interpreter.setProperty(globalObject, 'setRootState', interpreter.createNativeFunction(setRootState));
|
|
73
73
|
};
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
return output;
|
|
79
|
-
}
|
|
80
|
-
catch (e) {
|
|
81
|
-
logger.warn('Custom code error in edge runtime. NOTE: your code must be ES5 JavaScript.', {
|
|
82
|
-
e
|
|
83
|
-
});
|
|
84
|
-
return;
|
|
85
|
-
}
|
|
74
|
+
const myInterpreter = new Interpreter(transformed, initFunc);
|
|
75
|
+
myInterpreter.run();
|
|
76
|
+
const output = myInterpreter.pseudoToNative(myInterpreter.value);
|
|
77
|
+
return output;
|
|
86
78
|
};
|
|
@@ -1,10 +1,6 @@
|
|
|
1
1
|
export function getBlockComponentOptions(block) {
|
|
2
2
|
return {
|
|
3
3
|
...block.component?.options,
|
|
4
|
-
...block.options
|
|
5
|
-
/**
|
|
6
|
-
* Our built-in components frequently make use of the block, so we provide all of it under `builderBlock`
|
|
7
|
-
*/
|
|
8
|
-
builderBlock: block
|
|
4
|
+
...block.options
|
|
9
5
|
};
|
|
10
6
|
}
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
const DEFAULT_TRUSTED_HOSTS = ['*.beta.builder.io', 'beta.builder.io', 'builder.io', 'localhost', 'qa.builder.io'];
|
|
2
2
|
export function isFromTrustedHost(trustedHosts, e) {
|
|
3
|
+
if (!e.origin.startsWith('http') && !e.origin.startsWith('https')) {
|
|
4
|
+
return false;
|
|
5
|
+
}
|
|
3
6
|
const url = new URL(e.origin), hostname = url.hostname;
|
|
4
7
|
return (trustedHosts || DEFAULT_TRUSTED_HOSTS).findIndex(trustedHost => trustedHost.startsWith('*.') ? hostname.endsWith(trustedHost.slice(1)) : trustedHost === hostname) > -1;
|
|
5
8
|
}
|
|
@@ -112,6 +112,11 @@ export const componentInfo = {
|
|
|
112
112
|
type: 'boolean',
|
|
113
113
|
helperText: "When child blocks are provided, fit to them instead of using the image's aspect ratio",
|
|
114
114
|
defaultValue: true
|
|
115
|
+
}, {
|
|
116
|
+
name: 'highPriority',
|
|
117
|
+
type: 'boolean',
|
|
118
|
+
advanced: true,
|
|
119
|
+
helperText: 'Mark this image as high priority compared to other images on the page. This prevents lazy loading of the image and tells the browser to load this image before others on the page.'
|
|
115
120
|
}, {
|
|
116
121
|
name: 'aspectRatio',
|
|
117
122
|
type: 'number',
|
|
@@ -4,6 +4,7 @@ export let src = undefined;
|
|
|
4
4
|
export let srcset = undefined;
|
|
5
5
|
export let noWebp = undefined;
|
|
6
6
|
export let aspectRatio = undefined;
|
|
7
|
+
export let highPriority = undefined;
|
|
7
8
|
export let altText = undefined;
|
|
8
9
|
export let backgroundPosition = undefined;
|
|
9
10
|
export let backgroundSize = undefined;
|
|
@@ -71,7 +72,8 @@ $: aspectRatioCss = () => {
|
|
|
71
72
|
objectFit: backgroundSize || "cover",
|
|
72
73
|
...aspectRatioCss(),
|
|
73
74
|
})}
|
|
74
|
-
loading="lazy"
|
|
75
|
+
loading={highPriority ? "eager" : "lazy"}
|
|
76
|
+
fetchpriority={highPriority ? "high" : "auto"}
|
|
75
77
|
alt={altText}
|
|
76
78
|
role={altText ? undefined : "presentation"}
|
|
77
79
|
class={"builder-image" + (className ? " " + className : "") + " img"}
|
|
@@ -7,6 +7,7 @@ declare const __propDef: {
|
|
|
7
7
|
srcset?: ImageProps["srcset"];
|
|
8
8
|
noWebp?: ImageProps["noWebp"];
|
|
9
9
|
aspectRatio?: ImageProps["aspectRatio"];
|
|
10
|
+
highPriority?: ImageProps["highPriority"];
|
|
10
11
|
altText?: ImageProps["altText"];
|
|
11
12
|
backgroundPosition?: ImageProps["backgroundPosition"];
|
|
12
13
|
backgroundSize?: ImageProps["backgroundSize"];
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
/// <reference types="svelte" />
|
|
2
|
+
import type { Writable } from "svelte/store";
|
|
1
3
|
import type { BuilderContextInterface, RegisteredComponent, RegisteredComponents } from '../../context/types';
|
|
2
4
|
import type { BuilderBlock } from '../../types/builder-block';
|
|
3
5
|
import type { RepeatData } from './types';
|
|
@@ -14,5 +16,23 @@ export declare const getInheritedStyles: ({ block, context }: {
|
|
|
14
16
|
block: BuilderBlock;
|
|
15
17
|
context: BuilderContextInterface;
|
|
16
18
|
}) => Partial<CSSStyleDeclaration>;
|
|
17
|
-
export declare const
|
|
18
|
-
|
|
19
|
+
export declare const provideLinkComponent: (block: RegisteredComponent | null | undefined, linkComponent: any) => {
|
|
20
|
+
builderLinkComponent: any;
|
|
21
|
+
} | {
|
|
22
|
+
builderLinkComponent?: undefined;
|
|
23
|
+
};
|
|
24
|
+
export declare const provideRegisteredComponents: (block: RegisteredComponent | null | undefined, registeredComponents: RegisteredComponents) => {
|
|
25
|
+
builderComponents: RegisteredComponents;
|
|
26
|
+
} | {
|
|
27
|
+
builderComponents?: undefined;
|
|
28
|
+
};
|
|
29
|
+
export declare const provideBuilderBlock: (block: RegisteredComponent | null | undefined, builderBlock: BuilderBlock) => {
|
|
30
|
+
builderBlock: BuilderBlock;
|
|
31
|
+
} | {
|
|
32
|
+
builderBlock?: undefined;
|
|
33
|
+
};
|
|
34
|
+
export declare const provideBuilderContext: (block: RegisteredComponent | null | undefined, context: Writable<BuilderContextInterface>) => {
|
|
35
|
+
builderContext: Writable<BuilderContextInterface>;
|
|
36
|
+
} | {
|
|
37
|
+
builderContext?: undefined;
|
|
38
|
+
};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { TARGET } from '../../constants/target';
|
|
1
2
|
import { evaluate } from '../../functions/evaluate/index';
|
|
2
3
|
import { extractTextStyles } from '../../functions/extract-text-styles';
|
|
3
4
|
import { getProcessedBlock } from '../../functions/get-processed-block';
|
|
@@ -73,9 +74,26 @@ export const getInheritedStyles = ({ block, context }) => {
|
|
|
73
74
|
}
|
|
74
75
|
return extractTextStyles(style);
|
|
75
76
|
};
|
|
76
|
-
export const
|
|
77
|
-
return block && (block.isRSC || ['Core:Button', 'Symbol', 'Columns', 'Form:Form', 'Builder: Tabs', 'Builder:Accordion'].includes(block.name))
|
|
77
|
+
export const provideLinkComponent = (block, linkComponent) => {
|
|
78
|
+
return block && (block.isRSC && TARGET === 'rsc' || ['Core:Button', 'Symbol', 'Columns', 'Form:Form', 'Builder: Tabs', 'Builder:Accordion'].includes(block.name)) ? {
|
|
79
|
+
builderLinkComponent: linkComponent
|
|
80
|
+
} : {};
|
|
78
81
|
};
|
|
79
|
-
export const
|
|
80
|
-
return block && (block.isRSC || ['Symbol', 'Columns', 'Form:Form', 'Builder: Tabs', 'Builder:Accordion'].includes(block.name))
|
|
82
|
+
export const provideRegisteredComponents = (block, registeredComponents) => {
|
|
83
|
+
return block && (block.isRSC && TARGET === 'rsc' || ['Symbol', 'Columns', 'Form:Form', 'Builder: Tabs', 'Builder:Accordion'].includes(block.name)) ? {
|
|
84
|
+
builderComponents: registeredComponents
|
|
85
|
+
} : {};
|
|
86
|
+
};
|
|
87
|
+
export const provideBuilderBlock = (block, builderBlock) => {
|
|
88
|
+
/**
|
|
89
|
+
* Our built-in components frequently make use of the block, so we provide all of it under `builderBlock`
|
|
90
|
+
*/
|
|
91
|
+
return block && (block.isRSC && TARGET === 'rsc' || TARGET === 'reactNative' && block.name === 'Text' || ['Builder:Accordion', 'Columns', 'Form:Form', 'Builder: Tabs', 'Symbol', 'Image', 'Video'].includes(block.name)) ? {
|
|
92
|
+
builderBlock
|
|
93
|
+
} : {};
|
|
94
|
+
};
|
|
95
|
+
export const provideBuilderContext = (block, context) => {
|
|
96
|
+
return block && (block.isRSC && TARGET === 'rsc' || ['Builder:Accordion', 'Columns', 'Form:Form', 'Builder: Tabs', 'Symbol', 'Slot'].includes(block.name)) ? {
|
|
97
|
+
builderContext: context
|
|
98
|
+
} : {};
|
|
81
99
|
};
|
|
@@ -5,7 +5,7 @@ import { getBlockComponentOptions } from "../../functions/get-block-component-op
|
|
|
5
5
|
import { getProcessedBlock } from "../../functions/get-processed-block";
|
|
6
6
|
import "../dynamic-div.svelte";
|
|
7
7
|
import { bindAnimations } from "./animator";
|
|
8
|
-
import { getComponent, getRepeatItemData,
|
|
8
|
+
import { getComponent, getRepeatItemData, provideBuilderBlock, provideBuilderContext, provideLinkComponent, provideRegisteredComponents, } from "./block.helpers";
|
|
9
9
|
import BlockStyles from "./components/block-styles.svelte";
|
|
10
10
|
import BlockWrapper from "./components/block-wrapper.svelte";
|
|
11
11
|
import ComponentRef from "./components/component-ref/component-ref.svelte";
|
|
@@ -76,17 +76,10 @@ $: componentRefProps = () => {
|
|
|
76
76
|
componentRef: blockComponent?.()?.component,
|
|
77
77
|
componentOptions: {
|
|
78
78
|
...getBlockComponentOptions(processedBlock()),
|
|
79
|
-
|
|
80
|
-
...(
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
}
|
|
84
|
-
: {}),
|
|
85
|
-
...(shouldPassRegisteredComponents(blockComponent())
|
|
86
|
-
? {
|
|
87
|
-
builderComponents: registeredComponents,
|
|
88
|
-
}
|
|
89
|
-
: {}),
|
|
79
|
+
...provideBuilderBlock(blockComponent(), processedBlock()),
|
|
80
|
+
...provideBuilderContext(blockComponent(), context),
|
|
81
|
+
...provideLinkComponent(blockComponent(), linkComponent),
|
|
82
|
+
...provideRegisteredComponents(blockComponent(), registeredComponents),
|
|
90
83
|
},
|
|
91
84
|
context: context,
|
|
92
85
|
linkComponent: linkComponent,
|
|
@@ -113,11 +106,7 @@ onMount(() => {
|
|
|
113
106
|
|
|
114
107
|
{#if !blockComponent?.()?.noWrap}
|
|
115
108
|
{#if !repeatItem()}
|
|
116
|
-
<BlockWrapper
|
|
117
|
-
Wrapper={Tag()}
|
|
118
|
-
block={processedBlock()}
|
|
119
|
-
{context}
|
|
120
|
-
{linkComponent}
|
|
109
|
+
<BlockWrapper Wrapper={Tag()} block={processedBlock()} {context}
|
|
121
110
|
><ComponentRef
|
|
122
111
|
componentRef={componentRefProps().componentRef}
|
|
123
112
|
componentOptions={componentRefProps().componentOptions}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { SvelteComponent } from "svelte";
|
|
2
|
-
type BuilderEditorProps = Omit<ContentProps, "customComponents" | "apiVersion" | "isSsrAbTest" | "blocksWrapper" | "blocksWrapperProps" | "isNestedRender"> & {
|
|
2
|
+
type BuilderEditorProps = Omit<ContentProps, "customComponents" | "apiVersion" | "isSsrAbTest" | "blocksWrapper" | "blocksWrapperProps" | "isNestedRender" | "linkComponent"> & {
|
|
3
3
|
builderContextSignal: Writable<BuilderContextInterface>;
|
|
4
4
|
setBuilderContextSignal?: (signal: any) => any;
|
|
5
5
|
children?: any;
|
|
@@ -27,10 +27,10 @@ export let enrich = undefined;
|
|
|
27
27
|
export let showContent;
|
|
28
28
|
export let contentWrapper = undefined;
|
|
29
29
|
export let contentWrapperProps = undefined;
|
|
30
|
-
export let linkComponent = undefined;
|
|
31
30
|
export let trustedHosts = undefined;
|
|
32
31
|
export let isSsrAbTest;
|
|
33
32
|
export let isNestedRender = undefined;
|
|
33
|
+
export let linkComponent = undefined;
|
|
34
34
|
function contentSetState(newRootState) {
|
|
35
35
|
$builderContextSignal.rootState = newRootState;
|
|
36
36
|
}
|
|
@@ -95,7 +95,6 @@ setContext(ComponentsContext.key, {
|
|
|
95
95
|
{builderContextSignal}
|
|
96
96
|
{contentWrapper}
|
|
97
97
|
{contentWrapperProps}
|
|
98
|
-
{linkComponent}
|
|
99
98
|
{trustedHosts}
|
|
100
99
|
{...{}}
|
|
101
100
|
>
|
|
@@ -17,10 +17,10 @@ declare const __propDef: {
|
|
|
17
17
|
showContent: ContentProps["showContent"];
|
|
18
18
|
contentWrapper?: ContentProps["contentWrapper"];
|
|
19
19
|
contentWrapperProps?: ContentProps["contentWrapperProps"];
|
|
20
|
-
linkComponent?: ContentProps["linkComponent"];
|
|
21
20
|
trustedHosts?: ContentProps["trustedHosts"];
|
|
22
21
|
isSsrAbTest: ContentProps["isSsrAbTest"];
|
|
23
22
|
isNestedRender?: ContentProps["isNestedRender"];
|
|
23
|
+
linkComponent?: ContentProps["linkComponent"];
|
|
24
24
|
};
|
|
25
25
|
events: {
|
|
26
26
|
[evt: string]: CustomEvent<any>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const SDK_VERSION = "1.0.
|
|
1
|
+
export declare const SDK_VERSION = "1.0.33";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export const SDK_VERSION = "1.0.
|
|
1
|
+
export const SDK_VERSION = "1.0.33";
|
|
@@ -71,16 +71,8 @@ theFunction();
|
|
|
71
71
|
*/
|
|
72
72
|
interpreter.setProperty(globalObject, 'setRootState', interpreter.createNativeFunction(setRootState));
|
|
73
73
|
};
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
return output;
|
|
79
|
-
}
|
|
80
|
-
catch (e) {
|
|
81
|
-
logger.warn('Custom code error in edge runtime. NOTE: your code must be ES5 JavaScript.', {
|
|
82
|
-
e
|
|
83
|
-
});
|
|
84
|
-
return;
|
|
85
|
-
}
|
|
74
|
+
const myInterpreter = new Interpreter(transformed, initFunc);
|
|
75
|
+
myInterpreter.run();
|
|
76
|
+
const output = myInterpreter.pseudoToNative(myInterpreter.value);
|
|
77
|
+
return output;
|
|
86
78
|
};
|
|
@@ -1,10 +1,6 @@
|
|
|
1
1
|
export function getBlockComponentOptions(block) {
|
|
2
2
|
return {
|
|
3
3
|
...block.component?.options,
|
|
4
|
-
...block.options
|
|
5
|
-
/**
|
|
6
|
-
* Our built-in components frequently make use of the block, so we provide all of it under `builderBlock`
|
|
7
|
-
*/
|
|
8
|
-
builderBlock: block
|
|
4
|
+
...block.options
|
|
9
5
|
};
|
|
10
6
|
}
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
const DEFAULT_TRUSTED_HOSTS = ['*.beta.builder.io', 'beta.builder.io', 'builder.io', 'localhost', 'qa.builder.io'];
|
|
2
2
|
export function isFromTrustedHost(trustedHosts, e) {
|
|
3
|
+
if (!e.origin.startsWith('http') && !e.origin.startsWith('https')) {
|
|
4
|
+
return false;
|
|
5
|
+
}
|
|
3
6
|
const url = new URL(e.origin), hostname = url.hostname;
|
|
4
7
|
return (trustedHosts || DEFAULT_TRUSTED_HOSTS).findIndex(trustedHost => trustedHost.startsWith('*.') ? hostname.endsWith(trustedHost.slice(1)) : trustedHost === hostname) > -1;
|
|
5
8
|
}
|
|
@@ -112,6 +112,11 @@ export const componentInfo = {
|
|
|
112
112
|
type: 'boolean',
|
|
113
113
|
helperText: "When child blocks are provided, fit to them instead of using the image's aspect ratio",
|
|
114
114
|
defaultValue: true
|
|
115
|
+
}, {
|
|
116
|
+
name: 'highPriority',
|
|
117
|
+
type: 'boolean',
|
|
118
|
+
advanced: true,
|
|
119
|
+
helperText: 'Mark this image as high priority compared to other images on the page. This prevents lazy loading of the image and tells the browser to load this image before others on the page.'
|
|
115
120
|
}, {
|
|
116
121
|
name: 'aspectRatio',
|
|
117
122
|
type: 'number',
|
|
@@ -4,6 +4,7 @@ export let src = undefined;
|
|
|
4
4
|
export let srcset = undefined;
|
|
5
5
|
export let noWebp = undefined;
|
|
6
6
|
export let aspectRatio = undefined;
|
|
7
|
+
export let highPriority = undefined;
|
|
7
8
|
export let altText = undefined;
|
|
8
9
|
export let backgroundPosition = undefined;
|
|
9
10
|
export let backgroundSize = undefined;
|
|
@@ -71,7 +72,8 @@ $: aspectRatioCss = () => {
|
|
|
71
72
|
objectFit: backgroundSize || "cover",
|
|
72
73
|
...aspectRatioCss(),
|
|
73
74
|
})}
|
|
74
|
-
loading="lazy"
|
|
75
|
+
loading={highPriority ? "eager" : "lazy"}
|
|
76
|
+
fetchpriority={highPriority ? "high" : "auto"}
|
|
75
77
|
alt={altText}
|
|
76
78
|
role={altText ? undefined : "presentation"}
|
|
77
79
|
class={"builder-image" + (className ? " " + className : "") + " img"}
|
|
@@ -7,6 +7,7 @@ declare const __propDef: {
|
|
|
7
7
|
srcset?: ImageProps["srcset"];
|
|
8
8
|
noWebp?: ImageProps["noWebp"];
|
|
9
9
|
aspectRatio?: ImageProps["aspectRatio"];
|
|
10
|
+
highPriority?: ImageProps["highPriority"];
|
|
10
11
|
altText?: ImageProps["altText"];
|
|
11
12
|
backgroundPosition?: ImageProps["backgroundPosition"];
|
|
12
13
|
backgroundSize?: ImageProps["backgroundSize"];
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
/// <reference types="svelte" />
|
|
2
|
+
import type { Writable } from "svelte/store";
|
|
1
3
|
import type { BuilderContextInterface, RegisteredComponent, RegisteredComponents } from '../../context/types';
|
|
2
4
|
import type { BuilderBlock } from '../../types/builder-block';
|
|
3
5
|
import type { RepeatData } from './types';
|
|
@@ -14,5 +16,23 @@ export declare const getInheritedStyles: ({ block, context }: {
|
|
|
14
16
|
block: BuilderBlock;
|
|
15
17
|
context: BuilderContextInterface;
|
|
16
18
|
}) => Partial<CSSStyleDeclaration>;
|
|
17
|
-
export declare const
|
|
18
|
-
|
|
19
|
+
export declare const provideLinkComponent: (block: RegisteredComponent | null | undefined, linkComponent: any) => {
|
|
20
|
+
builderLinkComponent: any;
|
|
21
|
+
} | {
|
|
22
|
+
builderLinkComponent?: undefined;
|
|
23
|
+
};
|
|
24
|
+
export declare const provideRegisteredComponents: (block: RegisteredComponent | null | undefined, registeredComponents: RegisteredComponents) => {
|
|
25
|
+
builderComponents: RegisteredComponents;
|
|
26
|
+
} | {
|
|
27
|
+
builderComponents?: undefined;
|
|
28
|
+
};
|
|
29
|
+
export declare const provideBuilderBlock: (block: RegisteredComponent | null | undefined, builderBlock: BuilderBlock) => {
|
|
30
|
+
builderBlock: BuilderBlock;
|
|
31
|
+
} | {
|
|
32
|
+
builderBlock?: undefined;
|
|
33
|
+
};
|
|
34
|
+
export declare const provideBuilderContext: (block: RegisteredComponent | null | undefined, context: Writable<BuilderContextInterface>) => {
|
|
35
|
+
builderContext: Writable<BuilderContextInterface>;
|
|
36
|
+
} | {
|
|
37
|
+
builderContext?: undefined;
|
|
38
|
+
};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { TARGET } from '../../constants/target';
|
|
1
2
|
import { evaluate } from '../../functions/evaluate/index';
|
|
2
3
|
import { extractTextStyles } from '../../functions/extract-text-styles';
|
|
3
4
|
import { getProcessedBlock } from '../../functions/get-processed-block';
|
|
@@ -73,9 +74,26 @@ export const getInheritedStyles = ({ block, context }) => {
|
|
|
73
74
|
}
|
|
74
75
|
return extractTextStyles(style);
|
|
75
76
|
};
|
|
76
|
-
export const
|
|
77
|
-
return block && (block.isRSC || ['Core:Button', 'Symbol', 'Columns', 'Form:Form', 'Builder: Tabs', 'Builder:Accordion'].includes(block.name))
|
|
77
|
+
export const provideLinkComponent = (block, linkComponent) => {
|
|
78
|
+
return block && (block.isRSC && TARGET === 'rsc' || ['Core:Button', 'Symbol', 'Columns', 'Form:Form', 'Builder: Tabs', 'Builder:Accordion'].includes(block.name)) ? {
|
|
79
|
+
builderLinkComponent: linkComponent
|
|
80
|
+
} : {};
|
|
78
81
|
};
|
|
79
|
-
export const
|
|
80
|
-
return block && (block.isRSC || ['Symbol', 'Columns', 'Form:Form', 'Builder: Tabs', 'Builder:Accordion'].includes(block.name))
|
|
82
|
+
export const provideRegisteredComponents = (block, registeredComponents) => {
|
|
83
|
+
return block && (block.isRSC && TARGET === 'rsc' || ['Symbol', 'Columns', 'Form:Form', 'Builder: Tabs', 'Builder:Accordion'].includes(block.name)) ? {
|
|
84
|
+
builderComponents: registeredComponents
|
|
85
|
+
} : {};
|
|
86
|
+
};
|
|
87
|
+
export const provideBuilderBlock = (block, builderBlock) => {
|
|
88
|
+
/**
|
|
89
|
+
* Our built-in components frequently make use of the block, so we provide all of it under `builderBlock`
|
|
90
|
+
*/
|
|
91
|
+
return block && (block.isRSC && TARGET === 'rsc' || TARGET === 'reactNative' && block.name === 'Text' || ['Builder:Accordion', 'Columns', 'Form:Form', 'Builder: Tabs', 'Symbol', 'Image', 'Video'].includes(block.name)) ? {
|
|
92
|
+
builderBlock
|
|
93
|
+
} : {};
|
|
94
|
+
};
|
|
95
|
+
export const provideBuilderContext = (block, context) => {
|
|
96
|
+
return block && (block.isRSC && TARGET === 'rsc' || ['Builder:Accordion', 'Columns', 'Form:Form', 'Builder: Tabs', 'Symbol', 'Slot'].includes(block.name)) ? {
|
|
97
|
+
builderContext: context
|
|
98
|
+
} : {};
|
|
81
99
|
};
|
|
@@ -5,7 +5,7 @@ import { getBlockComponentOptions } from "../../functions/get-block-component-op
|
|
|
5
5
|
import { getProcessedBlock } from "../../functions/get-processed-block";
|
|
6
6
|
import "../dynamic-div.svelte";
|
|
7
7
|
import { bindAnimations } from "./animator";
|
|
8
|
-
import { getComponent, getRepeatItemData,
|
|
8
|
+
import { getComponent, getRepeatItemData, provideBuilderBlock, provideBuilderContext, provideLinkComponent, provideRegisteredComponents, } from "./block.helpers";
|
|
9
9
|
import BlockStyles from "./components/block-styles.svelte";
|
|
10
10
|
import BlockWrapper from "./components/block-wrapper.svelte";
|
|
11
11
|
import ComponentRef from "./components/component-ref/component-ref.svelte";
|
|
@@ -76,17 +76,10 @@ $: componentRefProps = () => {
|
|
|
76
76
|
componentRef: blockComponent?.()?.component,
|
|
77
77
|
componentOptions: {
|
|
78
78
|
...getBlockComponentOptions(processedBlock()),
|
|
79
|
-
|
|
80
|
-
...(
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
}
|
|
84
|
-
: {}),
|
|
85
|
-
...(shouldPassRegisteredComponents(blockComponent())
|
|
86
|
-
? {
|
|
87
|
-
builderComponents: registeredComponents,
|
|
88
|
-
}
|
|
89
|
-
: {}),
|
|
79
|
+
...provideBuilderBlock(blockComponent(), processedBlock()),
|
|
80
|
+
...provideBuilderContext(blockComponent(), context),
|
|
81
|
+
...provideLinkComponent(blockComponent(), linkComponent),
|
|
82
|
+
...provideRegisteredComponents(blockComponent(), registeredComponents),
|
|
90
83
|
},
|
|
91
84
|
context: context,
|
|
92
85
|
linkComponent: linkComponent,
|
|
@@ -113,11 +106,7 @@ onMount(() => {
|
|
|
113
106
|
|
|
114
107
|
{#if !blockComponent?.()?.noWrap}
|
|
115
108
|
{#if !repeatItem()}
|
|
116
|
-
<BlockWrapper
|
|
117
|
-
Wrapper={Tag()}
|
|
118
|
-
block={processedBlock()}
|
|
119
|
-
{context}
|
|
120
|
-
{linkComponent}
|
|
109
|
+
<BlockWrapper Wrapper={Tag()} block={processedBlock()} {context}
|
|
121
110
|
><ComponentRef
|
|
122
111
|
componentRef={componentRefProps().componentRef}
|
|
123
112
|
componentOptions={componentRefProps().componentOptions}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { SvelteComponent } from "svelte";
|
|
2
|
-
type BuilderEditorProps = Omit<ContentProps, "customComponents" | "apiVersion" | "isSsrAbTest" | "blocksWrapper" | "blocksWrapperProps" | "isNestedRender"> & {
|
|
2
|
+
type BuilderEditorProps = Omit<ContentProps, "customComponents" | "apiVersion" | "isSsrAbTest" | "blocksWrapper" | "blocksWrapperProps" | "isNestedRender" | "linkComponent"> & {
|
|
3
3
|
builderContextSignal: Writable<BuilderContextInterface>;
|
|
4
4
|
setBuilderContextSignal?: (signal: any) => any;
|
|
5
5
|
children?: any;
|
|
@@ -27,10 +27,10 @@ export let enrich = undefined;
|
|
|
27
27
|
export let showContent;
|
|
28
28
|
export let contentWrapper = undefined;
|
|
29
29
|
export let contentWrapperProps = undefined;
|
|
30
|
-
export let linkComponent = undefined;
|
|
31
30
|
export let trustedHosts = undefined;
|
|
32
31
|
export let isSsrAbTest;
|
|
33
32
|
export let isNestedRender = undefined;
|
|
33
|
+
export let linkComponent = undefined;
|
|
34
34
|
function contentSetState(newRootState) {
|
|
35
35
|
$builderContextSignal.rootState = newRootState;
|
|
36
36
|
}
|
|
@@ -95,7 +95,6 @@ setContext(ComponentsContext.key, {
|
|
|
95
95
|
{builderContextSignal}
|
|
96
96
|
{contentWrapper}
|
|
97
97
|
{contentWrapperProps}
|
|
98
|
-
{linkComponent}
|
|
99
98
|
{trustedHosts}
|
|
100
99
|
{...{}}
|
|
101
100
|
>
|
|
@@ -17,10 +17,10 @@ declare const __propDef: {
|
|
|
17
17
|
showContent: ContentProps["showContent"];
|
|
18
18
|
contentWrapper?: ContentProps["contentWrapper"];
|
|
19
19
|
contentWrapperProps?: ContentProps["contentWrapperProps"];
|
|
20
|
-
linkComponent?: ContentProps["linkComponent"];
|
|
21
20
|
trustedHosts?: ContentProps["trustedHosts"];
|
|
22
21
|
isSsrAbTest: ContentProps["isSsrAbTest"];
|
|
23
22
|
isNestedRender?: ContentProps["isNestedRender"];
|
|
23
|
+
linkComponent?: ContentProps["linkComponent"];
|
|
24
24
|
};
|
|
25
25
|
events: {
|
|
26
26
|
[evt: string]: CustomEvent<any>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const SDK_VERSION = "1.0.
|
|
1
|
+
export declare const SDK_VERSION = "1.0.33";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export const SDK_VERSION = "1.0.
|
|
1
|
+
export const SDK_VERSION = "1.0.33";
|
|
@@ -71,16 +71,8 @@ theFunction();
|
|
|
71
71
|
*/
|
|
72
72
|
interpreter.setProperty(globalObject, 'setRootState', interpreter.createNativeFunction(setRootState));
|
|
73
73
|
};
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
return output;
|
|
79
|
-
}
|
|
80
|
-
catch (e) {
|
|
81
|
-
logger.warn('Custom code error in edge runtime. NOTE: your code must be ES5 JavaScript.', {
|
|
82
|
-
e
|
|
83
|
-
});
|
|
84
|
-
return;
|
|
85
|
-
}
|
|
74
|
+
const myInterpreter = new Interpreter(transformed, initFunc);
|
|
75
|
+
myInterpreter.run();
|
|
76
|
+
const output = myInterpreter.pseudoToNative(myInterpreter.value);
|
|
77
|
+
return output;
|
|
86
78
|
};
|
|
@@ -1,10 +1,6 @@
|
|
|
1
1
|
export function getBlockComponentOptions(block) {
|
|
2
2
|
return {
|
|
3
3
|
...block.component?.options,
|
|
4
|
-
...block.options
|
|
5
|
-
/**
|
|
6
|
-
* Our built-in components frequently make use of the block, so we provide all of it under `builderBlock`
|
|
7
|
-
*/
|
|
8
|
-
builderBlock: block
|
|
4
|
+
...block.options
|
|
9
5
|
};
|
|
10
6
|
}
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
const DEFAULT_TRUSTED_HOSTS = ['*.beta.builder.io', 'beta.builder.io', 'builder.io', 'localhost', 'qa.builder.io'];
|
|
2
2
|
export function isFromTrustedHost(trustedHosts, e) {
|
|
3
|
+
if (!e.origin.startsWith('http') && !e.origin.startsWith('https')) {
|
|
4
|
+
return false;
|
|
5
|
+
}
|
|
3
6
|
const url = new URL(e.origin), hostname = url.hostname;
|
|
4
7
|
return (trustedHosts || DEFAULT_TRUSTED_HOSTS).findIndex(trustedHost => trustedHost.startsWith('*.') ? hostname.endsWith(trustedHost.slice(1)) : trustedHost === hostname) > -1;
|
|
5
8
|
}
|
package/package.json
CHANGED
|
@@ -114,6 +114,11 @@ export const componentInfo: ComponentInfo = {
|
|
|
114
114
|
type: 'boolean',
|
|
115
115
|
helperText: "When child blocks are provided, fit to them instead of using the image's aspect ratio",
|
|
116
116
|
defaultValue: true
|
|
117
|
+
}, {
|
|
118
|
+
name: 'highPriority',
|
|
119
|
+
type: 'boolean',
|
|
120
|
+
advanced: true,
|
|
121
|
+
helperText: 'Mark this image as high priority compared to other images on the page. This prevents lazy loading of the image and tells the browser to load this image before others on the page.'
|
|
117
122
|
}, {
|
|
118
123
|
name: 'aspectRatio',
|
|
119
124
|
type: 'number',
|
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
export let srcset: ImageProps["srcset"] = undefined;
|
|
8
8
|
export let noWebp: ImageProps["noWebp"] = undefined;
|
|
9
9
|
export let aspectRatio: ImageProps["aspectRatio"] = undefined;
|
|
10
|
+
export let highPriority: ImageProps["highPriority"] = undefined;
|
|
10
11
|
export let altText: ImageProps["altText"] = undefined;
|
|
11
12
|
export let backgroundPosition: ImageProps["backgroundPosition"] = undefined;
|
|
12
13
|
export let backgroundSize: ImageProps["backgroundSize"] = undefined;
|
|
@@ -76,7 +77,8 @@
|
|
|
76
77
|
objectFit: backgroundSize || "cover",
|
|
77
78
|
...aspectRatioCss(),
|
|
78
79
|
})}
|
|
79
|
-
loading="lazy"
|
|
80
|
+
loading={highPriority ? "eager" : "lazy"}
|
|
81
|
+
fetchpriority={highPriority ? "high" : "auto"}
|
|
80
82
|
alt={altText}
|
|
81
83
|
role={altText ? undefined : "presentation"}
|
|
82
84
|
class={"builder-image" + (className ? " " + className : "") + " img"}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import type { Writable } from "svelte/store";
|
|
2
|
+
import { TARGET } from '../../constants/target';
|
|
1
3
|
import type { BuilderContextInterface, RegisteredComponent, RegisteredComponents } from '../../context/types';
|
|
2
4
|
import { evaluate } from '../../functions/evaluate/index';
|
|
3
5
|
import { extractTextStyles } from '../../functions/extract-text-styles';
|
|
@@ -98,9 +100,26 @@ export const getInheritedStyles = ({
|
|
|
98
100
|
}
|
|
99
101
|
return extractTextStyles(style);
|
|
100
102
|
};
|
|
101
|
-
export const
|
|
102
|
-
return block && (block.isRSC || ['Core:Button', 'Symbol', 'Columns', 'Form:Form', 'Builder: Tabs', 'Builder:Accordion'].includes(block.name))
|
|
103
|
+
export const provideLinkComponent = (block: RegisteredComponent | null | undefined, linkComponent: any) => {
|
|
104
|
+
return block && (block.isRSC && TARGET === 'rsc' || ['Core:Button', 'Symbol', 'Columns', 'Form:Form', 'Builder: Tabs', 'Builder:Accordion'].includes(block.name)) ? {
|
|
105
|
+
builderLinkComponent: linkComponent
|
|
106
|
+
} : {};
|
|
103
107
|
};
|
|
104
|
-
export const
|
|
105
|
-
return block && (block.isRSC || ['Symbol', 'Columns', 'Form:Form', 'Builder: Tabs', 'Builder:Accordion'].includes(block.name))
|
|
108
|
+
export const provideRegisteredComponents = (block: RegisteredComponent | null | undefined, registeredComponents: RegisteredComponents) => {
|
|
109
|
+
return block && (block.isRSC && TARGET === 'rsc' || ['Symbol', 'Columns', 'Form:Form', 'Builder: Tabs', 'Builder:Accordion'].includes(block.name)) ? {
|
|
110
|
+
builderComponents: registeredComponents
|
|
111
|
+
} : {};
|
|
112
|
+
};
|
|
113
|
+
export const provideBuilderBlock = (block: RegisteredComponent | null | undefined, builderBlock: BuilderBlock) => {
|
|
114
|
+
/**
|
|
115
|
+
* Our built-in components frequently make use of the block, so we provide all of it under `builderBlock`
|
|
116
|
+
*/
|
|
117
|
+
return block && (block.isRSC && TARGET === 'rsc' || TARGET === 'reactNative' && block.name === 'Text' || ['Builder:Accordion', 'Columns', 'Form:Form', 'Builder: Tabs', 'Symbol', 'Image', 'Video'].includes(block.name)) ? {
|
|
118
|
+
builderBlock
|
|
119
|
+
} : {};
|
|
120
|
+
};
|
|
121
|
+
export const provideBuilderContext = (block: RegisteredComponent | null | undefined, context: Writable<BuilderContextInterface>) => {
|
|
122
|
+
return block && (block.isRSC && TARGET === 'rsc' || ['Builder:Accordion', 'Columns', 'Form:Form', 'Builder: Tabs', 'Symbol', 'Slot'].includes(block.name)) ? {
|
|
123
|
+
builderContext: context
|
|
124
|
+
} : {};
|
|
106
125
|
}
|
|
@@ -23,8 +23,10 @@
|
|
|
23
23
|
getComponent,
|
|
24
24
|
getInheritedStyles,
|
|
25
25
|
getRepeatItemData,
|
|
26
|
-
|
|
27
|
-
|
|
26
|
+
provideBuilderBlock,
|
|
27
|
+
provideBuilderContext,
|
|
28
|
+
provideLinkComponent,
|
|
29
|
+
provideRegisteredComponents,
|
|
28
30
|
} from "./block.helpers";
|
|
29
31
|
import BlockStyles from "./components/block-styles.svelte";
|
|
30
32
|
import BlockWrapper from "./components/block-wrapper.svelte";
|
|
@@ -103,17 +105,10 @@
|
|
|
103
105
|
componentRef: blockComponent?.()?.component,
|
|
104
106
|
componentOptions: {
|
|
105
107
|
...getBlockComponentOptions(processedBlock()),
|
|
106
|
-
|
|
107
|
-
...(
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
}
|
|
111
|
-
: {}),
|
|
112
|
-
...(shouldPassRegisteredComponents(blockComponent())
|
|
113
|
-
? {
|
|
114
|
-
builderComponents: registeredComponents,
|
|
115
|
-
}
|
|
116
|
-
: {}),
|
|
108
|
+
...provideBuilderBlock(blockComponent(), processedBlock()),
|
|
109
|
+
...provideBuilderContext(blockComponent(), context),
|
|
110
|
+
...provideLinkComponent(blockComponent(), linkComponent),
|
|
111
|
+
...provideRegisteredComponents(blockComponent(), registeredComponents),
|
|
117
112
|
},
|
|
118
113
|
context: context,
|
|
119
114
|
linkComponent: linkComponent,
|
|
@@ -143,11 +138,7 @@
|
|
|
143
138
|
|
|
144
139
|
{#if !blockComponent?.()?.noWrap}
|
|
145
140
|
{#if !repeatItem()}
|
|
146
|
-
<BlockWrapper
|
|
147
|
-
Wrapper={Tag()}
|
|
148
|
-
block={processedBlock()}
|
|
149
|
-
{context}
|
|
150
|
-
{linkComponent}
|
|
141
|
+
<BlockWrapper Wrapper={Tag()} block={processedBlock()} {context}
|
|
151
142
|
><ComponentRef
|
|
152
143
|
componentRef={componentRefProps().componentRef}
|
|
153
144
|
componentOptions={componentRefProps().componentOptions}
|
|
@@ -42,10 +42,10 @@
|
|
|
42
42
|
export let contentWrapper: ContentProps["contentWrapper"] = undefined;
|
|
43
43
|
export let contentWrapperProps: ContentProps["contentWrapperProps"] =
|
|
44
44
|
undefined;
|
|
45
|
-
export let linkComponent: ContentProps["linkComponent"] = undefined;
|
|
46
45
|
export let trustedHosts: ContentProps["trustedHosts"] = undefined;
|
|
47
46
|
export let isSsrAbTest: ContentProps["isSsrAbTest"];
|
|
48
47
|
export let isNestedRender: ContentProps["isNestedRender"] = undefined;
|
|
48
|
+
export let linkComponent: ContentProps["linkComponent"] = undefined;
|
|
49
49
|
|
|
50
50
|
function contentSetState(newRootState: BuilderRenderState) {
|
|
51
51
|
$builderContextSignal.rootState = newRootState;
|
|
@@ -119,7 +119,6 @@
|
|
|
119
119
|
{builderContextSignal}
|
|
120
120
|
{contentWrapper}
|
|
121
121
|
{contentWrapperProps}
|
|
122
|
-
{linkComponent}
|
|
123
122
|
{trustedHosts}
|
|
124
123
|
{...{}}
|
|
125
124
|
>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export const SDK_VERSION = "1.0.
|
|
1
|
+
export const SDK_VERSION = "1.0.33"
|
|
@@ -82,15 +82,8 @@ theFunction();
|
|
|
82
82
|
*/
|
|
83
83
|
interpreter.setProperty(globalObject, 'setRootState', interpreter.createNativeFunction(setRootState));
|
|
84
84
|
};
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
return output;
|
|
90
|
-
} catch (e) {
|
|
91
|
-
logger.warn('Custom code error in edge runtime. NOTE: your code must be ES5 JavaScript.', {
|
|
92
|
-
e
|
|
93
|
-
});
|
|
94
|
-
return;
|
|
95
|
-
}
|
|
85
|
+
const myInterpreter = new Interpreter(transformed, initFunc);
|
|
86
|
+
myInterpreter.run();
|
|
87
|
+
const output = myInterpreter.pseudoToNative(myInterpreter.value);
|
|
88
|
+
return output;
|
|
96
89
|
}
|
|
@@ -2,10 +2,6 @@ import type { BuilderBlock } from '../types/builder-block';
|
|
|
2
2
|
export function getBlockComponentOptions(block: BuilderBlock) {
|
|
3
3
|
return {
|
|
4
4
|
...block.component?.options,
|
|
5
|
-
...(block as any).options
|
|
6
|
-
/**
|
|
7
|
-
* Our built-in components frequently make use of the block, so we provide all of it under `builderBlock`
|
|
8
|
-
*/
|
|
9
|
-
builderBlock: block
|
|
5
|
+
...(block as any).options
|
|
10
6
|
};
|
|
11
7
|
}
|
|
@@ -2,6 +2,9 @@ const DEFAULT_TRUSTED_HOSTS = ['*.beta.builder.io', 'beta.builder.io', 'builder.
|
|
|
2
2
|
export function isFromTrustedHost(trustedHosts: string[] | undefined, e: {
|
|
3
3
|
origin: string;
|
|
4
4
|
}): boolean {
|
|
5
|
+
if (!e.origin.startsWith('http') && !e.origin.startsWith('https')) {
|
|
6
|
+
return false;
|
|
7
|
+
}
|
|
5
8
|
const url = new URL(e.origin),
|
|
6
9
|
hostname = url.hostname;
|
|
7
10
|
return (trustedHosts || DEFAULT_TRUSTED_HOSTS).findIndex(trustedHost => trustedHost.startsWith('*.') ? hostname.endsWith(trustedHost.slice(1)) : trustedHost === hostname) > -1;
|