@builder.io/sdk-solid 0.12.1 → 0.12.3
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/dist/index.d.ts +4 -0
- package/lib/browser/dev.js +102 -69
- package/lib/browser/dev.jsx +107 -83
- package/lib/browser/index.js +102 -69
- package/lib/browser/index.jsx +107 -83
- package/lib/edge/dev.js +102 -69
- package/lib/edge/dev.jsx +107 -83
- package/lib/edge/index.js +102 -69
- package/lib/edge/index.jsx +107 -83
- package/lib/node/dev.js +102 -69
- package/lib/node/dev.jsx +107 -83
- package/lib/node/index.js +102 -69
- package/lib/node/index.jsx +107 -83
- package/package.json +1 -1
package/lib/edge/index.jsx
CHANGED
|
@@ -8,13 +8,11 @@ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require
|
|
|
8
8
|
|
|
9
9
|
// src/blocks/button/button.tsx
|
|
10
10
|
import { Show } from "solid-js";
|
|
11
|
-
import { css } from "solid-styled-components";
|
|
12
11
|
function Button(props) {
|
|
13
12
|
return <Show
|
|
14
13
|
fallback={<button
|
|
15
|
-
class={props.attributes.class
|
|
16
|
-
|
|
17
|
-
})}
|
|
14
|
+
class={`builder-button ${props.attributes.class}`}
|
|
15
|
+
role="button"
|
|
18
16
|
{...{}}
|
|
19
17
|
{...props.attributes}
|
|
20
18
|
style={props.attributes.style}
|
|
@@ -32,7 +30,7 @@ var button_default = Button;
|
|
|
32
30
|
|
|
33
31
|
// src/blocks/columns/columns.tsx
|
|
34
32
|
import { Show as Show7, For as For4, createSignal as createSignal5 } from "solid-js";
|
|
35
|
-
import { css as
|
|
33
|
+
import { css as css2 } from "solid-styled-components";
|
|
36
34
|
|
|
37
35
|
// src/components/blocks/blocks.tsx
|
|
38
36
|
import { useContext, Show as Show6, For as For3 } from "solid-js";
|
|
@@ -3478,10 +3476,6 @@ function getProcessedBlock({
|
|
|
3478
3476
|
}
|
|
3479
3477
|
|
|
3480
3478
|
// src/components/block/block.helpers.ts
|
|
3481
|
-
var EMPTY_HTML_ELEMENTS = ["area", "base", "br", "col", "embed", "hr", "img", "input", "keygen", "link", "meta", "param", "source", "track", "wbr"];
|
|
3482
|
-
var isEmptyHtmlElement = (tagName) => {
|
|
3483
|
-
return typeof tagName === "string" && EMPTY_HTML_ELEMENTS.includes(tagName.toLowerCase());
|
|
3484
|
-
};
|
|
3485
3479
|
var getComponent = ({
|
|
3486
3480
|
block,
|
|
3487
3481
|
context,
|
|
@@ -3656,7 +3650,7 @@ function BlockStyles(props) {
|
|
|
3656
3650
|
}
|
|
3657
3651
|
return true;
|
|
3658
3652
|
}
|
|
3659
|
-
function
|
|
3653
|
+
function css4() {
|
|
3660
3654
|
const processedBlock = getProcessedBlock({
|
|
3661
3655
|
block: props.block,
|
|
3662
3656
|
localState: props.context.localState,
|
|
@@ -3699,14 +3693,10 @@ function BlockStyles(props) {
|
|
|
3699
3693
|
}) : "";
|
|
3700
3694
|
return [largeStylesClass, mediumStylesClass, smallStylesClass].join(" ");
|
|
3701
3695
|
}
|
|
3702
|
-
return <Show2 when={TARGET !== "reactNative" &&
|
|
3696
|
+
return <Show2 when={TARGET !== "reactNative" && css4() && canShowBlock()}><Inlined_styles_default styles={css4()} /></Show2>;
|
|
3703
3697
|
}
|
|
3704
3698
|
var Block_styles_default = BlockStyles;
|
|
3705
3699
|
|
|
3706
|
-
// src/components/block/components/block-wrapper.tsx
|
|
3707
|
-
import { Show as Show3 } from "solid-js";
|
|
3708
|
-
import { Dynamic } from "solid-js/web";
|
|
3709
|
-
|
|
3710
3700
|
// src/functions/event-handler-name.ts
|
|
3711
3701
|
function capitalizeFirstLetter(string) {
|
|
3712
3702
|
return string.charAt(0).toUpperCase() + string.slice(1);
|
|
@@ -3793,31 +3783,49 @@ function getStyleAttribute(style) {
|
|
|
3793
3783
|
}
|
|
3794
3784
|
}
|
|
3795
3785
|
|
|
3796
|
-
// src/components/
|
|
3797
|
-
|
|
3786
|
+
// src/components/dynamic-renderer/dynamic-renderer.tsx
|
|
3787
|
+
import { Show as Show3 } from "solid-js";
|
|
3788
|
+
import { Dynamic } from "solid-js/web";
|
|
3789
|
+
|
|
3790
|
+
// src/components/dynamic-renderer/dynamic-renderer.helpers.ts
|
|
3791
|
+
var EMPTY_HTML_ELEMENTS = /* @__PURE__ */ new Set(["area", "base", "br", "col", "embed", "hr", "img", "input", "keygen", "link", "meta", "param", "source", "track", "wbr"]);
|
|
3792
|
+
var isEmptyElement = (tagName) => {
|
|
3793
|
+
return typeof tagName === "string" && EMPTY_HTML_ELEMENTS.has(tagName.toLowerCase());
|
|
3794
|
+
};
|
|
3795
|
+
|
|
3796
|
+
// src/components/dynamic-renderer/dynamic-renderer.tsx
|
|
3797
|
+
function DynamicRenderer(props) {
|
|
3798
3798
|
return <Show3
|
|
3799
3799
|
fallback={<Dynamic
|
|
3800
|
-
{...
|
|
3801
|
-
|
|
3802
|
-
|
|
3803
|
-
})}
|
|
3804
|
-
{...getBlockActions({
|
|
3805
|
-
block: props.block,
|
|
3806
|
-
rootState: props.context.rootState,
|
|
3807
|
-
rootSetState: props.context.rootSetState,
|
|
3808
|
-
localState: props.context.localState,
|
|
3809
|
-
context: props.context.context,
|
|
3810
|
-
stripPrefix: true
|
|
3811
|
-
})}
|
|
3812
|
-
component={props.Wrapper}
|
|
3800
|
+
{...props.attributes}
|
|
3801
|
+
{...props.actionAttributes}
|
|
3802
|
+
component={props.TagName}
|
|
3813
3803
|
/>}
|
|
3814
|
-
when={props.
|
|
3804
|
+
when={!isEmptyElement(props.TagName)}
|
|
3805
|
+
><Show3
|
|
3806
|
+
fallback={<Dynamic
|
|
3807
|
+
{...props.attributes}
|
|
3808
|
+
{...props.actionAttributes}
|
|
3809
|
+
component={props.TagName}
|
|
3810
|
+
>{props.children}</Dynamic>}
|
|
3811
|
+
when={typeof props.TagName === "string"}
|
|
3815
3812
|
><Dynamic
|
|
3816
|
-
{...
|
|
3813
|
+
{...props.attributes}
|
|
3814
|
+
{...props.actionAttributes}
|
|
3815
|
+
component={props.TagName}
|
|
3816
|
+
>{props.children}</Dynamic></Show3></Show3>;
|
|
3817
|
+
}
|
|
3818
|
+
var Dynamic_renderer_default = DynamicRenderer;
|
|
3819
|
+
|
|
3820
|
+
// src/components/block/components/block-wrapper.tsx
|
|
3821
|
+
function BlockWrapper(props) {
|
|
3822
|
+
return <Dynamic_renderer_default
|
|
3823
|
+
TagName={props.Wrapper}
|
|
3824
|
+
attributes={getBlockProperties({
|
|
3817
3825
|
block: props.block,
|
|
3818
3826
|
context: props.context
|
|
3819
3827
|
})}
|
|
3820
|
-
{
|
|
3828
|
+
actionAttributes={getBlockActions({
|
|
3821
3829
|
block: props.block,
|
|
3822
3830
|
rootState: props.context.rootState,
|
|
3823
3831
|
rootSetState: props.context.rootSetState,
|
|
@@ -3825,8 +3833,7 @@ function BlockWrapper(props) {
|
|
|
3825
3833
|
context: props.context.context,
|
|
3826
3834
|
stripPrefix: true
|
|
3827
3835
|
})}
|
|
3828
|
-
|
|
3829
|
-
>{props.children}</Dynamic></Show3>;
|
|
3836
|
+
>{props.children}</Dynamic_renderer_default>;
|
|
3830
3837
|
}
|
|
3831
3838
|
var Block_wrapper_default = BlockWrapper;
|
|
3832
3839
|
|
|
@@ -4005,14 +4012,8 @@ function Block(props) {
|
|
|
4005
4012
|
isInteractive={componentRefProps().isInteractive}
|
|
4006
4013
|
/>}
|
|
4007
4014
|
when={!blockComponent()?.noWrap}
|
|
4008
|
-
|
|
4009
|
-
<
|
|
4010
|
-
Wrapper={Tag()}
|
|
4011
|
-
block={processedBlock()}
|
|
4012
|
-
context={props.context}
|
|
4013
|
-
hasChildren={false}
|
|
4014
|
-
/></Show5>
|
|
4015
|
-
<Show5 when={!isEmptyHtmlElement(Tag()) && repeatItem()}><For2 each={repeatItem()}>{(data, _index) => {
|
|
4015
|
+
><Show5
|
|
4016
|
+
fallback={<For2 each={repeatItem()}>{(data, _index) => {
|
|
4016
4017
|
const index = _index();
|
|
4017
4018
|
return <Repeated_block_default
|
|
4018
4019
|
key={index}
|
|
@@ -4020,41 +4021,40 @@ function Block(props) {
|
|
|
4020
4021
|
block={data.block}
|
|
4021
4022
|
registeredComponents={props.registeredComponents}
|
|
4022
4023
|
/>;
|
|
4023
|
-
}}</For2
|
|
4024
|
-
|
|
4025
|
-
|
|
4026
|
-
|
|
4027
|
-
|
|
4028
|
-
|
|
4029
|
-
|
|
4030
|
-
|
|
4031
|
-
|
|
4032
|
-
|
|
4033
|
-
|
|
4034
|
-
|
|
4035
|
-
|
|
4036
|
-
|
|
4037
|
-
|
|
4038
|
-
|
|
4039
|
-
|
|
4040
|
-
|
|
4041
|
-
|
|
4042
|
-
|
|
4043
|
-
|
|
4044
|
-
|
|
4045
|
-
|
|
4046
|
-
|
|
4047
|
-
|
|
4048
|
-
|
|
4049
|
-
|
|
4050
|
-
</Show5>
|
|
4024
|
+
}}</For2>}
|
|
4025
|
+
when={!repeatItem()}
|
|
4026
|
+
><Block_wrapper_default
|
|
4027
|
+
Wrapper={Tag()}
|
|
4028
|
+
block={processedBlock()}
|
|
4029
|
+
context={props.context}
|
|
4030
|
+
>
|
|
4031
|
+
<Component_ref_default
|
|
4032
|
+
componentRef={componentRefProps().componentRef}
|
|
4033
|
+
componentOptions={componentRefProps().componentOptions}
|
|
4034
|
+
blockChildren={componentRefProps().blockChildren}
|
|
4035
|
+
context={componentRefProps().context}
|
|
4036
|
+
registeredComponents={componentRefProps().registeredComponents}
|
|
4037
|
+
builderBlock={componentRefProps().builderBlock}
|
|
4038
|
+
includeBlockProps={componentRefProps().includeBlockProps}
|
|
4039
|
+
isInteractive={componentRefProps().isInteractive}
|
|
4040
|
+
/>
|
|
4041
|
+
<For2 each={childrenWithoutParentComponent()}>{(child, _index) => {
|
|
4042
|
+
const index = _index();
|
|
4043
|
+
return <Block
|
|
4044
|
+
key={child.id}
|
|
4045
|
+
block={child}
|
|
4046
|
+
context={childrenContext()}
|
|
4047
|
+
registeredComponents={props.registeredComponents}
|
|
4048
|
+
/>;
|
|
4049
|
+
}}</For2>
|
|
4050
|
+
</Block_wrapper_default></Show5></Show5>
|
|
4051
4051
|
</Show5>;
|
|
4052
4052
|
}
|
|
4053
4053
|
var Block_default = Block;
|
|
4054
4054
|
|
|
4055
4055
|
// src/components/blocks/blocks-wrapper.tsx
|
|
4056
4056
|
import { Dynamic as Dynamic4 } from "solid-js/web";
|
|
4057
|
-
import { css
|
|
4057
|
+
import { css } from "solid-styled-components";
|
|
4058
4058
|
function BlocksWrapper(props) {
|
|
4059
4059
|
function className() {
|
|
4060
4060
|
return "builder-blocks" + (!props.blocks?.length ? " no-blocks" : "");
|
|
@@ -4088,7 +4088,7 @@ function BlocksWrapper(props) {
|
|
|
4088
4088
|
}
|
|
4089
4089
|
}
|
|
4090
4090
|
return <Dynamic4
|
|
4091
|
-
class={className() + " " +
|
|
4091
|
+
class={className() + " " + css({
|
|
4092
4092
|
display: "flex",
|
|
4093
4093
|
flexDirection: "column",
|
|
4094
4094
|
alignItems: "stretch"
|
|
@@ -4229,7 +4229,7 @@ function Columns(props) {
|
|
|
4229
4229
|
`;
|
|
4230
4230
|
}
|
|
4231
4231
|
return <div
|
|
4232
|
-
class={`builder-columns ${props.builderBlock.id}-breakpoints ` +
|
|
4232
|
+
class={`builder-columns ${props.builderBlock.id}-breakpoints ` + css2({
|
|
4233
4233
|
display: "flex",
|
|
4234
4234
|
lineHeight: "normal"
|
|
4235
4235
|
})}
|
|
@@ -4240,7 +4240,7 @@ function Columns(props) {
|
|
|
4240
4240
|
<For4 each={props.columns}>{(column, _index) => {
|
|
4241
4241
|
const index = _index();
|
|
4242
4242
|
return <div
|
|
4243
|
-
class={"builder-column " +
|
|
4243
|
+
class={"builder-column " + css2({
|
|
4244
4244
|
display: "flex",
|
|
4245
4245
|
flexDirection: "column",
|
|
4246
4246
|
alignItems: "stretch"
|
|
@@ -4271,7 +4271,7 @@ var fragment_default = FragmentComponent;
|
|
|
4271
4271
|
|
|
4272
4272
|
// src/blocks/image/image.tsx
|
|
4273
4273
|
import { Show as Show8 } from "solid-js";
|
|
4274
|
-
import { css as
|
|
4274
|
+
import { css as css3 } from "solid-styled-components";
|
|
4275
4275
|
|
|
4276
4276
|
// src/blocks/image/image.helpers.ts
|
|
4277
4277
|
function removeProtocol(path) {
|
|
@@ -4361,7 +4361,7 @@ function Image(props) {
|
|
|
4361
4361
|
<picture>
|
|
4362
4362
|
<Show8 when={webpSrcSet()}><source type="image/webp" srcset={webpSrcSet()} /></Show8>
|
|
4363
4363
|
<img
|
|
4364
|
-
class={"builder-image" + (props.className ? " " + props.className : "") + " " +
|
|
4364
|
+
class={"builder-image" + (props.className ? " " + props.className : "") + " " + css3({
|
|
4365
4365
|
opacity: "1",
|
|
4366
4366
|
transition: "opacity 0.2s ease-in-out"
|
|
4367
4367
|
})}
|
|
@@ -4381,7 +4381,7 @@ function Image(props) {
|
|
|
4381
4381
|
<Show8
|
|
4382
4382
|
when={props.aspectRatio && !(props.builderBlock?.children?.length && props.fitContent)}
|
|
4383
4383
|
><div
|
|
4384
|
-
class={"builder-image-sizer " +
|
|
4384
|
+
class={"builder-image-sizer " + css3({
|
|
4385
4385
|
width: "100%",
|
|
4386
4386
|
pointerEvents: "none",
|
|
4387
4387
|
fontSize: "0"
|
|
@@ -4392,7 +4392,7 @@ function Image(props) {
|
|
|
4392
4392
|
/></Show8>
|
|
4393
4393
|
<Show8 when={props.builderBlock?.children?.length && props.fitContent}>{props.children}</Show8>
|
|
4394
4394
|
<Show8 when={!props.fitContent && props.children}><div
|
|
4395
|
-
class={
|
|
4395
|
+
class={css3({
|
|
4396
4396
|
display: "flex",
|
|
4397
4397
|
flexDirection: "column",
|
|
4398
4398
|
alignItems: "stretch",
|
|
@@ -5868,6 +5868,13 @@ async function fetchEntries(options) {
|
|
|
5868
5868
|
}
|
|
5869
5869
|
var getAllContent = fetchEntries;
|
|
5870
5870
|
|
|
5871
|
+
// src/functions/is-from-trusted-host.ts
|
|
5872
|
+
var DEFAULT_TRUSTED_HOSTS = ["*.beta.builder.io", "beta.builder.io", "builder.io", "localhost", "qa.builder.io"];
|
|
5873
|
+
function isFromTrustedHost(trustedHosts, e) {
|
|
5874
|
+
const url = new URL(e.origin), hostname = url.hostname;
|
|
5875
|
+
return (trustedHosts || DEFAULT_TRUSTED_HOSTS).findIndex((trustedHost) => trustedHost.startsWith("*.") ? hostname.endsWith(trustedHost.slice(1)) : trustedHost === hostname) > -1;
|
|
5876
|
+
}
|
|
5877
|
+
|
|
5871
5878
|
// src/functions/is-previewing.ts
|
|
5872
5879
|
function isPreviewing() {
|
|
5873
5880
|
if (!isBrowser()) {
|
|
@@ -6116,7 +6123,7 @@ var getInteractionPropertiesForEvent = (event) => {
|
|
|
6116
6123
|
};
|
|
6117
6124
|
|
|
6118
6125
|
// src/constants/sdk-version.ts
|
|
6119
|
-
var SDK_VERSION = "0.12.
|
|
6126
|
+
var SDK_VERSION = "0.12.3";
|
|
6120
6127
|
|
|
6121
6128
|
// src/functions/register.ts
|
|
6122
6129
|
var registry = {};
|
|
@@ -6193,9 +6200,13 @@ var setupBrowserForEditing = (options = {}) => {
|
|
|
6193
6200
|
options
|
|
6194
6201
|
}
|
|
6195
6202
|
}, "*");
|
|
6196
|
-
window.addEventListener("message", ({
|
|
6197
|
-
|
|
6198
|
-
|
|
6203
|
+
window.addEventListener("message", (event) => {
|
|
6204
|
+
if (!isFromTrustedHost(options.trustedHosts, event)) {
|
|
6205
|
+
return;
|
|
6206
|
+
}
|
|
6207
|
+
const {
|
|
6208
|
+
data
|
|
6209
|
+
} = event;
|
|
6199
6210
|
if (!data?.type) {
|
|
6200
6211
|
return;
|
|
6201
6212
|
}
|
|
@@ -6293,6 +6304,9 @@ function EnableEditor(props) {
|
|
|
6293
6304
|
}));
|
|
6294
6305
|
}
|
|
6295
6306
|
function processMessage(event) {
|
|
6307
|
+
if (!isFromTrustedHost(props.trustedHosts, event)) {
|
|
6308
|
+
return;
|
|
6309
|
+
}
|
|
6296
6310
|
const { data } = event;
|
|
6297
6311
|
if (data) {
|
|
6298
6312
|
switch (data.type) {
|
|
@@ -6423,6 +6437,9 @@ function EnableEditor(props) {
|
|
|
6423
6437
|
} : {},
|
|
6424
6438
|
...props.enrich ? {
|
|
6425
6439
|
enrich: props.enrich
|
|
6440
|
+
} : {},
|
|
6441
|
+
...props.trustedHosts ? {
|
|
6442
|
+
trustedHosts: props.trustedHosts
|
|
6426
6443
|
} : {}
|
|
6427
6444
|
});
|
|
6428
6445
|
Object.values(
|
|
@@ -6617,6 +6634,10 @@ ${getFontCss({
|
|
|
6617
6634
|
customFonts: props.customFonts
|
|
6618
6635
|
})}
|
|
6619
6636
|
|
|
6637
|
+
.builder-button {
|
|
6638
|
+
all: unset;
|
|
6639
|
+
}
|
|
6640
|
+
|
|
6620
6641
|
.builder-text > p:first-of-type, .builder-text > .builder-paragraph:first-of-type {
|
|
6621
6642
|
margin: 0;
|
|
6622
6643
|
}
|
|
@@ -6761,6 +6782,7 @@ function ContentComponent(props) {
|
|
|
6761
6782
|
builderContextSignal={builderContextSignal()}
|
|
6762
6783
|
contentWrapper={props.contentWrapper}
|
|
6763
6784
|
contentWrapperProps={props.contentWrapperProps}
|
|
6785
|
+
trustedHosts={props.trustedHosts}
|
|
6764
6786
|
{...{
|
|
6765
6787
|
setBuilderContextSignal
|
|
6766
6788
|
}}
|
|
@@ -6843,6 +6865,7 @@ function ContentVariants(props) {
|
|
|
6843
6865
|
blocksWrapperProps={props.blocksWrapperProps}
|
|
6844
6866
|
contentWrapper={props.contentWrapper}
|
|
6845
6867
|
contentWrapperProps={props.contentWrapperProps}
|
|
6868
|
+
trustedHosts={props.trustedHosts}
|
|
6846
6869
|
/>;
|
|
6847
6870
|
}}</For5>
|
|
6848
6871
|
</Show12>
|
|
@@ -6865,6 +6888,7 @@ function ContentVariants(props) {
|
|
|
6865
6888
|
blocksWrapperProps={props.blocksWrapperProps}
|
|
6866
6889
|
contentWrapper={props.contentWrapper}
|
|
6867
6890
|
contentWrapperProps={props.contentWrapperProps}
|
|
6891
|
+
trustedHosts={props.trustedHosts}
|
|
6868
6892
|
/>
|
|
6869
6893
|
</>;
|
|
6870
6894
|
}
|