@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/browser/dev.jsx
CHANGED
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
// src/blocks/button/button.tsx
|
|
2
2
|
import { Show } from "solid-js";
|
|
3
|
-
import { css } from "solid-styled-components";
|
|
4
3
|
function Button(props) {
|
|
5
4
|
return <Show
|
|
6
5
|
fallback={<button
|
|
7
|
-
class={props.attributes.class
|
|
8
|
-
|
|
9
|
-
})}
|
|
6
|
+
class={`builder-button ${props.attributes.class}`}
|
|
7
|
+
role="button"
|
|
10
8
|
{...{}}
|
|
11
9
|
{...props.attributes}
|
|
12
10
|
style={props.attributes.style}
|
|
@@ -24,7 +22,7 @@ var button_default = Button;
|
|
|
24
22
|
|
|
25
23
|
// src/blocks/columns/columns.tsx
|
|
26
24
|
import { Show as Show7, For as For4, createSignal as createSignal5 } from "solid-js";
|
|
27
|
-
import { css as
|
|
25
|
+
import { css as css2 } from "solid-styled-components";
|
|
28
26
|
|
|
29
27
|
// src/components/blocks/blocks.tsx
|
|
30
28
|
import { useContext, Show as Show6, For as For3 } from "solid-js";
|
|
@@ -325,10 +323,6 @@ function getProcessedBlock({
|
|
|
325
323
|
}
|
|
326
324
|
|
|
327
325
|
// src/components/block/block.helpers.ts
|
|
328
|
-
var EMPTY_HTML_ELEMENTS = ["area", "base", "br", "col", "embed", "hr", "img", "input", "keygen", "link", "meta", "param", "source", "track", "wbr"];
|
|
329
|
-
var isEmptyHtmlElement = (tagName) => {
|
|
330
|
-
return typeof tagName === "string" && EMPTY_HTML_ELEMENTS.includes(tagName.toLowerCase());
|
|
331
|
-
};
|
|
332
326
|
var getComponent = ({
|
|
333
327
|
block,
|
|
334
328
|
context,
|
|
@@ -506,7 +500,7 @@ function BlockStyles(props) {
|
|
|
506
500
|
}
|
|
507
501
|
return true;
|
|
508
502
|
}
|
|
509
|
-
function
|
|
503
|
+
function css4() {
|
|
510
504
|
const processedBlock = getProcessedBlock({
|
|
511
505
|
block: props.block,
|
|
512
506
|
localState: props.context.localState,
|
|
@@ -549,14 +543,10 @@ function BlockStyles(props) {
|
|
|
549
543
|
}) : "";
|
|
550
544
|
return [largeStylesClass, mediumStylesClass, smallStylesClass].join(" ");
|
|
551
545
|
}
|
|
552
|
-
return <Show2 when={TARGET !== "reactNative" &&
|
|
546
|
+
return <Show2 when={TARGET !== "reactNative" && css4() && canShowBlock()}><Inlined_styles_default styles={css4()} /></Show2>;
|
|
553
547
|
}
|
|
554
548
|
var Block_styles_default = BlockStyles;
|
|
555
549
|
|
|
556
|
-
// src/components/block/components/block-wrapper.tsx
|
|
557
|
-
import { Show as Show3 } from "solid-js";
|
|
558
|
-
import { Dynamic } from "solid-js/web";
|
|
559
|
-
|
|
560
550
|
// src/functions/event-handler-name.ts
|
|
561
551
|
function capitalizeFirstLetter(string) {
|
|
562
552
|
return string.charAt(0).toUpperCase() + string.slice(1);
|
|
@@ -643,31 +633,49 @@ function getStyleAttribute(style) {
|
|
|
643
633
|
}
|
|
644
634
|
}
|
|
645
635
|
|
|
646
|
-
// src/components/
|
|
647
|
-
|
|
636
|
+
// src/components/dynamic-renderer/dynamic-renderer.tsx
|
|
637
|
+
import { Show as Show3 } from "solid-js";
|
|
638
|
+
import { Dynamic } from "solid-js/web";
|
|
639
|
+
|
|
640
|
+
// src/components/dynamic-renderer/dynamic-renderer.helpers.ts
|
|
641
|
+
var EMPTY_HTML_ELEMENTS = /* @__PURE__ */ new Set(["area", "base", "br", "col", "embed", "hr", "img", "input", "keygen", "link", "meta", "param", "source", "track", "wbr"]);
|
|
642
|
+
var isEmptyElement = (tagName) => {
|
|
643
|
+
return typeof tagName === "string" && EMPTY_HTML_ELEMENTS.has(tagName.toLowerCase());
|
|
644
|
+
};
|
|
645
|
+
|
|
646
|
+
// src/components/dynamic-renderer/dynamic-renderer.tsx
|
|
647
|
+
function DynamicRenderer(props) {
|
|
648
648
|
return <Show3
|
|
649
649
|
fallback={<Dynamic
|
|
650
|
-
{...
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
})}
|
|
654
|
-
{...getBlockActions({
|
|
655
|
-
block: props.block,
|
|
656
|
-
rootState: props.context.rootState,
|
|
657
|
-
rootSetState: props.context.rootSetState,
|
|
658
|
-
localState: props.context.localState,
|
|
659
|
-
context: props.context.context,
|
|
660
|
-
stripPrefix: true
|
|
661
|
-
})}
|
|
662
|
-
component={props.Wrapper}
|
|
650
|
+
{...props.attributes}
|
|
651
|
+
{...props.actionAttributes}
|
|
652
|
+
component={props.TagName}
|
|
663
653
|
/>}
|
|
664
|
-
when={props.
|
|
654
|
+
when={!isEmptyElement(props.TagName)}
|
|
655
|
+
><Show3
|
|
656
|
+
fallback={<Dynamic
|
|
657
|
+
{...props.attributes}
|
|
658
|
+
{...props.actionAttributes}
|
|
659
|
+
component={props.TagName}
|
|
660
|
+
>{props.children}</Dynamic>}
|
|
661
|
+
when={typeof props.TagName === "string"}
|
|
665
662
|
><Dynamic
|
|
666
|
-
{...
|
|
663
|
+
{...props.attributes}
|
|
664
|
+
{...props.actionAttributes}
|
|
665
|
+
component={props.TagName}
|
|
666
|
+
>{props.children}</Dynamic></Show3></Show3>;
|
|
667
|
+
}
|
|
668
|
+
var Dynamic_renderer_default = DynamicRenderer;
|
|
669
|
+
|
|
670
|
+
// src/components/block/components/block-wrapper.tsx
|
|
671
|
+
function BlockWrapper(props) {
|
|
672
|
+
return <Dynamic_renderer_default
|
|
673
|
+
TagName={props.Wrapper}
|
|
674
|
+
attributes={getBlockProperties({
|
|
667
675
|
block: props.block,
|
|
668
676
|
context: props.context
|
|
669
677
|
})}
|
|
670
|
-
{
|
|
678
|
+
actionAttributes={getBlockActions({
|
|
671
679
|
block: props.block,
|
|
672
680
|
rootState: props.context.rootState,
|
|
673
681
|
rootSetState: props.context.rootSetState,
|
|
@@ -675,8 +683,7 @@ function BlockWrapper(props) {
|
|
|
675
683
|
context: props.context.context,
|
|
676
684
|
stripPrefix: true
|
|
677
685
|
})}
|
|
678
|
-
|
|
679
|
-
>{props.children}</Dynamic></Show3>;
|
|
686
|
+
>{props.children}</Dynamic_renderer_default>;
|
|
680
687
|
}
|
|
681
688
|
var Block_wrapper_default = BlockWrapper;
|
|
682
689
|
|
|
@@ -855,14 +862,8 @@ function Block(props) {
|
|
|
855
862
|
isInteractive={componentRefProps().isInteractive}
|
|
856
863
|
/>}
|
|
857
864
|
when={!blockComponent()?.noWrap}
|
|
858
|
-
|
|
859
|
-
<
|
|
860
|
-
Wrapper={Tag()}
|
|
861
|
-
block={processedBlock()}
|
|
862
|
-
context={props.context}
|
|
863
|
-
hasChildren={false}
|
|
864
|
-
/></Show5>
|
|
865
|
-
<Show5 when={!isEmptyHtmlElement(Tag()) && repeatItem()}><For2 each={repeatItem()}>{(data, _index) => {
|
|
865
|
+
><Show5
|
|
866
|
+
fallback={<For2 each={repeatItem()}>{(data, _index) => {
|
|
866
867
|
const index = _index();
|
|
867
868
|
return <Repeated_block_default
|
|
868
869
|
key={index}
|
|
@@ -870,41 +871,40 @@ function Block(props) {
|
|
|
870
871
|
block={data.block}
|
|
871
872
|
registeredComponents={props.registeredComponents}
|
|
872
873
|
/>;
|
|
873
|
-
}}</For2
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
</Show5>
|
|
874
|
+
}}</For2>}
|
|
875
|
+
when={!repeatItem()}
|
|
876
|
+
><Block_wrapper_default
|
|
877
|
+
Wrapper={Tag()}
|
|
878
|
+
block={processedBlock()}
|
|
879
|
+
context={props.context}
|
|
880
|
+
>
|
|
881
|
+
<Component_ref_default
|
|
882
|
+
componentRef={componentRefProps().componentRef}
|
|
883
|
+
componentOptions={componentRefProps().componentOptions}
|
|
884
|
+
blockChildren={componentRefProps().blockChildren}
|
|
885
|
+
context={componentRefProps().context}
|
|
886
|
+
registeredComponents={componentRefProps().registeredComponents}
|
|
887
|
+
builderBlock={componentRefProps().builderBlock}
|
|
888
|
+
includeBlockProps={componentRefProps().includeBlockProps}
|
|
889
|
+
isInteractive={componentRefProps().isInteractive}
|
|
890
|
+
/>
|
|
891
|
+
<For2 each={childrenWithoutParentComponent()}>{(child, _index) => {
|
|
892
|
+
const index = _index();
|
|
893
|
+
return <Block
|
|
894
|
+
key={child.id}
|
|
895
|
+
block={child}
|
|
896
|
+
context={childrenContext()}
|
|
897
|
+
registeredComponents={props.registeredComponents}
|
|
898
|
+
/>;
|
|
899
|
+
}}</For2>
|
|
900
|
+
</Block_wrapper_default></Show5></Show5>
|
|
901
901
|
</Show5>;
|
|
902
902
|
}
|
|
903
903
|
var Block_default = Block;
|
|
904
904
|
|
|
905
905
|
// src/components/blocks/blocks-wrapper.tsx
|
|
906
906
|
import { Dynamic as Dynamic4 } from "solid-js/web";
|
|
907
|
-
import { css
|
|
907
|
+
import { css } from "solid-styled-components";
|
|
908
908
|
function BlocksWrapper(props) {
|
|
909
909
|
function className() {
|
|
910
910
|
return "builder-blocks" + (!props.blocks?.length ? " no-blocks" : "");
|
|
@@ -938,7 +938,7 @@ function BlocksWrapper(props) {
|
|
|
938
938
|
}
|
|
939
939
|
}
|
|
940
940
|
return <Dynamic4
|
|
941
|
-
class={className() + " " +
|
|
941
|
+
class={className() + " " + css({
|
|
942
942
|
display: "flex",
|
|
943
943
|
flexDirection: "column",
|
|
944
944
|
alignItems: "stretch"
|
|
@@ -1079,7 +1079,7 @@ function Columns(props) {
|
|
|
1079
1079
|
`;
|
|
1080
1080
|
}
|
|
1081
1081
|
return <div
|
|
1082
|
-
class={`builder-columns ${props.builderBlock.id}-breakpoints ` +
|
|
1082
|
+
class={`builder-columns ${props.builderBlock.id}-breakpoints ` + css2({
|
|
1083
1083
|
display: "flex",
|
|
1084
1084
|
lineHeight: "normal"
|
|
1085
1085
|
})}
|
|
@@ -1090,7 +1090,7 @@ function Columns(props) {
|
|
|
1090
1090
|
<For4 each={props.columns}>{(column, _index) => {
|
|
1091
1091
|
const index = _index();
|
|
1092
1092
|
return <div
|
|
1093
|
-
class={"builder-column " +
|
|
1093
|
+
class={"builder-column " + css2({
|
|
1094
1094
|
display: "flex",
|
|
1095
1095
|
flexDirection: "column",
|
|
1096
1096
|
alignItems: "stretch"
|
|
@@ -1121,7 +1121,7 @@ var fragment_default = FragmentComponent;
|
|
|
1121
1121
|
|
|
1122
1122
|
// src/blocks/image/image.tsx
|
|
1123
1123
|
import { Show as Show8 } from "solid-js";
|
|
1124
|
-
import { css as
|
|
1124
|
+
import { css as css3 } from "solid-styled-components";
|
|
1125
1125
|
|
|
1126
1126
|
// src/blocks/image/image.helpers.ts
|
|
1127
1127
|
function removeProtocol(path) {
|
|
@@ -1212,7 +1212,7 @@ function Image(props) {
|
|
|
1212
1212
|
<picture>
|
|
1213
1213
|
<Show8 when={webpSrcSet()}><source type="image/webp" srcset={webpSrcSet()} /></Show8>
|
|
1214
1214
|
<img
|
|
1215
|
-
class={"builder-image" + (props.className ? " " + props.className : "") + " " +
|
|
1215
|
+
class={"builder-image" + (props.className ? " " + props.className : "") + " " + css3({
|
|
1216
1216
|
opacity: "1",
|
|
1217
1217
|
transition: "opacity 0.2s ease-in-out"
|
|
1218
1218
|
})}
|
|
@@ -1232,7 +1232,7 @@ function Image(props) {
|
|
|
1232
1232
|
<Show8
|
|
1233
1233
|
when={props.aspectRatio && !(props.builderBlock?.children?.length && props.fitContent)}
|
|
1234
1234
|
><div
|
|
1235
|
-
class={"builder-image-sizer " +
|
|
1235
|
+
class={"builder-image-sizer " + css3({
|
|
1236
1236
|
width: "100%",
|
|
1237
1237
|
pointerEvents: "none",
|
|
1238
1238
|
fontSize: "0"
|
|
@@ -1243,7 +1243,7 @@ function Image(props) {
|
|
|
1243
1243
|
/></Show8>
|
|
1244
1244
|
<Show8 when={props.builderBlock?.children?.length && props.fitContent}>{props.children}</Show8>
|
|
1245
1245
|
<Show8 when={!props.fitContent && props.children}><div
|
|
1246
|
-
class={
|
|
1246
|
+
class={css3({
|
|
1247
1247
|
display: "flex",
|
|
1248
1248
|
flexDirection: "column",
|
|
1249
1249
|
alignItems: "stretch",
|
|
@@ -2724,6 +2724,13 @@ async function fetchEntries(options) {
|
|
|
2724
2724
|
}
|
|
2725
2725
|
var getAllContent = fetchEntries;
|
|
2726
2726
|
|
|
2727
|
+
// src/functions/is-from-trusted-host.ts
|
|
2728
|
+
var DEFAULT_TRUSTED_HOSTS = ["*.beta.builder.io", "beta.builder.io", "builder.io", "localhost", "qa.builder.io"];
|
|
2729
|
+
function isFromTrustedHost(trustedHosts, e) {
|
|
2730
|
+
const url = new URL(e.origin), hostname = url.hostname;
|
|
2731
|
+
return (trustedHosts || DEFAULT_TRUSTED_HOSTS).findIndex((trustedHost) => trustedHost.startsWith("*.") ? hostname.endsWith(trustedHost.slice(1)) : trustedHost === hostname) > -1;
|
|
2732
|
+
}
|
|
2733
|
+
|
|
2727
2734
|
// src/functions/is-previewing.ts
|
|
2728
2735
|
function isPreviewing() {
|
|
2729
2736
|
if (!isBrowser()) {
|
|
@@ -2975,7 +2982,7 @@ var getInteractionPropertiesForEvent = (event) => {
|
|
|
2975
2982
|
};
|
|
2976
2983
|
|
|
2977
2984
|
// src/constants/sdk-version.ts
|
|
2978
|
-
var SDK_VERSION = "0.12.
|
|
2985
|
+
var SDK_VERSION = "0.12.3";
|
|
2979
2986
|
|
|
2980
2987
|
// src/functions/register.ts
|
|
2981
2988
|
var registry = {};
|
|
@@ -3053,9 +3060,13 @@ var setupBrowserForEditing = (options = {}) => {
|
|
|
3053
3060
|
options
|
|
3054
3061
|
}
|
|
3055
3062
|
}, "*");
|
|
3056
|
-
window.addEventListener("message", ({
|
|
3057
|
-
|
|
3058
|
-
|
|
3063
|
+
window.addEventListener("message", (event) => {
|
|
3064
|
+
if (!isFromTrustedHost(options.trustedHosts, event)) {
|
|
3065
|
+
return;
|
|
3066
|
+
}
|
|
3067
|
+
const {
|
|
3068
|
+
data
|
|
3069
|
+
} = event;
|
|
3059
3070
|
if (!data?.type) {
|
|
3060
3071
|
return;
|
|
3061
3072
|
}
|
|
@@ -3153,6 +3164,9 @@ function EnableEditor(props) {
|
|
|
3153
3164
|
}));
|
|
3154
3165
|
}
|
|
3155
3166
|
function processMessage(event) {
|
|
3167
|
+
if (!isFromTrustedHost(props.trustedHosts, event)) {
|
|
3168
|
+
return;
|
|
3169
|
+
}
|
|
3156
3170
|
const { data } = event;
|
|
3157
3171
|
if (data) {
|
|
3158
3172
|
switch (data.type) {
|
|
@@ -3284,6 +3298,9 @@ function EnableEditor(props) {
|
|
|
3284
3298
|
} : {},
|
|
3285
3299
|
...props.enrich ? {
|
|
3286
3300
|
enrich: props.enrich
|
|
3301
|
+
} : {},
|
|
3302
|
+
...props.trustedHosts ? {
|
|
3303
|
+
trustedHosts: props.trustedHosts
|
|
3287
3304
|
} : {}
|
|
3288
3305
|
});
|
|
3289
3306
|
Object.values(
|
|
@@ -3478,6 +3495,10 @@ ${getFontCss({
|
|
|
3478
3495
|
customFonts: props.customFonts
|
|
3479
3496
|
})}
|
|
3480
3497
|
|
|
3498
|
+
.builder-button {
|
|
3499
|
+
all: unset;
|
|
3500
|
+
}
|
|
3501
|
+
|
|
3481
3502
|
.builder-text > p:first-of-type, .builder-text > .builder-paragraph:first-of-type {
|
|
3482
3503
|
margin: 0;
|
|
3483
3504
|
}
|
|
@@ -3622,6 +3643,7 @@ function ContentComponent(props) {
|
|
|
3622
3643
|
builderContextSignal={builderContextSignal()}
|
|
3623
3644
|
contentWrapper={props.contentWrapper}
|
|
3624
3645
|
contentWrapperProps={props.contentWrapperProps}
|
|
3646
|
+
trustedHosts={props.trustedHosts}
|
|
3625
3647
|
{...{
|
|
3626
3648
|
setBuilderContextSignal
|
|
3627
3649
|
}}
|
|
@@ -3704,6 +3726,7 @@ function ContentVariants(props) {
|
|
|
3704
3726
|
blocksWrapperProps={props.blocksWrapperProps}
|
|
3705
3727
|
contentWrapper={props.contentWrapper}
|
|
3706
3728
|
contentWrapperProps={props.contentWrapperProps}
|
|
3729
|
+
trustedHosts={props.trustedHosts}
|
|
3707
3730
|
/>;
|
|
3708
3731
|
}}</For5>
|
|
3709
3732
|
</Show12>
|
|
@@ -3726,6 +3749,7 @@ function ContentVariants(props) {
|
|
|
3726
3749
|
blocksWrapperProps={props.blocksWrapperProps}
|
|
3727
3750
|
contentWrapper={props.contentWrapper}
|
|
3728
3751
|
contentWrapperProps={props.contentWrapperProps}
|
|
3752
|
+
trustedHosts={props.trustedHosts}
|
|
3729
3753
|
/>
|
|
3730
3754
|
</>;
|
|
3731
3755
|
}
|