@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/index.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";
|
|
@@ -323,10 +321,6 @@ function getProcessedBlock({
|
|
|
323
321
|
}
|
|
324
322
|
|
|
325
323
|
// src/components/block/block.helpers.ts
|
|
326
|
-
var EMPTY_HTML_ELEMENTS = ["area", "base", "br", "col", "embed", "hr", "img", "input", "keygen", "link", "meta", "param", "source", "track", "wbr"];
|
|
327
|
-
var isEmptyHtmlElement = (tagName) => {
|
|
328
|
-
return typeof tagName === "string" && EMPTY_HTML_ELEMENTS.includes(tagName.toLowerCase());
|
|
329
|
-
};
|
|
330
324
|
var getComponent = ({
|
|
331
325
|
block,
|
|
332
326
|
context,
|
|
@@ -501,7 +495,7 @@ function BlockStyles(props) {
|
|
|
501
495
|
}
|
|
502
496
|
return true;
|
|
503
497
|
}
|
|
504
|
-
function
|
|
498
|
+
function css4() {
|
|
505
499
|
const processedBlock = getProcessedBlock({
|
|
506
500
|
block: props.block,
|
|
507
501
|
localState: props.context.localState,
|
|
@@ -544,14 +538,10 @@ function BlockStyles(props) {
|
|
|
544
538
|
}) : "";
|
|
545
539
|
return [largeStylesClass, mediumStylesClass, smallStylesClass].join(" ");
|
|
546
540
|
}
|
|
547
|
-
return <Show2 when={TARGET !== "reactNative" &&
|
|
541
|
+
return <Show2 when={TARGET !== "reactNative" && css4() && canShowBlock()}><Inlined_styles_default styles={css4()} /></Show2>;
|
|
548
542
|
}
|
|
549
543
|
var Block_styles_default = BlockStyles;
|
|
550
544
|
|
|
551
|
-
// src/components/block/components/block-wrapper.tsx
|
|
552
|
-
import { Show as Show3 } from "solid-js";
|
|
553
|
-
import { Dynamic } from "solid-js/web";
|
|
554
|
-
|
|
555
545
|
// src/functions/event-handler-name.ts
|
|
556
546
|
function capitalizeFirstLetter(string) {
|
|
557
547
|
return string.charAt(0).toUpperCase() + string.slice(1);
|
|
@@ -638,31 +628,49 @@ function getStyleAttribute(style) {
|
|
|
638
628
|
}
|
|
639
629
|
}
|
|
640
630
|
|
|
641
|
-
// src/components/
|
|
642
|
-
|
|
631
|
+
// src/components/dynamic-renderer/dynamic-renderer.tsx
|
|
632
|
+
import { Show as Show3 } from "solid-js";
|
|
633
|
+
import { Dynamic } from "solid-js/web";
|
|
634
|
+
|
|
635
|
+
// src/components/dynamic-renderer/dynamic-renderer.helpers.ts
|
|
636
|
+
var EMPTY_HTML_ELEMENTS = /* @__PURE__ */ new Set(["area", "base", "br", "col", "embed", "hr", "img", "input", "keygen", "link", "meta", "param", "source", "track", "wbr"]);
|
|
637
|
+
var isEmptyElement = (tagName) => {
|
|
638
|
+
return typeof tagName === "string" && EMPTY_HTML_ELEMENTS.has(tagName.toLowerCase());
|
|
639
|
+
};
|
|
640
|
+
|
|
641
|
+
// src/components/dynamic-renderer/dynamic-renderer.tsx
|
|
642
|
+
function DynamicRenderer(props) {
|
|
643
643
|
return <Show3
|
|
644
644
|
fallback={<Dynamic
|
|
645
|
-
{...
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
})}
|
|
649
|
-
{...getBlockActions({
|
|
650
|
-
block: props.block,
|
|
651
|
-
rootState: props.context.rootState,
|
|
652
|
-
rootSetState: props.context.rootSetState,
|
|
653
|
-
localState: props.context.localState,
|
|
654
|
-
context: props.context.context,
|
|
655
|
-
stripPrefix: true
|
|
656
|
-
})}
|
|
657
|
-
component={props.Wrapper}
|
|
645
|
+
{...props.attributes}
|
|
646
|
+
{...props.actionAttributes}
|
|
647
|
+
component={props.TagName}
|
|
658
648
|
/>}
|
|
659
|
-
when={props.
|
|
649
|
+
when={!isEmptyElement(props.TagName)}
|
|
650
|
+
><Show3
|
|
651
|
+
fallback={<Dynamic
|
|
652
|
+
{...props.attributes}
|
|
653
|
+
{...props.actionAttributes}
|
|
654
|
+
component={props.TagName}
|
|
655
|
+
>{props.children}</Dynamic>}
|
|
656
|
+
when={typeof props.TagName === "string"}
|
|
660
657
|
><Dynamic
|
|
661
|
-
{...
|
|
658
|
+
{...props.attributes}
|
|
659
|
+
{...props.actionAttributes}
|
|
660
|
+
component={props.TagName}
|
|
661
|
+
>{props.children}</Dynamic></Show3></Show3>;
|
|
662
|
+
}
|
|
663
|
+
var Dynamic_renderer_default = DynamicRenderer;
|
|
664
|
+
|
|
665
|
+
// src/components/block/components/block-wrapper.tsx
|
|
666
|
+
function BlockWrapper(props) {
|
|
667
|
+
return <Dynamic_renderer_default
|
|
668
|
+
TagName={props.Wrapper}
|
|
669
|
+
attributes={getBlockProperties({
|
|
662
670
|
block: props.block,
|
|
663
671
|
context: props.context
|
|
664
672
|
})}
|
|
665
|
-
{
|
|
673
|
+
actionAttributes={getBlockActions({
|
|
666
674
|
block: props.block,
|
|
667
675
|
rootState: props.context.rootState,
|
|
668
676
|
rootSetState: props.context.rootSetState,
|
|
@@ -670,8 +678,7 @@ function BlockWrapper(props) {
|
|
|
670
678
|
context: props.context.context,
|
|
671
679
|
stripPrefix: true
|
|
672
680
|
})}
|
|
673
|
-
|
|
674
|
-
>{props.children}</Dynamic></Show3>;
|
|
681
|
+
>{props.children}</Dynamic_renderer_default>;
|
|
675
682
|
}
|
|
676
683
|
var Block_wrapper_default = BlockWrapper;
|
|
677
684
|
|
|
@@ -850,14 +857,8 @@ function Block(props) {
|
|
|
850
857
|
isInteractive={componentRefProps().isInteractive}
|
|
851
858
|
/>}
|
|
852
859
|
when={!blockComponent()?.noWrap}
|
|
853
|
-
|
|
854
|
-
<
|
|
855
|
-
Wrapper={Tag()}
|
|
856
|
-
block={processedBlock()}
|
|
857
|
-
context={props.context}
|
|
858
|
-
hasChildren={false}
|
|
859
|
-
/></Show5>
|
|
860
|
-
<Show5 when={!isEmptyHtmlElement(Tag()) && repeatItem()}><For2 each={repeatItem()}>{(data, _index) => {
|
|
860
|
+
><Show5
|
|
861
|
+
fallback={<For2 each={repeatItem()}>{(data, _index) => {
|
|
861
862
|
const index = _index();
|
|
862
863
|
return <Repeated_block_default
|
|
863
864
|
key={index}
|
|
@@ -865,41 +866,40 @@ function Block(props) {
|
|
|
865
866
|
block={data.block}
|
|
866
867
|
registeredComponents={props.registeredComponents}
|
|
867
868
|
/>;
|
|
868
|
-
}}</For2
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
</Show5>
|
|
869
|
+
}}</For2>}
|
|
870
|
+
when={!repeatItem()}
|
|
871
|
+
><Block_wrapper_default
|
|
872
|
+
Wrapper={Tag()}
|
|
873
|
+
block={processedBlock()}
|
|
874
|
+
context={props.context}
|
|
875
|
+
>
|
|
876
|
+
<Component_ref_default
|
|
877
|
+
componentRef={componentRefProps().componentRef}
|
|
878
|
+
componentOptions={componentRefProps().componentOptions}
|
|
879
|
+
blockChildren={componentRefProps().blockChildren}
|
|
880
|
+
context={componentRefProps().context}
|
|
881
|
+
registeredComponents={componentRefProps().registeredComponents}
|
|
882
|
+
builderBlock={componentRefProps().builderBlock}
|
|
883
|
+
includeBlockProps={componentRefProps().includeBlockProps}
|
|
884
|
+
isInteractive={componentRefProps().isInteractive}
|
|
885
|
+
/>
|
|
886
|
+
<For2 each={childrenWithoutParentComponent()}>{(child, _index) => {
|
|
887
|
+
const index = _index();
|
|
888
|
+
return <Block
|
|
889
|
+
key={child.id}
|
|
890
|
+
block={child}
|
|
891
|
+
context={childrenContext()}
|
|
892
|
+
registeredComponents={props.registeredComponents}
|
|
893
|
+
/>;
|
|
894
|
+
}}</For2>
|
|
895
|
+
</Block_wrapper_default></Show5></Show5>
|
|
896
896
|
</Show5>;
|
|
897
897
|
}
|
|
898
898
|
var Block_default = Block;
|
|
899
899
|
|
|
900
900
|
// src/components/blocks/blocks-wrapper.tsx
|
|
901
901
|
import { Dynamic as Dynamic4 } from "solid-js/web";
|
|
902
|
-
import { css
|
|
902
|
+
import { css } from "solid-styled-components";
|
|
903
903
|
function BlocksWrapper(props) {
|
|
904
904
|
function className() {
|
|
905
905
|
return "builder-blocks" + (!props.blocks?.length ? " no-blocks" : "");
|
|
@@ -933,7 +933,7 @@ function BlocksWrapper(props) {
|
|
|
933
933
|
}
|
|
934
934
|
}
|
|
935
935
|
return <Dynamic4
|
|
936
|
-
class={className() + " " +
|
|
936
|
+
class={className() + " " + css({
|
|
937
937
|
display: "flex",
|
|
938
938
|
flexDirection: "column",
|
|
939
939
|
alignItems: "stretch"
|
|
@@ -1074,7 +1074,7 @@ function Columns(props) {
|
|
|
1074
1074
|
`;
|
|
1075
1075
|
}
|
|
1076
1076
|
return <div
|
|
1077
|
-
class={`builder-columns ${props.builderBlock.id}-breakpoints ` +
|
|
1077
|
+
class={`builder-columns ${props.builderBlock.id}-breakpoints ` + css2({
|
|
1078
1078
|
display: "flex",
|
|
1079
1079
|
lineHeight: "normal"
|
|
1080
1080
|
})}
|
|
@@ -1085,7 +1085,7 @@ function Columns(props) {
|
|
|
1085
1085
|
<For4 each={props.columns}>{(column, _index) => {
|
|
1086
1086
|
const index = _index();
|
|
1087
1087
|
return <div
|
|
1088
|
-
class={"builder-column " +
|
|
1088
|
+
class={"builder-column " + css2({
|
|
1089
1089
|
display: "flex",
|
|
1090
1090
|
flexDirection: "column",
|
|
1091
1091
|
alignItems: "stretch"
|
|
@@ -1116,7 +1116,7 @@ var fragment_default = FragmentComponent;
|
|
|
1116
1116
|
|
|
1117
1117
|
// src/blocks/image/image.tsx
|
|
1118
1118
|
import { Show as Show8 } from "solid-js";
|
|
1119
|
-
import { css as
|
|
1119
|
+
import { css as css3 } from "solid-styled-components";
|
|
1120
1120
|
|
|
1121
1121
|
// src/blocks/image/image.helpers.ts
|
|
1122
1122
|
function removeProtocol(path) {
|
|
@@ -1206,7 +1206,7 @@ function Image(props) {
|
|
|
1206
1206
|
<picture>
|
|
1207
1207
|
<Show8 when={webpSrcSet()}><source type="image/webp" srcset={webpSrcSet()} /></Show8>
|
|
1208
1208
|
<img
|
|
1209
|
-
class={"builder-image" + (props.className ? " " + props.className : "") + " " +
|
|
1209
|
+
class={"builder-image" + (props.className ? " " + props.className : "") + " " + css3({
|
|
1210
1210
|
opacity: "1",
|
|
1211
1211
|
transition: "opacity 0.2s ease-in-out"
|
|
1212
1212
|
})}
|
|
@@ -1226,7 +1226,7 @@ function Image(props) {
|
|
|
1226
1226
|
<Show8
|
|
1227
1227
|
when={props.aspectRatio && !(props.builderBlock?.children?.length && props.fitContent)}
|
|
1228
1228
|
><div
|
|
1229
|
-
class={"builder-image-sizer " +
|
|
1229
|
+
class={"builder-image-sizer " + css3({
|
|
1230
1230
|
width: "100%",
|
|
1231
1231
|
pointerEvents: "none",
|
|
1232
1232
|
fontSize: "0"
|
|
@@ -1237,7 +1237,7 @@ function Image(props) {
|
|
|
1237
1237
|
/></Show8>
|
|
1238
1238
|
<Show8 when={props.builderBlock?.children?.length && props.fitContent}>{props.children}</Show8>
|
|
1239
1239
|
<Show8 when={!props.fitContent && props.children}><div
|
|
1240
|
-
class={
|
|
1240
|
+
class={css3({
|
|
1241
1241
|
display: "flex",
|
|
1242
1242
|
flexDirection: "column",
|
|
1243
1243
|
alignItems: "stretch",
|
|
@@ -2713,6 +2713,13 @@ async function fetchEntries(options) {
|
|
|
2713
2713
|
}
|
|
2714
2714
|
var getAllContent = fetchEntries;
|
|
2715
2715
|
|
|
2716
|
+
// src/functions/is-from-trusted-host.ts
|
|
2717
|
+
var DEFAULT_TRUSTED_HOSTS = ["*.beta.builder.io", "beta.builder.io", "builder.io", "localhost", "qa.builder.io"];
|
|
2718
|
+
function isFromTrustedHost(trustedHosts, e) {
|
|
2719
|
+
const url = new URL(e.origin), hostname = url.hostname;
|
|
2720
|
+
return (trustedHosts || DEFAULT_TRUSTED_HOSTS).findIndex((trustedHost) => trustedHost.startsWith("*.") ? hostname.endsWith(trustedHost.slice(1)) : trustedHost === hostname) > -1;
|
|
2721
|
+
}
|
|
2722
|
+
|
|
2716
2723
|
// src/functions/is-previewing.ts
|
|
2717
2724
|
function isPreviewing() {
|
|
2718
2725
|
if (!isBrowser()) {
|
|
@@ -2961,7 +2968,7 @@ var getInteractionPropertiesForEvent = (event) => {
|
|
|
2961
2968
|
};
|
|
2962
2969
|
|
|
2963
2970
|
// src/constants/sdk-version.ts
|
|
2964
|
-
var SDK_VERSION = "0.12.
|
|
2971
|
+
var SDK_VERSION = "0.12.3";
|
|
2965
2972
|
|
|
2966
2973
|
// src/functions/register.ts
|
|
2967
2974
|
var registry = {};
|
|
@@ -3038,9 +3045,13 @@ var setupBrowserForEditing = (options = {}) => {
|
|
|
3038
3045
|
options
|
|
3039
3046
|
}
|
|
3040
3047
|
}, "*");
|
|
3041
|
-
window.addEventListener("message", ({
|
|
3042
|
-
|
|
3043
|
-
|
|
3048
|
+
window.addEventListener("message", (event) => {
|
|
3049
|
+
if (!isFromTrustedHost(options.trustedHosts, event)) {
|
|
3050
|
+
return;
|
|
3051
|
+
}
|
|
3052
|
+
const {
|
|
3053
|
+
data
|
|
3054
|
+
} = event;
|
|
3044
3055
|
if (!data?.type) {
|
|
3045
3056
|
return;
|
|
3046
3057
|
}
|
|
@@ -3138,6 +3149,9 @@ function EnableEditor(props) {
|
|
|
3138
3149
|
}));
|
|
3139
3150
|
}
|
|
3140
3151
|
function processMessage(event) {
|
|
3152
|
+
if (!isFromTrustedHost(props.trustedHosts, event)) {
|
|
3153
|
+
return;
|
|
3154
|
+
}
|
|
3141
3155
|
const { data } = event;
|
|
3142
3156
|
if (data) {
|
|
3143
3157
|
switch (data.type) {
|
|
@@ -3268,6 +3282,9 @@ function EnableEditor(props) {
|
|
|
3268
3282
|
} : {},
|
|
3269
3283
|
...props.enrich ? {
|
|
3270
3284
|
enrich: props.enrich
|
|
3285
|
+
} : {},
|
|
3286
|
+
...props.trustedHosts ? {
|
|
3287
|
+
trustedHosts: props.trustedHosts
|
|
3271
3288
|
} : {}
|
|
3272
3289
|
});
|
|
3273
3290
|
Object.values(
|
|
@@ -3462,6 +3479,10 @@ ${getFontCss({
|
|
|
3462
3479
|
customFonts: props.customFonts
|
|
3463
3480
|
})}
|
|
3464
3481
|
|
|
3482
|
+
.builder-button {
|
|
3483
|
+
all: unset;
|
|
3484
|
+
}
|
|
3485
|
+
|
|
3465
3486
|
.builder-text > p:first-of-type, .builder-text > .builder-paragraph:first-of-type {
|
|
3466
3487
|
margin: 0;
|
|
3467
3488
|
}
|
|
@@ -3606,6 +3627,7 @@ function ContentComponent(props) {
|
|
|
3606
3627
|
builderContextSignal={builderContextSignal()}
|
|
3607
3628
|
contentWrapper={props.contentWrapper}
|
|
3608
3629
|
contentWrapperProps={props.contentWrapperProps}
|
|
3630
|
+
trustedHosts={props.trustedHosts}
|
|
3609
3631
|
{...{
|
|
3610
3632
|
setBuilderContextSignal
|
|
3611
3633
|
}}
|
|
@@ -3688,6 +3710,7 @@ function ContentVariants(props) {
|
|
|
3688
3710
|
blocksWrapperProps={props.blocksWrapperProps}
|
|
3689
3711
|
contentWrapper={props.contentWrapper}
|
|
3690
3712
|
contentWrapperProps={props.contentWrapperProps}
|
|
3713
|
+
trustedHosts={props.trustedHosts}
|
|
3691
3714
|
/>;
|
|
3692
3715
|
}}</For5>
|
|
3693
3716
|
</Show12>
|
|
@@ -3710,6 +3733,7 @@ function ContentVariants(props) {
|
|
|
3710
3733
|
blocksWrapperProps={props.blocksWrapperProps}
|
|
3711
3734
|
contentWrapper={props.contentWrapper}
|
|
3712
3735
|
contentWrapperProps={props.contentWrapperProps}
|
|
3736
|
+
trustedHosts={props.trustedHosts}
|
|
3713
3737
|
/>
|
|
3714
3738
|
</>;
|
|
3715
3739
|
}
|