@builder.io/sdk-solid 0.12.0 → 0.12.2
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 +156 -77
- package/lib/browser/dev.jsx +137 -75
- package/lib/browser/index.js +156 -77
- package/lib/browser/index.jsx +137 -75
- package/lib/edge/dev.js +156 -77
- package/lib/edge/dev.jsx +137 -75
- package/lib/edge/index.js +156 -77
- package/lib/edge/index.jsx +137 -75
- package/lib/node/dev.js +156 -77
- package/lib/node/dev.jsx +137 -75
- package/lib/node/index.js +156 -77
- package/lib/node/index.jsx +137 -75
- package/package.json +1 -1
package/lib/node/index.jsx
CHANGED
|
@@ -448,10 +448,6 @@ function getProcessedBlock({
|
|
|
448
448
|
}
|
|
449
449
|
|
|
450
450
|
// src/components/block/block.helpers.ts
|
|
451
|
-
var EMPTY_HTML_ELEMENTS = ["area", "base", "br", "col", "embed", "hr", "img", "input", "keygen", "link", "meta", "param", "source", "track", "wbr"];
|
|
452
|
-
var isEmptyHtmlElement = (tagName) => {
|
|
453
|
-
return typeof tagName === "string" && EMPTY_HTML_ELEMENTS.includes(tagName.toLowerCase());
|
|
454
|
-
};
|
|
455
451
|
var getComponent = ({
|
|
456
452
|
block,
|
|
457
453
|
context,
|
|
@@ -673,10 +669,6 @@ function BlockStyles(props) {
|
|
|
673
669
|
}
|
|
674
670
|
var Block_styles_default = BlockStyles;
|
|
675
671
|
|
|
676
|
-
// src/components/block/components/block-wrapper.tsx
|
|
677
|
-
import { Show as Show3 } from "solid-js";
|
|
678
|
-
import { Dynamic } from "solid-js/web";
|
|
679
|
-
|
|
680
672
|
// src/functions/event-handler-name.ts
|
|
681
673
|
function capitalizeFirstLetter(string) {
|
|
682
674
|
return string.charAt(0).toUpperCase() + string.slice(1);
|
|
@@ -763,31 +755,49 @@ function getStyleAttribute(style) {
|
|
|
763
755
|
}
|
|
764
756
|
}
|
|
765
757
|
|
|
766
|
-
// src/components/
|
|
767
|
-
|
|
758
|
+
// src/components/dynamic-renderer/dynamic-renderer.tsx
|
|
759
|
+
import { Show as Show3 } from "solid-js";
|
|
760
|
+
import { Dynamic } from "solid-js/web";
|
|
761
|
+
|
|
762
|
+
// src/components/dynamic-renderer/dynamic-renderer.helpers.ts
|
|
763
|
+
var EMPTY_HTML_ELEMENTS = /* @__PURE__ */ new Set(["area", "base", "br", "col", "embed", "hr", "img", "input", "keygen", "link", "meta", "param", "source", "track", "wbr"]);
|
|
764
|
+
var isEmptyElement = (tagName) => {
|
|
765
|
+
return typeof tagName === "string" && EMPTY_HTML_ELEMENTS.has(tagName.toLowerCase());
|
|
766
|
+
};
|
|
767
|
+
|
|
768
|
+
// src/components/dynamic-renderer/dynamic-renderer.tsx
|
|
769
|
+
function DynamicRenderer(props) {
|
|
768
770
|
return <Show3
|
|
769
771
|
fallback={<Dynamic
|
|
770
|
-
{...
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
})}
|
|
774
|
-
{...getBlockActions({
|
|
775
|
-
block: props.block,
|
|
776
|
-
rootState: props.context.rootState,
|
|
777
|
-
rootSetState: props.context.rootSetState,
|
|
778
|
-
localState: props.context.localState,
|
|
779
|
-
context: props.context.context,
|
|
780
|
-
stripPrefix: true
|
|
781
|
-
})}
|
|
782
|
-
component={props.Wrapper}
|
|
772
|
+
{...props.attributes}
|
|
773
|
+
{...props.actionAttributes}
|
|
774
|
+
component={props.TagName}
|
|
783
775
|
/>}
|
|
784
|
-
when={props.
|
|
776
|
+
when={!isEmptyElement(props.TagName)}
|
|
777
|
+
><Show3
|
|
778
|
+
fallback={<Dynamic
|
|
779
|
+
{...props.attributes}
|
|
780
|
+
{...props.actionAttributes}
|
|
781
|
+
component={props.TagName}
|
|
782
|
+
>{props.children}</Dynamic>}
|
|
783
|
+
when={typeof props.TagName === "string"}
|
|
785
784
|
><Dynamic
|
|
786
|
-
{...
|
|
785
|
+
{...props.attributes}
|
|
786
|
+
{...props.actionAttributes}
|
|
787
|
+
component={props.TagName}
|
|
788
|
+
>{props.children}</Dynamic></Show3></Show3>;
|
|
789
|
+
}
|
|
790
|
+
var Dynamic_renderer_default = DynamicRenderer;
|
|
791
|
+
|
|
792
|
+
// src/components/block/components/block-wrapper.tsx
|
|
793
|
+
function BlockWrapper(props) {
|
|
794
|
+
return <Dynamic_renderer_default
|
|
795
|
+
TagName={props.Wrapper}
|
|
796
|
+
attributes={getBlockProperties({
|
|
787
797
|
block: props.block,
|
|
788
798
|
context: props.context
|
|
789
799
|
})}
|
|
790
|
-
{
|
|
800
|
+
actionAttributes={getBlockActions({
|
|
791
801
|
block: props.block,
|
|
792
802
|
rootState: props.context.rootState,
|
|
793
803
|
rootSetState: props.context.rootSetState,
|
|
@@ -795,8 +805,7 @@ function BlockWrapper(props) {
|
|
|
795
805
|
context: props.context.context,
|
|
796
806
|
stripPrefix: true
|
|
797
807
|
})}
|
|
798
|
-
|
|
799
|
-
>{props.children}</Dynamic></Show3>;
|
|
808
|
+
>{props.children}</Dynamic_renderer_default>;
|
|
800
809
|
}
|
|
801
810
|
var Block_wrapper_default = BlockWrapper;
|
|
802
811
|
|
|
@@ -975,14 +984,8 @@ function Block(props) {
|
|
|
975
984
|
isInteractive={componentRefProps().isInteractive}
|
|
976
985
|
/>}
|
|
977
986
|
when={!blockComponent()?.noWrap}
|
|
978
|
-
|
|
979
|
-
<
|
|
980
|
-
Wrapper={Tag()}
|
|
981
|
-
block={processedBlock()}
|
|
982
|
-
context={props.context}
|
|
983
|
-
hasChildren={false}
|
|
984
|
-
/></Show5>
|
|
985
|
-
<Show5 when={!isEmptyHtmlElement(Tag()) && repeatItem()}><For2 each={repeatItem()}>{(data, _index) => {
|
|
987
|
+
><Show5
|
|
988
|
+
fallback={<For2 each={repeatItem()}>{(data, _index) => {
|
|
986
989
|
const index = _index();
|
|
987
990
|
return <Repeated_block_default
|
|
988
991
|
key={index}
|
|
@@ -990,34 +993,33 @@ function Block(props) {
|
|
|
990
993
|
block={data.block}
|
|
991
994
|
registeredComponents={props.registeredComponents}
|
|
992
995
|
/>;
|
|
993
|
-
}}</For2
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
</Show5>
|
|
996
|
+
}}</For2>}
|
|
997
|
+
when={!repeatItem()}
|
|
998
|
+
><Block_wrapper_default
|
|
999
|
+
Wrapper={Tag()}
|
|
1000
|
+
block={processedBlock()}
|
|
1001
|
+
context={props.context}
|
|
1002
|
+
>
|
|
1003
|
+
<Component_ref_default
|
|
1004
|
+
componentRef={componentRefProps().componentRef}
|
|
1005
|
+
componentOptions={componentRefProps().componentOptions}
|
|
1006
|
+
blockChildren={componentRefProps().blockChildren}
|
|
1007
|
+
context={componentRefProps().context}
|
|
1008
|
+
registeredComponents={componentRefProps().registeredComponents}
|
|
1009
|
+
builderBlock={componentRefProps().builderBlock}
|
|
1010
|
+
includeBlockProps={componentRefProps().includeBlockProps}
|
|
1011
|
+
isInteractive={componentRefProps().isInteractive}
|
|
1012
|
+
/>
|
|
1013
|
+
<For2 each={childrenWithoutParentComponent()}>{(child, _index) => {
|
|
1014
|
+
const index = _index();
|
|
1015
|
+
return <Block
|
|
1016
|
+
key={child.id}
|
|
1017
|
+
block={child}
|
|
1018
|
+
context={childrenContext()}
|
|
1019
|
+
registeredComponents={props.registeredComponents}
|
|
1020
|
+
/>;
|
|
1021
|
+
}}</For2>
|
|
1022
|
+
</Block_wrapper_default></Show5></Show5>
|
|
1021
1023
|
</Show5>;
|
|
1022
1024
|
}
|
|
1023
1025
|
var Block_default = Block;
|
|
@@ -2214,8 +2216,42 @@ var componentInfo8 = {
|
|
|
2214
2216
|
}]
|
|
2215
2217
|
};
|
|
2216
2218
|
|
|
2217
|
-
// src/blocks/
|
|
2219
|
+
// src/blocks/slot/component-info.ts
|
|
2218
2220
|
var componentInfo9 = {
|
|
2221
|
+
name: "Slot",
|
|
2222
|
+
isRSC: true,
|
|
2223
|
+
description: "Allow child blocks to be inserted into this content when used as a Symbol",
|
|
2224
|
+
docsLink: "https://www.builder.io/c/docs/symbols-with-blocks",
|
|
2225
|
+
image: "https://cdn.builder.io/api/v1/image/assets%2FYJIGb4i01jvw0SRdL5Bt%2F3aad6de36eae43b59b52c85190fdef56",
|
|
2226
|
+
// Maybe wrap this for canHaveChildren so bind children to this hm
|
|
2227
|
+
inputs: [{
|
|
2228
|
+
name: "name",
|
|
2229
|
+
type: "string",
|
|
2230
|
+
required: true,
|
|
2231
|
+
defaultValue: "children"
|
|
2232
|
+
}]
|
|
2233
|
+
};
|
|
2234
|
+
|
|
2235
|
+
// src/blocks/slot/slot.tsx
|
|
2236
|
+
function Slot(props) {
|
|
2237
|
+
return <div
|
|
2238
|
+
style={{
|
|
2239
|
+
"pointer-events": "auto"
|
|
2240
|
+
}}
|
|
2241
|
+
{...!props.builderContext.context?.symbolId && {
|
|
2242
|
+
"builder-slot": props.name
|
|
2243
|
+
}}
|
|
2244
|
+
><Blocks_default
|
|
2245
|
+
parent={props.builderContext.context?.symbolId}
|
|
2246
|
+
path={`symbol.data.${props.name}`}
|
|
2247
|
+
context={props.builderContext}
|
|
2248
|
+
blocks={props.builderContext.rootState?.[props.name]}
|
|
2249
|
+
/></div>;
|
|
2250
|
+
}
|
|
2251
|
+
var slot_default = Slot;
|
|
2252
|
+
|
|
2253
|
+
// src/blocks/symbol/component-info.ts
|
|
2254
|
+
var componentInfo10 = {
|
|
2219
2255
|
name: "Symbol",
|
|
2220
2256
|
noWrap: true,
|
|
2221
2257
|
static: true,
|
|
@@ -2251,7 +2287,7 @@ var componentInfo9 = {
|
|
|
2251
2287
|
};
|
|
2252
2288
|
|
|
2253
2289
|
// src/blocks/text/component-info.ts
|
|
2254
|
-
var
|
|
2290
|
+
var componentInfo11 = {
|
|
2255
2291
|
name: "Text",
|
|
2256
2292
|
static: true,
|
|
2257
2293
|
isRSC: true,
|
|
@@ -2284,7 +2320,7 @@ function Text(props) {
|
|
|
2284
2320
|
var text_default = Text;
|
|
2285
2321
|
|
|
2286
2322
|
// src/blocks/video/component-info.ts
|
|
2287
|
-
var
|
|
2323
|
+
var componentInfo12 = {
|
|
2288
2324
|
name: "Video",
|
|
2289
2325
|
canHaveChildren: true,
|
|
2290
2326
|
defaultStyles: {
|
|
@@ -2481,13 +2517,16 @@ var getDefaultRegisteredComponents = () => [{
|
|
|
2481
2517
|
...componentInfo8
|
|
2482
2518
|
}, {
|
|
2483
2519
|
component: symbol_default,
|
|
2484
|
-
...
|
|
2520
|
+
...componentInfo10
|
|
2485
2521
|
}, {
|
|
2486
2522
|
component: text_default,
|
|
2487
|
-
...
|
|
2523
|
+
...componentInfo11
|
|
2488
2524
|
}, {
|
|
2489
2525
|
component: video_default,
|
|
2490
|
-
...
|
|
2526
|
+
...componentInfo12
|
|
2527
|
+
}, {
|
|
2528
|
+
component: slot_default,
|
|
2529
|
+
...componentInfo9
|
|
2491
2530
|
}];
|
|
2492
2531
|
|
|
2493
2532
|
// src/functions/register-component.ts
|
|
@@ -2801,6 +2840,13 @@ async function fetchEntries(options) {
|
|
|
2801
2840
|
}
|
|
2802
2841
|
var getAllContent = fetchEntries;
|
|
2803
2842
|
|
|
2843
|
+
// src/functions/is-from-trusted-host.ts
|
|
2844
|
+
var DEFAULT_TRUSTED_HOSTS = ["*.beta.builder.io", "beta.builder.io", "builder.io", "localhost", "qa.builder.io"];
|
|
2845
|
+
function isFromTrustedHost(trustedHosts, e) {
|
|
2846
|
+
const url = new URL(e.origin), hostname = url.hostname;
|
|
2847
|
+
return (trustedHosts || DEFAULT_TRUSTED_HOSTS).findIndex((trustedHost) => trustedHost.startsWith("*.") ? hostname.endsWith(trustedHost.slice(1)) : trustedHost === hostname) > -1;
|
|
2848
|
+
}
|
|
2849
|
+
|
|
2804
2850
|
// src/functions/is-previewing.ts
|
|
2805
2851
|
function isPreviewing() {
|
|
2806
2852
|
if (!isBrowser()) {
|
|
@@ -3049,7 +3095,7 @@ var getInteractionPropertiesForEvent = (event) => {
|
|
|
3049
3095
|
};
|
|
3050
3096
|
|
|
3051
3097
|
// src/constants/sdk-version.ts
|
|
3052
|
-
var SDK_VERSION = "0.12.
|
|
3098
|
+
var SDK_VERSION = "0.12.2";
|
|
3053
3099
|
|
|
3054
3100
|
// src/functions/register.ts
|
|
3055
3101
|
var registry = {};
|
|
@@ -3126,9 +3172,13 @@ var setupBrowserForEditing = (options = {}) => {
|
|
|
3126
3172
|
options
|
|
3127
3173
|
}
|
|
3128
3174
|
}, "*");
|
|
3129
|
-
window.addEventListener("message", ({
|
|
3130
|
-
|
|
3131
|
-
|
|
3175
|
+
window.addEventListener("message", (event) => {
|
|
3176
|
+
if (!isFromTrustedHost(options.trustedHosts, event)) {
|
|
3177
|
+
return;
|
|
3178
|
+
}
|
|
3179
|
+
const {
|
|
3180
|
+
data
|
|
3181
|
+
} = event;
|
|
3132
3182
|
if (!data?.type) {
|
|
3133
3183
|
return;
|
|
3134
3184
|
}
|
|
@@ -3226,6 +3276,9 @@ function EnableEditor(props) {
|
|
|
3226
3276
|
}));
|
|
3227
3277
|
}
|
|
3228
3278
|
function processMessage(event) {
|
|
3279
|
+
if (!isFromTrustedHost(props.trustedHosts, event)) {
|
|
3280
|
+
return;
|
|
3281
|
+
}
|
|
3229
3282
|
const { data } = event;
|
|
3230
3283
|
if (data) {
|
|
3231
3284
|
switch (data.type) {
|
|
@@ -3356,6 +3409,9 @@ function EnableEditor(props) {
|
|
|
3356
3409
|
} : {},
|
|
3357
3410
|
...props.enrich ? {
|
|
3358
3411
|
enrich: props.enrich
|
|
3412
|
+
} : {},
|
|
3413
|
+
...props.trustedHosts ? {
|
|
3414
|
+
trustedHosts: props.trustedHosts
|
|
3359
3415
|
} : {}
|
|
3360
3416
|
});
|
|
3361
3417
|
Object.values(
|
|
@@ -3694,6 +3750,7 @@ function ContentComponent(props) {
|
|
|
3694
3750
|
builderContextSignal={builderContextSignal()}
|
|
3695
3751
|
contentWrapper={props.contentWrapper}
|
|
3696
3752
|
contentWrapperProps={props.contentWrapperProps}
|
|
3753
|
+
trustedHosts={props.trustedHosts}
|
|
3697
3754
|
{...{
|
|
3698
3755
|
setBuilderContextSignal
|
|
3699
3756
|
}}
|
|
@@ -3776,6 +3833,7 @@ function ContentVariants(props) {
|
|
|
3776
3833
|
blocksWrapperProps={props.blocksWrapperProps}
|
|
3777
3834
|
contentWrapper={props.contentWrapper}
|
|
3778
3835
|
contentWrapperProps={props.contentWrapperProps}
|
|
3836
|
+
trustedHosts={props.trustedHosts}
|
|
3779
3837
|
/>;
|
|
3780
3838
|
}}</For5>
|
|
3781
3839
|
</Show12>
|
|
@@ -3798,6 +3856,7 @@ function ContentVariants(props) {
|
|
|
3798
3856
|
blocksWrapperProps={props.blocksWrapperProps}
|
|
3799
3857
|
contentWrapper={props.contentWrapper}
|
|
3800
3858
|
contentWrapperProps={props.contentWrapperProps}
|
|
3859
|
+
trustedHosts={props.trustedHosts}
|
|
3801
3860
|
/>
|
|
3802
3861
|
</>;
|
|
3803
3862
|
}
|
|
@@ -3861,7 +3920,10 @@ function Symbol(props) {
|
|
|
3861
3920
|
__isNestedRender={true}
|
|
3862
3921
|
apiVersion={props.builderContext.apiVersion}
|
|
3863
3922
|
apiKey={props.builderContext.apiKey}
|
|
3864
|
-
context={
|
|
3923
|
+
context={{
|
|
3924
|
+
...props.builderContext.context,
|
|
3925
|
+
symbolId: props.builderBlock?.id
|
|
3926
|
+
}}
|
|
3865
3927
|
customComponents={Object.values(props.builderComponents)}
|
|
3866
3928
|
data={{
|
|
3867
3929
|
...props.symbol?.data,
|