@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/index.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { createComponent, spread, mergeProps, insert, effect, setAttribute, className, style, template,
|
|
1
|
+
import { createComponent, spread, mergeProps, insert, effect, setAttribute, className, style, template, Dynamic, memo, use } from 'solid-js/web';
|
|
2
2
|
import { createContext, Show, useContext, For, createSignal, onMount, createEffect, on } from 'solid-js';
|
|
3
3
|
import { css } from 'solid-styled-components';
|
|
4
4
|
import { createRequire } from 'node:module';
|
|
5
5
|
|
|
6
6
|
// src/blocks/button/button.tsx
|
|
7
7
|
var _tmpl$ = /* @__PURE__ */ template(`<a>`);
|
|
8
|
-
var _tmpl$2 = /* @__PURE__ */ template(`<button>`);
|
|
8
|
+
var _tmpl$2 = /* @__PURE__ */ template(`<button role=button>`);
|
|
9
9
|
function Button(props) {
|
|
10
10
|
return createComponent(Show, {
|
|
11
11
|
get fallback() {
|
|
@@ -13,9 +13,7 @@ function Button(props) {
|
|
|
13
13
|
const _el$2 = _tmpl$2();
|
|
14
14
|
spread(_el$2, mergeProps({
|
|
15
15
|
get ["class"]() {
|
|
16
|
-
return props.attributes.class
|
|
17
|
-
all: "unset"
|
|
18
|
-
});
|
|
16
|
+
return `builder-button ${props.attributes.class}`;
|
|
19
17
|
}
|
|
20
18
|
}, {}, () => props.attributes, {
|
|
21
19
|
get style() {
|
|
@@ -454,10 +452,6 @@ function getProcessedBlock({
|
|
|
454
452
|
}
|
|
455
453
|
|
|
456
454
|
// src/components/block/block.helpers.ts
|
|
457
|
-
var EMPTY_HTML_ELEMENTS = ["area", "base", "br", "col", "embed", "hr", "img", "input", "keygen", "link", "meta", "param", "source", "track", "wbr"];
|
|
458
|
-
var isEmptyHtmlElement = (tagName) => {
|
|
459
|
-
return typeof tagName === "string" && EMPTY_HTML_ELEMENTS.includes(tagName.toLowerCase());
|
|
460
|
-
};
|
|
461
455
|
var getComponent = ({
|
|
462
456
|
block,
|
|
463
457
|
context,
|
|
@@ -640,7 +634,7 @@ function BlockStyles(props) {
|
|
|
640
634
|
}
|
|
641
635
|
return true;
|
|
642
636
|
}
|
|
643
|
-
function
|
|
637
|
+
function css4() {
|
|
644
638
|
const processedBlock = getProcessedBlock({
|
|
645
639
|
block: props.block,
|
|
646
640
|
localState: props.context.localState,
|
|
@@ -677,12 +671,12 @@ function BlockStyles(props) {
|
|
|
677
671
|
}
|
|
678
672
|
return createComponent(Show, {
|
|
679
673
|
get when() {
|
|
680
|
-
return memo(() => !!(TARGET !== "reactNative" &&
|
|
674
|
+
return memo(() => !!(TARGET !== "reactNative" && css4()))() && canShowBlock();
|
|
681
675
|
},
|
|
682
676
|
get children() {
|
|
683
677
|
return createComponent(inlined_styles_default, {
|
|
684
678
|
get styles() {
|
|
685
|
-
return
|
|
679
|
+
return css4();
|
|
686
680
|
}
|
|
687
681
|
});
|
|
688
682
|
}
|
|
@@ -776,48 +770,80 @@ function getStyleAttribute(style) {
|
|
|
776
770
|
}
|
|
777
771
|
}
|
|
778
772
|
|
|
779
|
-
// src/components/
|
|
780
|
-
|
|
773
|
+
// src/components/dynamic-renderer/dynamic-renderer.helpers.ts
|
|
774
|
+
var EMPTY_HTML_ELEMENTS = /* @__PURE__ */ new Set(["area", "base", "br", "col", "embed", "hr", "img", "input", "keygen", "link", "meta", "param", "source", "track", "wbr"]);
|
|
775
|
+
var isEmptyElement = (tagName) => {
|
|
776
|
+
return typeof tagName === "string" && EMPTY_HTML_ELEMENTS.has(tagName.toLowerCase());
|
|
777
|
+
};
|
|
778
|
+
|
|
779
|
+
// src/components/dynamic-renderer/dynamic-renderer.tsx
|
|
780
|
+
function DynamicRenderer(props) {
|
|
781
781
|
return createComponent(Show, {
|
|
782
782
|
get fallback() {
|
|
783
|
-
return createComponent(Dynamic, mergeProps(() =>
|
|
784
|
-
block: props.block,
|
|
785
|
-
context: props.context
|
|
786
|
-
}), () => getBlockActions({
|
|
787
|
-
block: props.block,
|
|
788
|
-
rootState: props.context.rootState,
|
|
789
|
-
rootSetState: props.context.rootSetState,
|
|
790
|
-
localState: props.context.localState,
|
|
791
|
-
context: props.context.context,
|
|
792
|
-
stripPrefix: true
|
|
793
|
-
}), {
|
|
783
|
+
return createComponent(Dynamic, mergeProps(() => props.attributes, () => props.actionAttributes, {
|
|
794
784
|
get component() {
|
|
795
|
-
return props.
|
|
785
|
+
return props.TagName;
|
|
796
786
|
}
|
|
797
787
|
}));
|
|
798
788
|
},
|
|
799
789
|
get when() {
|
|
800
|
-
return props.
|
|
790
|
+
return !isEmptyElement(props.TagName);
|
|
801
791
|
},
|
|
802
792
|
get children() {
|
|
803
|
-
return createComponent(
|
|
793
|
+
return createComponent(Show, {
|
|
794
|
+
get fallback() {
|
|
795
|
+
return createComponent(Dynamic, mergeProps(() => props.attributes, () => props.actionAttributes, {
|
|
796
|
+
get component() {
|
|
797
|
+
return props.TagName;
|
|
798
|
+
},
|
|
799
|
+
get children() {
|
|
800
|
+
return props.children;
|
|
801
|
+
}
|
|
802
|
+
}));
|
|
803
|
+
},
|
|
804
|
+
get when() {
|
|
805
|
+
return typeof props.TagName === "string";
|
|
806
|
+
},
|
|
807
|
+
get children() {
|
|
808
|
+
return createComponent(Dynamic, mergeProps(() => props.attributes, () => props.actionAttributes, {
|
|
809
|
+
get component() {
|
|
810
|
+
return props.TagName;
|
|
811
|
+
},
|
|
812
|
+
get children() {
|
|
813
|
+
return props.children;
|
|
814
|
+
}
|
|
815
|
+
}));
|
|
816
|
+
}
|
|
817
|
+
});
|
|
818
|
+
}
|
|
819
|
+
});
|
|
820
|
+
}
|
|
821
|
+
var dynamic_renderer_default = DynamicRenderer;
|
|
822
|
+
|
|
823
|
+
// src/components/block/components/block-wrapper.tsx
|
|
824
|
+
function BlockWrapper(props) {
|
|
825
|
+
return createComponent(dynamic_renderer_default, {
|
|
826
|
+
get TagName() {
|
|
827
|
+
return props.Wrapper;
|
|
828
|
+
},
|
|
829
|
+
get attributes() {
|
|
830
|
+
return getBlockProperties({
|
|
804
831
|
block: props.block,
|
|
805
832
|
context: props.context
|
|
806
|
-
})
|
|
833
|
+
});
|
|
834
|
+
},
|
|
835
|
+
get actionAttributes() {
|
|
836
|
+
return getBlockActions({
|
|
807
837
|
block: props.block,
|
|
808
838
|
rootState: props.context.rootState,
|
|
809
839
|
rootSetState: props.context.rootSetState,
|
|
810
840
|
localState: props.context.localState,
|
|
811
841
|
context: props.context.context,
|
|
812
842
|
stripPrefix: true
|
|
813
|
-
})
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
get children() {
|
|
818
|
-
return props.children;
|
|
819
|
-
}
|
|
820
|
-
}));
|
|
843
|
+
});
|
|
844
|
+
},
|
|
845
|
+
get children() {
|
|
846
|
+
return props.children;
|
|
821
847
|
}
|
|
822
848
|
});
|
|
823
849
|
}
|
|
@@ -1058,29 +1084,8 @@ function Block(props) {
|
|
|
1058
1084
|
return !blockComponent()?.noWrap;
|
|
1059
1085
|
},
|
|
1060
1086
|
get children() {
|
|
1061
|
-
return
|
|
1062
|
-
get
|
|
1063
|
-
return isEmptyHtmlElement(Tag());
|
|
1064
|
-
},
|
|
1065
|
-
get children() {
|
|
1066
|
-
return createComponent(block_wrapper_default, {
|
|
1067
|
-
get Wrapper() {
|
|
1068
|
-
return Tag();
|
|
1069
|
-
},
|
|
1070
|
-
get block() {
|
|
1071
|
-
return processedBlock();
|
|
1072
|
-
},
|
|
1073
|
-
get context() {
|
|
1074
|
-
return props.context;
|
|
1075
|
-
},
|
|
1076
|
-
hasChildren: false
|
|
1077
|
-
});
|
|
1078
|
-
}
|
|
1079
|
-
}), createComponent(Show, {
|
|
1080
|
-
get when() {
|
|
1081
|
-
return memo(() => !!!isEmptyHtmlElement(Tag()))() && repeatItem();
|
|
1082
|
-
},
|
|
1083
|
-
get children() {
|
|
1087
|
+
return createComponent(Show, {
|
|
1088
|
+
get fallback() {
|
|
1084
1089
|
return createComponent(For, {
|
|
1085
1090
|
get each() {
|
|
1086
1091
|
return repeatItem();
|
|
@@ -1101,10 +1106,9 @@ function Block(props) {
|
|
|
1101
1106
|
});
|
|
1102
1107
|
}
|
|
1103
1108
|
});
|
|
1104
|
-
}
|
|
1105
|
-
}), createComponent(Show, {
|
|
1109
|
+
},
|
|
1106
1110
|
get when() {
|
|
1107
|
-
return
|
|
1111
|
+
return !repeatItem();
|
|
1108
1112
|
},
|
|
1109
1113
|
get children() {
|
|
1110
1114
|
return createComponent(block_wrapper_default, {
|
|
@@ -1117,7 +1121,6 @@ function Block(props) {
|
|
|
1117
1121
|
get context() {
|
|
1118
1122
|
return props.context;
|
|
1119
1123
|
},
|
|
1120
|
-
hasChildren: true,
|
|
1121
1124
|
get children() {
|
|
1122
1125
|
return [createComponent(component_ref_default, {
|
|
1123
1126
|
get componentRef() {
|
|
@@ -1167,7 +1170,7 @@ function Block(props) {
|
|
|
1167
1170
|
}
|
|
1168
1171
|
});
|
|
1169
1172
|
}
|
|
1170
|
-
})
|
|
1173
|
+
});
|
|
1171
1174
|
}
|
|
1172
1175
|
})];
|
|
1173
1176
|
}
|
|
@@ -3156,6 +3159,13 @@ async function fetchEntries(options) {
|
|
|
3156
3159
|
}
|
|
3157
3160
|
var getAllContent = fetchEntries;
|
|
3158
3161
|
|
|
3162
|
+
// src/functions/is-from-trusted-host.ts
|
|
3163
|
+
var DEFAULT_TRUSTED_HOSTS = ["*.beta.builder.io", "beta.builder.io", "builder.io", "localhost", "qa.builder.io"];
|
|
3164
|
+
function isFromTrustedHost(trustedHosts, e) {
|
|
3165
|
+
const url = new URL(e.origin), hostname = url.hostname;
|
|
3166
|
+
return (trustedHosts || DEFAULT_TRUSTED_HOSTS).findIndex((trustedHost) => trustedHost.startsWith("*.") ? hostname.endsWith(trustedHost.slice(1)) : trustedHost === hostname) > -1;
|
|
3167
|
+
}
|
|
3168
|
+
|
|
3159
3169
|
// src/functions/is-previewing.ts
|
|
3160
3170
|
function isPreviewing() {
|
|
3161
3171
|
if (!isBrowser()) {
|
|
@@ -3404,7 +3414,7 @@ var getInteractionPropertiesForEvent = (event) => {
|
|
|
3404
3414
|
};
|
|
3405
3415
|
|
|
3406
3416
|
// src/constants/sdk-version.ts
|
|
3407
|
-
var SDK_VERSION = "0.12.
|
|
3417
|
+
var SDK_VERSION = "0.12.3";
|
|
3408
3418
|
|
|
3409
3419
|
// src/functions/register.ts
|
|
3410
3420
|
var registry = {};
|
|
@@ -3481,9 +3491,13 @@ var setupBrowserForEditing = (options = {}) => {
|
|
|
3481
3491
|
options
|
|
3482
3492
|
}
|
|
3483
3493
|
}, "*");
|
|
3484
|
-
window.addEventListener("message", ({
|
|
3485
|
-
|
|
3486
|
-
|
|
3494
|
+
window.addEventListener("message", (event) => {
|
|
3495
|
+
if (!isFromTrustedHost(options.trustedHosts, event)) {
|
|
3496
|
+
return;
|
|
3497
|
+
}
|
|
3498
|
+
const {
|
|
3499
|
+
data
|
|
3500
|
+
} = event;
|
|
3487
3501
|
if (!data?.type) {
|
|
3488
3502
|
return;
|
|
3489
3503
|
}
|
|
@@ -3579,6 +3593,9 @@ function EnableEditor(props) {
|
|
|
3579
3593
|
}));
|
|
3580
3594
|
}
|
|
3581
3595
|
function processMessage(event) {
|
|
3596
|
+
if (!isFromTrustedHost(props.trustedHosts, event)) {
|
|
3597
|
+
return;
|
|
3598
|
+
}
|
|
3582
3599
|
const {
|
|
3583
3600
|
data
|
|
3584
3601
|
} = event;
|
|
@@ -3709,6 +3726,9 @@ function EnableEditor(props) {
|
|
|
3709
3726
|
} : {},
|
|
3710
3727
|
...props.enrich ? {
|
|
3711
3728
|
enrich: props.enrich
|
|
3729
|
+
} : {},
|
|
3730
|
+
...props.trustedHosts ? {
|
|
3731
|
+
trustedHosts: props.trustedHosts
|
|
3712
3732
|
} : {}
|
|
3713
3733
|
});
|
|
3714
3734
|
Object.values(props.builderContextSignal.componentInfos).forEach((registeredComponent) => {
|
|
@@ -3905,6 +3925,10 @@ ${getFontCss({
|
|
|
3905
3925
|
customFonts: props.customFonts
|
|
3906
3926
|
})}
|
|
3907
3927
|
|
|
3928
|
+
.builder-button {
|
|
3929
|
+
all: unset;
|
|
3930
|
+
}
|
|
3931
|
+
|
|
3908
3932
|
.builder-text > p:first-of-type, .builder-text > .builder-paragraph:first-of-type {
|
|
3909
3933
|
margin: 0;
|
|
3910
3934
|
}
|
|
@@ -4076,6 +4100,9 @@ function ContentComponent(props) {
|
|
|
4076
4100
|
},
|
|
4077
4101
|
get contentWrapperProps() {
|
|
4078
4102
|
return props.contentWrapperProps;
|
|
4103
|
+
},
|
|
4104
|
+
get trustedHosts() {
|
|
4105
|
+
return props.trustedHosts;
|
|
4079
4106
|
}
|
|
4080
4107
|
}, {
|
|
4081
4108
|
setBuilderContextSignal
|
|
@@ -4235,6 +4262,9 @@ function ContentVariants(props) {
|
|
|
4235
4262
|
},
|
|
4236
4263
|
get contentWrapperProps() {
|
|
4237
4264
|
return props.contentWrapperProps;
|
|
4265
|
+
},
|
|
4266
|
+
get trustedHosts() {
|
|
4267
|
+
return props.trustedHosts;
|
|
4238
4268
|
}
|
|
4239
4269
|
});
|
|
4240
4270
|
}
|
|
@@ -4289,6 +4319,9 @@ function ContentVariants(props) {
|
|
|
4289
4319
|
},
|
|
4290
4320
|
get contentWrapperProps() {
|
|
4291
4321
|
return props.contentWrapperProps;
|
|
4322
|
+
},
|
|
4323
|
+
get trustedHosts() {
|
|
4324
|
+
return props.trustedHosts;
|
|
4292
4325
|
}
|
|
4293
4326
|
}))];
|
|
4294
4327
|
}
|