@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.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
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
|
|
|
5
5
|
// src/blocks/button/button.tsx
|
|
6
6
|
var _tmpl$ = /* @__PURE__ */ template(`<a>`);
|
|
7
|
-
var _tmpl$2 = /* @__PURE__ */ template(`<button>`);
|
|
7
|
+
var _tmpl$2 = /* @__PURE__ */ template(`<button role=button>`);
|
|
8
8
|
function Button(props) {
|
|
9
9
|
return createComponent(Show, {
|
|
10
10
|
get fallback() {
|
|
@@ -12,9 +12,7 @@ function Button(props) {
|
|
|
12
12
|
const _el$2 = _tmpl$2();
|
|
13
13
|
spread(_el$2, mergeProps({
|
|
14
14
|
get ["class"]() {
|
|
15
|
-
return props.attributes.class
|
|
16
|
-
all: "unset"
|
|
17
|
-
});
|
|
15
|
+
return `builder-button ${props.attributes.class}`;
|
|
18
16
|
}
|
|
19
17
|
}, {}, () => props.attributes, {
|
|
20
18
|
get style() {
|
|
@@ -331,10 +329,6 @@ function getProcessedBlock({
|
|
|
331
329
|
}
|
|
332
330
|
|
|
333
331
|
// src/components/block/block.helpers.ts
|
|
334
|
-
var EMPTY_HTML_ELEMENTS = ["area", "base", "br", "col", "embed", "hr", "img", "input", "keygen", "link", "meta", "param", "source", "track", "wbr"];
|
|
335
|
-
var isEmptyHtmlElement = (tagName) => {
|
|
336
|
-
return typeof tagName === "string" && EMPTY_HTML_ELEMENTS.includes(tagName.toLowerCase());
|
|
337
|
-
};
|
|
338
332
|
var getComponent = ({
|
|
339
333
|
block,
|
|
340
334
|
context,
|
|
@@ -517,7 +511,7 @@ function BlockStyles(props) {
|
|
|
517
511
|
}
|
|
518
512
|
return true;
|
|
519
513
|
}
|
|
520
|
-
function
|
|
514
|
+
function css4() {
|
|
521
515
|
const processedBlock = getProcessedBlock({
|
|
522
516
|
block: props.block,
|
|
523
517
|
localState: props.context.localState,
|
|
@@ -554,12 +548,12 @@ function BlockStyles(props) {
|
|
|
554
548
|
}
|
|
555
549
|
return createComponent(Show, {
|
|
556
550
|
get when() {
|
|
557
|
-
return memo(() => !!(TARGET !== "reactNative" &&
|
|
551
|
+
return memo(() => !!(TARGET !== "reactNative" && css4()))() && canShowBlock();
|
|
558
552
|
},
|
|
559
553
|
get children() {
|
|
560
554
|
return createComponent(inlined_styles_default, {
|
|
561
555
|
get styles() {
|
|
562
|
-
return
|
|
556
|
+
return css4();
|
|
563
557
|
}
|
|
564
558
|
});
|
|
565
559
|
}
|
|
@@ -653,48 +647,80 @@ function getStyleAttribute(style) {
|
|
|
653
647
|
}
|
|
654
648
|
}
|
|
655
649
|
|
|
656
|
-
// src/components/
|
|
657
|
-
|
|
650
|
+
// src/components/dynamic-renderer/dynamic-renderer.helpers.ts
|
|
651
|
+
var EMPTY_HTML_ELEMENTS = /* @__PURE__ */ new Set(["area", "base", "br", "col", "embed", "hr", "img", "input", "keygen", "link", "meta", "param", "source", "track", "wbr"]);
|
|
652
|
+
var isEmptyElement = (tagName) => {
|
|
653
|
+
return typeof tagName === "string" && EMPTY_HTML_ELEMENTS.has(tagName.toLowerCase());
|
|
654
|
+
};
|
|
655
|
+
|
|
656
|
+
// src/components/dynamic-renderer/dynamic-renderer.tsx
|
|
657
|
+
function DynamicRenderer(props) {
|
|
658
658
|
return createComponent(Show, {
|
|
659
659
|
get fallback() {
|
|
660
|
-
return createComponent(Dynamic, mergeProps(() =>
|
|
661
|
-
block: props.block,
|
|
662
|
-
context: props.context
|
|
663
|
-
}), () => getBlockActions({
|
|
664
|
-
block: props.block,
|
|
665
|
-
rootState: props.context.rootState,
|
|
666
|
-
rootSetState: props.context.rootSetState,
|
|
667
|
-
localState: props.context.localState,
|
|
668
|
-
context: props.context.context,
|
|
669
|
-
stripPrefix: true
|
|
670
|
-
}), {
|
|
660
|
+
return createComponent(Dynamic, mergeProps(() => props.attributes, () => props.actionAttributes, {
|
|
671
661
|
get component() {
|
|
672
|
-
return props.
|
|
662
|
+
return props.TagName;
|
|
673
663
|
}
|
|
674
664
|
}));
|
|
675
665
|
},
|
|
676
666
|
get when() {
|
|
677
|
-
return props.
|
|
667
|
+
return !isEmptyElement(props.TagName);
|
|
678
668
|
},
|
|
679
669
|
get children() {
|
|
680
|
-
return createComponent(
|
|
670
|
+
return createComponent(Show, {
|
|
671
|
+
get fallback() {
|
|
672
|
+
return createComponent(Dynamic, mergeProps(() => props.attributes, () => props.actionAttributes, {
|
|
673
|
+
get component() {
|
|
674
|
+
return props.TagName;
|
|
675
|
+
},
|
|
676
|
+
get children() {
|
|
677
|
+
return props.children;
|
|
678
|
+
}
|
|
679
|
+
}));
|
|
680
|
+
},
|
|
681
|
+
get when() {
|
|
682
|
+
return typeof props.TagName === "string";
|
|
683
|
+
},
|
|
684
|
+
get children() {
|
|
685
|
+
return createComponent(Dynamic, mergeProps(() => props.attributes, () => props.actionAttributes, {
|
|
686
|
+
get component() {
|
|
687
|
+
return props.TagName;
|
|
688
|
+
},
|
|
689
|
+
get children() {
|
|
690
|
+
return props.children;
|
|
691
|
+
}
|
|
692
|
+
}));
|
|
693
|
+
}
|
|
694
|
+
});
|
|
695
|
+
}
|
|
696
|
+
});
|
|
697
|
+
}
|
|
698
|
+
var dynamic_renderer_default = DynamicRenderer;
|
|
699
|
+
|
|
700
|
+
// src/components/block/components/block-wrapper.tsx
|
|
701
|
+
function BlockWrapper(props) {
|
|
702
|
+
return createComponent(dynamic_renderer_default, {
|
|
703
|
+
get TagName() {
|
|
704
|
+
return props.Wrapper;
|
|
705
|
+
},
|
|
706
|
+
get attributes() {
|
|
707
|
+
return getBlockProperties({
|
|
681
708
|
block: props.block,
|
|
682
709
|
context: props.context
|
|
683
|
-
})
|
|
710
|
+
});
|
|
711
|
+
},
|
|
712
|
+
get actionAttributes() {
|
|
713
|
+
return getBlockActions({
|
|
684
714
|
block: props.block,
|
|
685
715
|
rootState: props.context.rootState,
|
|
686
716
|
rootSetState: props.context.rootSetState,
|
|
687
717
|
localState: props.context.localState,
|
|
688
718
|
context: props.context.context,
|
|
689
719
|
stripPrefix: true
|
|
690
|
-
})
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
get children() {
|
|
695
|
-
return props.children;
|
|
696
|
-
}
|
|
697
|
-
}));
|
|
720
|
+
});
|
|
721
|
+
},
|
|
722
|
+
get children() {
|
|
723
|
+
return props.children;
|
|
698
724
|
}
|
|
699
725
|
});
|
|
700
726
|
}
|
|
@@ -935,29 +961,8 @@ function Block(props) {
|
|
|
935
961
|
return !blockComponent()?.noWrap;
|
|
936
962
|
},
|
|
937
963
|
get children() {
|
|
938
|
-
return
|
|
939
|
-
get
|
|
940
|
-
return isEmptyHtmlElement(Tag());
|
|
941
|
-
},
|
|
942
|
-
get children() {
|
|
943
|
-
return createComponent(block_wrapper_default, {
|
|
944
|
-
get Wrapper() {
|
|
945
|
-
return Tag();
|
|
946
|
-
},
|
|
947
|
-
get block() {
|
|
948
|
-
return processedBlock();
|
|
949
|
-
},
|
|
950
|
-
get context() {
|
|
951
|
-
return props.context;
|
|
952
|
-
},
|
|
953
|
-
hasChildren: false
|
|
954
|
-
});
|
|
955
|
-
}
|
|
956
|
-
}), createComponent(Show, {
|
|
957
|
-
get when() {
|
|
958
|
-
return memo(() => !!!isEmptyHtmlElement(Tag()))() && repeatItem();
|
|
959
|
-
},
|
|
960
|
-
get children() {
|
|
964
|
+
return createComponent(Show, {
|
|
965
|
+
get fallback() {
|
|
961
966
|
return createComponent(For, {
|
|
962
967
|
get each() {
|
|
963
968
|
return repeatItem();
|
|
@@ -978,10 +983,9 @@ function Block(props) {
|
|
|
978
983
|
});
|
|
979
984
|
}
|
|
980
985
|
});
|
|
981
|
-
}
|
|
982
|
-
}), createComponent(Show, {
|
|
986
|
+
},
|
|
983
987
|
get when() {
|
|
984
|
-
return
|
|
988
|
+
return !repeatItem();
|
|
985
989
|
},
|
|
986
990
|
get children() {
|
|
987
991
|
return createComponent(block_wrapper_default, {
|
|
@@ -994,7 +998,6 @@ function Block(props) {
|
|
|
994
998
|
get context() {
|
|
995
999
|
return props.context;
|
|
996
1000
|
},
|
|
997
|
-
hasChildren: true,
|
|
998
1001
|
get children() {
|
|
999
1002
|
return [createComponent(component_ref_default, {
|
|
1000
1003
|
get componentRef() {
|
|
@@ -1044,7 +1047,7 @@ function Block(props) {
|
|
|
1044
1047
|
}
|
|
1045
1048
|
});
|
|
1046
1049
|
}
|
|
1047
|
-
})
|
|
1050
|
+
});
|
|
1048
1051
|
}
|
|
1049
1052
|
})];
|
|
1050
1053
|
}
|
|
@@ -3033,6 +3036,13 @@ async function fetchEntries(options) {
|
|
|
3033
3036
|
}
|
|
3034
3037
|
var getAllContent = fetchEntries;
|
|
3035
3038
|
|
|
3039
|
+
// src/functions/is-from-trusted-host.ts
|
|
3040
|
+
var DEFAULT_TRUSTED_HOSTS = ["*.beta.builder.io", "beta.builder.io", "builder.io", "localhost", "qa.builder.io"];
|
|
3041
|
+
function isFromTrustedHost(trustedHosts, e) {
|
|
3042
|
+
const url = new URL(e.origin), hostname = url.hostname;
|
|
3043
|
+
return (trustedHosts || DEFAULT_TRUSTED_HOSTS).findIndex((trustedHost) => trustedHost.startsWith("*.") ? hostname.endsWith(trustedHost.slice(1)) : trustedHost === hostname) > -1;
|
|
3044
|
+
}
|
|
3045
|
+
|
|
3036
3046
|
// src/functions/is-previewing.ts
|
|
3037
3047
|
function isPreviewing() {
|
|
3038
3048
|
if (!isBrowser()) {
|
|
@@ -3281,7 +3291,7 @@ var getInteractionPropertiesForEvent = (event) => {
|
|
|
3281
3291
|
};
|
|
3282
3292
|
|
|
3283
3293
|
// src/constants/sdk-version.ts
|
|
3284
|
-
var SDK_VERSION = "0.12.
|
|
3294
|
+
var SDK_VERSION = "0.12.3";
|
|
3285
3295
|
|
|
3286
3296
|
// src/functions/register.ts
|
|
3287
3297
|
var registry = {};
|
|
@@ -3358,9 +3368,13 @@ var setupBrowserForEditing = (options = {}) => {
|
|
|
3358
3368
|
options
|
|
3359
3369
|
}
|
|
3360
3370
|
}, "*");
|
|
3361
|
-
window.addEventListener("message", ({
|
|
3362
|
-
|
|
3363
|
-
|
|
3371
|
+
window.addEventListener("message", (event) => {
|
|
3372
|
+
if (!isFromTrustedHost(options.trustedHosts, event)) {
|
|
3373
|
+
return;
|
|
3374
|
+
}
|
|
3375
|
+
const {
|
|
3376
|
+
data
|
|
3377
|
+
} = event;
|
|
3364
3378
|
if (!data?.type) {
|
|
3365
3379
|
return;
|
|
3366
3380
|
}
|
|
@@ -3456,6 +3470,9 @@ function EnableEditor(props) {
|
|
|
3456
3470
|
}));
|
|
3457
3471
|
}
|
|
3458
3472
|
function processMessage(event) {
|
|
3473
|
+
if (!isFromTrustedHost(props.trustedHosts, event)) {
|
|
3474
|
+
return;
|
|
3475
|
+
}
|
|
3459
3476
|
const {
|
|
3460
3477
|
data
|
|
3461
3478
|
} = event;
|
|
@@ -3586,6 +3603,9 @@ function EnableEditor(props) {
|
|
|
3586
3603
|
} : {},
|
|
3587
3604
|
...props.enrich ? {
|
|
3588
3605
|
enrich: props.enrich
|
|
3606
|
+
} : {},
|
|
3607
|
+
...props.trustedHosts ? {
|
|
3608
|
+
trustedHosts: props.trustedHosts
|
|
3589
3609
|
} : {}
|
|
3590
3610
|
});
|
|
3591
3611
|
Object.values(props.builderContextSignal.componentInfos).forEach((registeredComponent) => {
|
|
@@ -3782,6 +3802,10 @@ ${getFontCss({
|
|
|
3782
3802
|
customFonts: props.customFonts
|
|
3783
3803
|
})}
|
|
3784
3804
|
|
|
3805
|
+
.builder-button {
|
|
3806
|
+
all: unset;
|
|
3807
|
+
}
|
|
3808
|
+
|
|
3785
3809
|
.builder-text > p:first-of-type, .builder-text > .builder-paragraph:first-of-type {
|
|
3786
3810
|
margin: 0;
|
|
3787
3811
|
}
|
|
@@ -3953,6 +3977,9 @@ function ContentComponent(props) {
|
|
|
3953
3977
|
},
|
|
3954
3978
|
get contentWrapperProps() {
|
|
3955
3979
|
return props.contentWrapperProps;
|
|
3980
|
+
},
|
|
3981
|
+
get trustedHosts() {
|
|
3982
|
+
return props.trustedHosts;
|
|
3956
3983
|
}
|
|
3957
3984
|
}, {
|
|
3958
3985
|
setBuilderContextSignal
|
|
@@ -4112,6 +4139,9 @@ function ContentVariants(props) {
|
|
|
4112
4139
|
},
|
|
4113
4140
|
get contentWrapperProps() {
|
|
4114
4141
|
return props.contentWrapperProps;
|
|
4142
|
+
},
|
|
4143
|
+
get trustedHosts() {
|
|
4144
|
+
return props.trustedHosts;
|
|
4115
4145
|
}
|
|
4116
4146
|
});
|
|
4117
4147
|
}
|
|
@@ -4166,6 +4196,9 @@ function ContentVariants(props) {
|
|
|
4166
4196
|
},
|
|
4167
4197
|
get contentWrapperProps() {
|
|
4168
4198
|
return props.contentWrapperProps;
|
|
4199
|
+
},
|
|
4200
|
+
get trustedHosts() {
|
|
4201
|
+
return props.trustedHosts;
|
|
4169
4202
|
}
|
|
4170
4203
|
}))];
|
|
4171
4204
|
}
|