@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/node/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";
|
|
@@ -451,10 +449,6 @@ function getProcessedBlock({
|
|
|
451
449
|
}
|
|
452
450
|
|
|
453
451
|
// src/components/block/block.helpers.ts
|
|
454
|
-
var EMPTY_HTML_ELEMENTS = ["area", "base", "br", "col", "embed", "hr", "img", "input", "keygen", "link", "meta", "param", "source", "track", "wbr"];
|
|
455
|
-
var isEmptyHtmlElement = (tagName) => {
|
|
456
|
-
return typeof tagName === "string" && EMPTY_HTML_ELEMENTS.includes(tagName.toLowerCase());
|
|
457
|
-
};
|
|
458
452
|
var getComponent = ({
|
|
459
453
|
block,
|
|
460
454
|
context,
|
|
@@ -632,7 +626,7 @@ function BlockStyles(props) {
|
|
|
632
626
|
}
|
|
633
627
|
return true;
|
|
634
628
|
}
|
|
635
|
-
function
|
|
629
|
+
function css4() {
|
|
636
630
|
const processedBlock = getProcessedBlock({
|
|
637
631
|
block: props.block,
|
|
638
632
|
localState: props.context.localState,
|
|
@@ -675,14 +669,10 @@ function BlockStyles(props) {
|
|
|
675
669
|
}) : "";
|
|
676
670
|
return [largeStylesClass, mediumStylesClass, smallStylesClass].join(" ");
|
|
677
671
|
}
|
|
678
|
-
return <Show2 when={TARGET !== "reactNative" &&
|
|
672
|
+
return <Show2 when={TARGET !== "reactNative" && css4() && canShowBlock()}><Inlined_styles_default styles={css4()} /></Show2>;
|
|
679
673
|
}
|
|
680
674
|
var Block_styles_default = BlockStyles;
|
|
681
675
|
|
|
682
|
-
// src/components/block/components/block-wrapper.tsx
|
|
683
|
-
import { Show as Show3 } from "solid-js";
|
|
684
|
-
import { Dynamic } from "solid-js/web";
|
|
685
|
-
|
|
686
676
|
// src/functions/event-handler-name.ts
|
|
687
677
|
function capitalizeFirstLetter(string) {
|
|
688
678
|
return string.charAt(0).toUpperCase() + string.slice(1);
|
|
@@ -769,31 +759,49 @@ function getStyleAttribute(style) {
|
|
|
769
759
|
}
|
|
770
760
|
}
|
|
771
761
|
|
|
772
|
-
// src/components/
|
|
773
|
-
|
|
762
|
+
// src/components/dynamic-renderer/dynamic-renderer.tsx
|
|
763
|
+
import { Show as Show3 } from "solid-js";
|
|
764
|
+
import { Dynamic } from "solid-js/web";
|
|
765
|
+
|
|
766
|
+
// src/components/dynamic-renderer/dynamic-renderer.helpers.ts
|
|
767
|
+
var EMPTY_HTML_ELEMENTS = /* @__PURE__ */ new Set(["area", "base", "br", "col", "embed", "hr", "img", "input", "keygen", "link", "meta", "param", "source", "track", "wbr"]);
|
|
768
|
+
var isEmptyElement = (tagName) => {
|
|
769
|
+
return typeof tagName === "string" && EMPTY_HTML_ELEMENTS.has(tagName.toLowerCase());
|
|
770
|
+
};
|
|
771
|
+
|
|
772
|
+
// src/components/dynamic-renderer/dynamic-renderer.tsx
|
|
773
|
+
function DynamicRenderer(props) {
|
|
774
774
|
return <Show3
|
|
775
775
|
fallback={<Dynamic
|
|
776
|
-
{...
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
})}
|
|
780
|
-
{...getBlockActions({
|
|
781
|
-
block: props.block,
|
|
782
|
-
rootState: props.context.rootState,
|
|
783
|
-
rootSetState: props.context.rootSetState,
|
|
784
|
-
localState: props.context.localState,
|
|
785
|
-
context: props.context.context,
|
|
786
|
-
stripPrefix: true
|
|
787
|
-
})}
|
|
788
|
-
component={props.Wrapper}
|
|
776
|
+
{...props.attributes}
|
|
777
|
+
{...props.actionAttributes}
|
|
778
|
+
component={props.TagName}
|
|
789
779
|
/>}
|
|
790
|
-
when={props.
|
|
780
|
+
when={!isEmptyElement(props.TagName)}
|
|
781
|
+
><Show3
|
|
782
|
+
fallback={<Dynamic
|
|
783
|
+
{...props.attributes}
|
|
784
|
+
{...props.actionAttributes}
|
|
785
|
+
component={props.TagName}
|
|
786
|
+
>{props.children}</Dynamic>}
|
|
787
|
+
when={typeof props.TagName === "string"}
|
|
791
788
|
><Dynamic
|
|
792
|
-
{...
|
|
789
|
+
{...props.attributes}
|
|
790
|
+
{...props.actionAttributes}
|
|
791
|
+
component={props.TagName}
|
|
792
|
+
>{props.children}</Dynamic></Show3></Show3>;
|
|
793
|
+
}
|
|
794
|
+
var Dynamic_renderer_default = DynamicRenderer;
|
|
795
|
+
|
|
796
|
+
// src/components/block/components/block-wrapper.tsx
|
|
797
|
+
function BlockWrapper(props) {
|
|
798
|
+
return <Dynamic_renderer_default
|
|
799
|
+
TagName={props.Wrapper}
|
|
800
|
+
attributes={getBlockProperties({
|
|
793
801
|
block: props.block,
|
|
794
802
|
context: props.context
|
|
795
803
|
})}
|
|
796
|
-
{
|
|
804
|
+
actionAttributes={getBlockActions({
|
|
797
805
|
block: props.block,
|
|
798
806
|
rootState: props.context.rootState,
|
|
799
807
|
rootSetState: props.context.rootSetState,
|
|
@@ -801,8 +809,7 @@ function BlockWrapper(props) {
|
|
|
801
809
|
context: props.context.context,
|
|
802
810
|
stripPrefix: true
|
|
803
811
|
})}
|
|
804
|
-
|
|
805
|
-
>{props.children}</Dynamic></Show3>;
|
|
812
|
+
>{props.children}</Dynamic_renderer_default>;
|
|
806
813
|
}
|
|
807
814
|
var Block_wrapper_default = BlockWrapper;
|
|
808
815
|
|
|
@@ -981,14 +988,8 @@ function Block(props) {
|
|
|
981
988
|
isInteractive={componentRefProps().isInteractive}
|
|
982
989
|
/>}
|
|
983
990
|
when={!blockComponent()?.noWrap}
|
|
984
|
-
|
|
985
|
-
<
|
|
986
|
-
Wrapper={Tag()}
|
|
987
|
-
block={processedBlock()}
|
|
988
|
-
context={props.context}
|
|
989
|
-
hasChildren={false}
|
|
990
|
-
/></Show5>
|
|
991
|
-
<Show5 when={!isEmptyHtmlElement(Tag()) && repeatItem()}><For2 each={repeatItem()}>{(data, _index) => {
|
|
991
|
+
><Show5
|
|
992
|
+
fallback={<For2 each={repeatItem()}>{(data, _index) => {
|
|
992
993
|
const index = _index();
|
|
993
994
|
return <Repeated_block_default
|
|
994
995
|
key={index}
|
|
@@ -996,41 +997,40 @@ function Block(props) {
|
|
|
996
997
|
block={data.block}
|
|
997
998
|
registeredComponents={props.registeredComponents}
|
|
998
999
|
/>;
|
|
999
|
-
}}</For2
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
</Show5>
|
|
1000
|
+
}}</For2>}
|
|
1001
|
+
when={!repeatItem()}
|
|
1002
|
+
><Block_wrapper_default
|
|
1003
|
+
Wrapper={Tag()}
|
|
1004
|
+
block={processedBlock()}
|
|
1005
|
+
context={props.context}
|
|
1006
|
+
>
|
|
1007
|
+
<Component_ref_default
|
|
1008
|
+
componentRef={componentRefProps().componentRef}
|
|
1009
|
+
componentOptions={componentRefProps().componentOptions}
|
|
1010
|
+
blockChildren={componentRefProps().blockChildren}
|
|
1011
|
+
context={componentRefProps().context}
|
|
1012
|
+
registeredComponents={componentRefProps().registeredComponents}
|
|
1013
|
+
builderBlock={componentRefProps().builderBlock}
|
|
1014
|
+
includeBlockProps={componentRefProps().includeBlockProps}
|
|
1015
|
+
isInteractive={componentRefProps().isInteractive}
|
|
1016
|
+
/>
|
|
1017
|
+
<For2 each={childrenWithoutParentComponent()}>{(child, _index) => {
|
|
1018
|
+
const index = _index();
|
|
1019
|
+
return <Block
|
|
1020
|
+
key={child.id}
|
|
1021
|
+
block={child}
|
|
1022
|
+
context={childrenContext()}
|
|
1023
|
+
registeredComponents={props.registeredComponents}
|
|
1024
|
+
/>;
|
|
1025
|
+
}}</For2>
|
|
1026
|
+
</Block_wrapper_default></Show5></Show5>
|
|
1027
1027
|
</Show5>;
|
|
1028
1028
|
}
|
|
1029
1029
|
var Block_default = Block;
|
|
1030
1030
|
|
|
1031
1031
|
// src/components/blocks/blocks-wrapper.tsx
|
|
1032
1032
|
import { Dynamic as Dynamic4 } from "solid-js/web";
|
|
1033
|
-
import { css
|
|
1033
|
+
import { css } from "solid-styled-components";
|
|
1034
1034
|
function BlocksWrapper(props) {
|
|
1035
1035
|
function className() {
|
|
1036
1036
|
return "builder-blocks" + (!props.blocks?.length ? " no-blocks" : "");
|
|
@@ -1064,7 +1064,7 @@ function BlocksWrapper(props) {
|
|
|
1064
1064
|
}
|
|
1065
1065
|
}
|
|
1066
1066
|
return <Dynamic4
|
|
1067
|
-
class={className() + " " +
|
|
1067
|
+
class={className() + " " + css({
|
|
1068
1068
|
display: "flex",
|
|
1069
1069
|
flexDirection: "column",
|
|
1070
1070
|
alignItems: "stretch"
|
|
@@ -1205,7 +1205,7 @@ function Columns(props) {
|
|
|
1205
1205
|
`;
|
|
1206
1206
|
}
|
|
1207
1207
|
return <div
|
|
1208
|
-
class={`builder-columns ${props.builderBlock.id}-breakpoints ` +
|
|
1208
|
+
class={`builder-columns ${props.builderBlock.id}-breakpoints ` + css2({
|
|
1209
1209
|
display: "flex",
|
|
1210
1210
|
lineHeight: "normal"
|
|
1211
1211
|
})}
|
|
@@ -1216,7 +1216,7 @@ function Columns(props) {
|
|
|
1216
1216
|
<For4 each={props.columns}>{(column, _index) => {
|
|
1217
1217
|
const index = _index();
|
|
1218
1218
|
return <div
|
|
1219
|
-
class={"builder-column " +
|
|
1219
|
+
class={"builder-column " + css2({
|
|
1220
1220
|
display: "flex",
|
|
1221
1221
|
flexDirection: "column",
|
|
1222
1222
|
alignItems: "stretch"
|
|
@@ -1247,7 +1247,7 @@ var fragment_default = FragmentComponent;
|
|
|
1247
1247
|
|
|
1248
1248
|
// src/blocks/image/image.tsx
|
|
1249
1249
|
import { Show as Show8 } from "solid-js";
|
|
1250
|
-
import { css as
|
|
1250
|
+
import { css as css3 } from "solid-styled-components";
|
|
1251
1251
|
|
|
1252
1252
|
// src/blocks/image/image.helpers.ts
|
|
1253
1253
|
function removeProtocol(path) {
|
|
@@ -1338,7 +1338,7 @@ function Image(props) {
|
|
|
1338
1338
|
<picture>
|
|
1339
1339
|
<Show8 when={webpSrcSet()}><source type="image/webp" srcset={webpSrcSet()} /></Show8>
|
|
1340
1340
|
<img
|
|
1341
|
-
class={"builder-image" + (props.className ? " " + props.className : "") + " " +
|
|
1341
|
+
class={"builder-image" + (props.className ? " " + props.className : "") + " " + css3({
|
|
1342
1342
|
opacity: "1",
|
|
1343
1343
|
transition: "opacity 0.2s ease-in-out"
|
|
1344
1344
|
})}
|
|
@@ -1358,7 +1358,7 @@ function Image(props) {
|
|
|
1358
1358
|
<Show8
|
|
1359
1359
|
when={props.aspectRatio && !(props.builderBlock?.children?.length && props.fitContent)}
|
|
1360
1360
|
><div
|
|
1361
|
-
class={"builder-image-sizer " +
|
|
1361
|
+
class={"builder-image-sizer " + css3({
|
|
1362
1362
|
width: "100%",
|
|
1363
1363
|
pointerEvents: "none",
|
|
1364
1364
|
fontSize: "0"
|
|
@@ -1369,7 +1369,7 @@ function Image(props) {
|
|
|
1369
1369
|
/></Show8>
|
|
1370
1370
|
<Show8 when={props.builderBlock?.children?.length && props.fitContent}>{props.children}</Show8>
|
|
1371
1371
|
<Show8 when={!props.fitContent && props.children}><div
|
|
1372
|
-
class={
|
|
1372
|
+
class={css3({
|
|
1373
1373
|
display: "flex",
|
|
1374
1374
|
flexDirection: "column",
|
|
1375
1375
|
alignItems: "stretch",
|
|
@@ -2850,6 +2850,13 @@ async function fetchEntries(options) {
|
|
|
2850
2850
|
}
|
|
2851
2851
|
var getAllContent = fetchEntries;
|
|
2852
2852
|
|
|
2853
|
+
// src/functions/is-from-trusted-host.ts
|
|
2854
|
+
var DEFAULT_TRUSTED_HOSTS = ["*.beta.builder.io", "beta.builder.io", "builder.io", "localhost", "qa.builder.io"];
|
|
2855
|
+
function isFromTrustedHost(trustedHosts, e) {
|
|
2856
|
+
const url = new URL(e.origin), hostname = url.hostname;
|
|
2857
|
+
return (trustedHosts || DEFAULT_TRUSTED_HOSTS).findIndex((trustedHost) => trustedHost.startsWith("*.") ? hostname.endsWith(trustedHost.slice(1)) : trustedHost === hostname) > -1;
|
|
2858
|
+
}
|
|
2859
|
+
|
|
2853
2860
|
// src/functions/is-previewing.ts
|
|
2854
2861
|
function isPreviewing() {
|
|
2855
2862
|
if (!isBrowser()) {
|
|
@@ -3101,7 +3108,7 @@ var getInteractionPropertiesForEvent = (event) => {
|
|
|
3101
3108
|
};
|
|
3102
3109
|
|
|
3103
3110
|
// src/constants/sdk-version.ts
|
|
3104
|
-
var SDK_VERSION = "0.12.
|
|
3111
|
+
var SDK_VERSION = "0.12.3";
|
|
3105
3112
|
|
|
3106
3113
|
// src/functions/register.ts
|
|
3107
3114
|
var registry = {};
|
|
@@ -3179,9 +3186,13 @@ var setupBrowserForEditing = (options = {}) => {
|
|
|
3179
3186
|
options
|
|
3180
3187
|
}
|
|
3181
3188
|
}, "*");
|
|
3182
|
-
window.addEventListener("message", ({
|
|
3183
|
-
|
|
3184
|
-
|
|
3189
|
+
window.addEventListener("message", (event) => {
|
|
3190
|
+
if (!isFromTrustedHost(options.trustedHosts, event)) {
|
|
3191
|
+
return;
|
|
3192
|
+
}
|
|
3193
|
+
const {
|
|
3194
|
+
data
|
|
3195
|
+
} = event;
|
|
3185
3196
|
if (!data?.type) {
|
|
3186
3197
|
return;
|
|
3187
3198
|
}
|
|
@@ -3279,6 +3290,9 @@ function EnableEditor(props) {
|
|
|
3279
3290
|
}));
|
|
3280
3291
|
}
|
|
3281
3292
|
function processMessage(event) {
|
|
3293
|
+
if (!isFromTrustedHost(props.trustedHosts, event)) {
|
|
3294
|
+
return;
|
|
3295
|
+
}
|
|
3282
3296
|
const { data } = event;
|
|
3283
3297
|
if (data) {
|
|
3284
3298
|
switch (data.type) {
|
|
@@ -3410,6 +3424,9 @@ function EnableEditor(props) {
|
|
|
3410
3424
|
} : {},
|
|
3411
3425
|
...props.enrich ? {
|
|
3412
3426
|
enrich: props.enrich
|
|
3427
|
+
} : {},
|
|
3428
|
+
...props.trustedHosts ? {
|
|
3429
|
+
trustedHosts: props.trustedHosts
|
|
3413
3430
|
} : {}
|
|
3414
3431
|
});
|
|
3415
3432
|
Object.values(
|
|
@@ -3604,6 +3621,10 @@ ${getFontCss({
|
|
|
3604
3621
|
customFonts: props.customFonts
|
|
3605
3622
|
})}
|
|
3606
3623
|
|
|
3624
|
+
.builder-button {
|
|
3625
|
+
all: unset;
|
|
3626
|
+
}
|
|
3627
|
+
|
|
3607
3628
|
.builder-text > p:first-of-type, .builder-text > .builder-paragraph:first-of-type {
|
|
3608
3629
|
margin: 0;
|
|
3609
3630
|
}
|
|
@@ -3748,6 +3769,7 @@ function ContentComponent(props) {
|
|
|
3748
3769
|
builderContextSignal={builderContextSignal()}
|
|
3749
3770
|
contentWrapper={props.contentWrapper}
|
|
3750
3771
|
contentWrapperProps={props.contentWrapperProps}
|
|
3772
|
+
trustedHosts={props.trustedHosts}
|
|
3751
3773
|
{...{
|
|
3752
3774
|
setBuilderContextSignal
|
|
3753
3775
|
}}
|
|
@@ -3830,6 +3852,7 @@ function ContentVariants(props) {
|
|
|
3830
3852
|
blocksWrapperProps={props.blocksWrapperProps}
|
|
3831
3853
|
contentWrapper={props.contentWrapper}
|
|
3832
3854
|
contentWrapperProps={props.contentWrapperProps}
|
|
3855
|
+
trustedHosts={props.trustedHosts}
|
|
3833
3856
|
/>;
|
|
3834
3857
|
}}</For5>
|
|
3835
3858
|
</Show12>
|
|
@@ -3852,6 +3875,7 @@ function ContentVariants(props) {
|
|
|
3852
3875
|
blocksWrapperProps={props.blocksWrapperProps}
|
|
3853
3876
|
contentWrapper={props.contentWrapper}
|
|
3854
3877
|
contentWrapperProps={props.contentWrapperProps}
|
|
3878
|
+
trustedHosts={props.trustedHosts}
|
|
3855
3879
|
/>
|
|
3856
3880
|
</>;
|
|
3857
3881
|
}
|