@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/dev.jsx
CHANGED
|
@@ -451,10 +451,6 @@ function getProcessedBlock({
|
|
|
451
451
|
}
|
|
452
452
|
|
|
453
453
|
// 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
454
|
var getComponent = ({
|
|
459
455
|
block,
|
|
460
456
|
context,
|
|
@@ -679,10 +675,6 @@ function BlockStyles(props) {
|
|
|
679
675
|
}
|
|
680
676
|
var Block_styles_default = BlockStyles;
|
|
681
677
|
|
|
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
678
|
// src/functions/event-handler-name.ts
|
|
687
679
|
function capitalizeFirstLetter(string) {
|
|
688
680
|
return string.charAt(0).toUpperCase() + string.slice(1);
|
|
@@ -769,31 +761,49 @@ function getStyleAttribute(style) {
|
|
|
769
761
|
}
|
|
770
762
|
}
|
|
771
763
|
|
|
772
|
-
// src/components/
|
|
773
|
-
|
|
764
|
+
// src/components/dynamic-renderer/dynamic-renderer.tsx
|
|
765
|
+
import { Show as Show3 } from "solid-js";
|
|
766
|
+
import { Dynamic } from "solid-js/web";
|
|
767
|
+
|
|
768
|
+
// src/components/dynamic-renderer/dynamic-renderer.helpers.ts
|
|
769
|
+
var EMPTY_HTML_ELEMENTS = /* @__PURE__ */ new Set(["area", "base", "br", "col", "embed", "hr", "img", "input", "keygen", "link", "meta", "param", "source", "track", "wbr"]);
|
|
770
|
+
var isEmptyElement = (tagName) => {
|
|
771
|
+
return typeof tagName === "string" && EMPTY_HTML_ELEMENTS.has(tagName.toLowerCase());
|
|
772
|
+
};
|
|
773
|
+
|
|
774
|
+
// src/components/dynamic-renderer/dynamic-renderer.tsx
|
|
775
|
+
function DynamicRenderer(props) {
|
|
774
776
|
return <Show3
|
|
775
777
|
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}
|
|
778
|
+
{...props.attributes}
|
|
779
|
+
{...props.actionAttributes}
|
|
780
|
+
component={props.TagName}
|
|
789
781
|
/>}
|
|
790
|
-
when={props.
|
|
782
|
+
when={!isEmptyElement(props.TagName)}
|
|
783
|
+
><Show3
|
|
784
|
+
fallback={<Dynamic
|
|
785
|
+
{...props.attributes}
|
|
786
|
+
{...props.actionAttributes}
|
|
787
|
+
component={props.TagName}
|
|
788
|
+
>{props.children}</Dynamic>}
|
|
789
|
+
when={typeof props.TagName === "string"}
|
|
791
790
|
><Dynamic
|
|
792
|
-
{...
|
|
791
|
+
{...props.attributes}
|
|
792
|
+
{...props.actionAttributes}
|
|
793
|
+
component={props.TagName}
|
|
794
|
+
>{props.children}</Dynamic></Show3></Show3>;
|
|
795
|
+
}
|
|
796
|
+
var Dynamic_renderer_default = DynamicRenderer;
|
|
797
|
+
|
|
798
|
+
// src/components/block/components/block-wrapper.tsx
|
|
799
|
+
function BlockWrapper(props) {
|
|
800
|
+
return <Dynamic_renderer_default
|
|
801
|
+
TagName={props.Wrapper}
|
|
802
|
+
attributes={getBlockProperties({
|
|
793
803
|
block: props.block,
|
|
794
804
|
context: props.context
|
|
795
805
|
})}
|
|
796
|
-
{
|
|
806
|
+
actionAttributes={getBlockActions({
|
|
797
807
|
block: props.block,
|
|
798
808
|
rootState: props.context.rootState,
|
|
799
809
|
rootSetState: props.context.rootSetState,
|
|
@@ -801,8 +811,7 @@ function BlockWrapper(props) {
|
|
|
801
811
|
context: props.context.context,
|
|
802
812
|
stripPrefix: true
|
|
803
813
|
})}
|
|
804
|
-
|
|
805
|
-
>{props.children}</Dynamic></Show3>;
|
|
814
|
+
>{props.children}</Dynamic_renderer_default>;
|
|
806
815
|
}
|
|
807
816
|
var Block_wrapper_default = BlockWrapper;
|
|
808
817
|
|
|
@@ -981,14 +990,8 @@ function Block(props) {
|
|
|
981
990
|
isInteractive={componentRefProps().isInteractive}
|
|
982
991
|
/>}
|
|
983
992
|
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) => {
|
|
993
|
+
><Show5
|
|
994
|
+
fallback={<For2 each={repeatItem()}>{(data, _index) => {
|
|
992
995
|
const index = _index();
|
|
993
996
|
return <Repeated_block_default
|
|
994
997
|
key={index}
|
|
@@ -996,34 +999,33 @@ function Block(props) {
|
|
|
996
999
|
block={data.block}
|
|
997
1000
|
registeredComponents={props.registeredComponents}
|
|
998
1001
|
/>;
|
|
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>
|
|
1002
|
+
}}</For2>}
|
|
1003
|
+
when={!repeatItem()}
|
|
1004
|
+
><Block_wrapper_default
|
|
1005
|
+
Wrapper={Tag()}
|
|
1006
|
+
block={processedBlock()}
|
|
1007
|
+
context={props.context}
|
|
1008
|
+
>
|
|
1009
|
+
<Component_ref_default
|
|
1010
|
+
componentRef={componentRefProps().componentRef}
|
|
1011
|
+
componentOptions={componentRefProps().componentOptions}
|
|
1012
|
+
blockChildren={componentRefProps().blockChildren}
|
|
1013
|
+
context={componentRefProps().context}
|
|
1014
|
+
registeredComponents={componentRefProps().registeredComponents}
|
|
1015
|
+
builderBlock={componentRefProps().builderBlock}
|
|
1016
|
+
includeBlockProps={componentRefProps().includeBlockProps}
|
|
1017
|
+
isInteractive={componentRefProps().isInteractive}
|
|
1018
|
+
/>
|
|
1019
|
+
<For2 each={childrenWithoutParentComponent()}>{(child, _index) => {
|
|
1020
|
+
const index = _index();
|
|
1021
|
+
return <Block
|
|
1022
|
+
key={child.id}
|
|
1023
|
+
block={child}
|
|
1024
|
+
context={childrenContext()}
|
|
1025
|
+
registeredComponents={props.registeredComponents}
|
|
1026
|
+
/>;
|
|
1027
|
+
}}</For2>
|
|
1028
|
+
</Block_wrapper_default></Show5></Show5>
|
|
1027
1029
|
</Show5>;
|
|
1028
1030
|
}
|
|
1029
1031
|
var Block_default = Block;
|
|
@@ -2224,8 +2226,42 @@ var componentInfo8 = {
|
|
|
2224
2226
|
}]
|
|
2225
2227
|
};
|
|
2226
2228
|
|
|
2227
|
-
// src/blocks/
|
|
2229
|
+
// src/blocks/slot/component-info.ts
|
|
2228
2230
|
var componentInfo9 = {
|
|
2231
|
+
name: "Slot",
|
|
2232
|
+
isRSC: true,
|
|
2233
|
+
description: "Allow child blocks to be inserted into this content when used as a Symbol",
|
|
2234
|
+
docsLink: "https://www.builder.io/c/docs/symbols-with-blocks",
|
|
2235
|
+
image: "https://cdn.builder.io/api/v1/image/assets%2FYJIGb4i01jvw0SRdL5Bt%2F3aad6de36eae43b59b52c85190fdef56",
|
|
2236
|
+
// Maybe wrap this for canHaveChildren so bind children to this hm
|
|
2237
|
+
inputs: [{
|
|
2238
|
+
name: "name",
|
|
2239
|
+
type: "string",
|
|
2240
|
+
required: true,
|
|
2241
|
+
defaultValue: "children"
|
|
2242
|
+
}]
|
|
2243
|
+
};
|
|
2244
|
+
|
|
2245
|
+
// src/blocks/slot/slot.tsx
|
|
2246
|
+
function Slot(props) {
|
|
2247
|
+
return <div
|
|
2248
|
+
style={{
|
|
2249
|
+
"pointer-events": "auto"
|
|
2250
|
+
}}
|
|
2251
|
+
{...!props.builderContext.context?.symbolId && {
|
|
2252
|
+
"builder-slot": props.name
|
|
2253
|
+
}}
|
|
2254
|
+
><Blocks_default
|
|
2255
|
+
parent={props.builderContext.context?.symbolId}
|
|
2256
|
+
path={`symbol.data.${props.name}`}
|
|
2257
|
+
context={props.builderContext}
|
|
2258
|
+
blocks={props.builderContext.rootState?.[props.name]}
|
|
2259
|
+
/></div>;
|
|
2260
|
+
}
|
|
2261
|
+
var slot_default = Slot;
|
|
2262
|
+
|
|
2263
|
+
// src/blocks/symbol/component-info.ts
|
|
2264
|
+
var componentInfo10 = {
|
|
2229
2265
|
name: "Symbol",
|
|
2230
2266
|
noWrap: true,
|
|
2231
2267
|
static: true,
|
|
@@ -2261,7 +2297,7 @@ var componentInfo9 = {
|
|
|
2261
2297
|
};
|
|
2262
2298
|
|
|
2263
2299
|
// src/blocks/text/component-info.ts
|
|
2264
|
-
var
|
|
2300
|
+
var componentInfo11 = {
|
|
2265
2301
|
name: "Text",
|
|
2266
2302
|
static: true,
|
|
2267
2303
|
isRSC: true,
|
|
@@ -2294,7 +2330,7 @@ function Text(props) {
|
|
|
2294
2330
|
var text_default = Text;
|
|
2295
2331
|
|
|
2296
2332
|
// src/blocks/video/component-info.ts
|
|
2297
|
-
var
|
|
2333
|
+
var componentInfo12 = {
|
|
2298
2334
|
name: "Video",
|
|
2299
2335
|
canHaveChildren: true,
|
|
2300
2336
|
defaultStyles: {
|
|
@@ -2491,13 +2527,16 @@ var getDefaultRegisteredComponents = () => [{
|
|
|
2491
2527
|
...componentInfo8
|
|
2492
2528
|
}, {
|
|
2493
2529
|
component: symbol_default,
|
|
2494
|
-
...
|
|
2530
|
+
...componentInfo10
|
|
2495
2531
|
}, {
|
|
2496
2532
|
component: text_default,
|
|
2497
|
-
...
|
|
2533
|
+
...componentInfo11
|
|
2498
2534
|
}, {
|
|
2499
2535
|
component: video_default,
|
|
2500
|
-
...
|
|
2536
|
+
...componentInfo12
|
|
2537
|
+
}, {
|
|
2538
|
+
component: slot_default,
|
|
2539
|
+
...componentInfo9
|
|
2501
2540
|
}];
|
|
2502
2541
|
|
|
2503
2542
|
// src/functions/register-component.ts
|
|
@@ -2813,6 +2852,13 @@ async function fetchEntries(options) {
|
|
|
2813
2852
|
}
|
|
2814
2853
|
var getAllContent = fetchEntries;
|
|
2815
2854
|
|
|
2855
|
+
// src/functions/is-from-trusted-host.ts
|
|
2856
|
+
var DEFAULT_TRUSTED_HOSTS = ["*.beta.builder.io", "beta.builder.io", "builder.io", "localhost", "qa.builder.io"];
|
|
2857
|
+
function isFromTrustedHost(trustedHosts, e) {
|
|
2858
|
+
const url = new URL(e.origin), hostname = url.hostname;
|
|
2859
|
+
return (trustedHosts || DEFAULT_TRUSTED_HOSTS).findIndex((trustedHost) => trustedHost.startsWith("*.") ? hostname.endsWith(trustedHost.slice(1)) : trustedHost === hostname) > -1;
|
|
2860
|
+
}
|
|
2861
|
+
|
|
2816
2862
|
// src/functions/is-previewing.ts
|
|
2817
2863
|
function isPreviewing() {
|
|
2818
2864
|
if (!isBrowser()) {
|
|
@@ -3064,7 +3110,7 @@ var getInteractionPropertiesForEvent = (event) => {
|
|
|
3064
3110
|
};
|
|
3065
3111
|
|
|
3066
3112
|
// src/constants/sdk-version.ts
|
|
3067
|
-
var SDK_VERSION = "0.12.
|
|
3113
|
+
var SDK_VERSION = "0.12.2";
|
|
3068
3114
|
|
|
3069
3115
|
// src/functions/register.ts
|
|
3070
3116
|
var registry = {};
|
|
@@ -3142,9 +3188,13 @@ var setupBrowserForEditing = (options = {}) => {
|
|
|
3142
3188
|
options
|
|
3143
3189
|
}
|
|
3144
3190
|
}, "*");
|
|
3145
|
-
window.addEventListener("message", ({
|
|
3146
|
-
|
|
3147
|
-
|
|
3191
|
+
window.addEventListener("message", (event) => {
|
|
3192
|
+
if (!isFromTrustedHost(options.trustedHosts, event)) {
|
|
3193
|
+
return;
|
|
3194
|
+
}
|
|
3195
|
+
const {
|
|
3196
|
+
data
|
|
3197
|
+
} = event;
|
|
3148
3198
|
if (!data?.type) {
|
|
3149
3199
|
return;
|
|
3150
3200
|
}
|
|
@@ -3242,6 +3292,9 @@ function EnableEditor(props) {
|
|
|
3242
3292
|
}));
|
|
3243
3293
|
}
|
|
3244
3294
|
function processMessage(event) {
|
|
3295
|
+
if (!isFromTrustedHost(props.trustedHosts, event)) {
|
|
3296
|
+
return;
|
|
3297
|
+
}
|
|
3245
3298
|
const { data } = event;
|
|
3246
3299
|
if (data) {
|
|
3247
3300
|
switch (data.type) {
|
|
@@ -3373,6 +3426,9 @@ function EnableEditor(props) {
|
|
|
3373
3426
|
} : {},
|
|
3374
3427
|
...props.enrich ? {
|
|
3375
3428
|
enrich: props.enrich
|
|
3429
|
+
} : {},
|
|
3430
|
+
...props.trustedHosts ? {
|
|
3431
|
+
trustedHosts: props.trustedHosts
|
|
3376
3432
|
} : {}
|
|
3377
3433
|
});
|
|
3378
3434
|
Object.values(
|
|
@@ -3711,6 +3767,7 @@ function ContentComponent(props) {
|
|
|
3711
3767
|
builderContextSignal={builderContextSignal()}
|
|
3712
3768
|
contentWrapper={props.contentWrapper}
|
|
3713
3769
|
contentWrapperProps={props.contentWrapperProps}
|
|
3770
|
+
trustedHosts={props.trustedHosts}
|
|
3714
3771
|
{...{
|
|
3715
3772
|
setBuilderContextSignal
|
|
3716
3773
|
}}
|
|
@@ -3793,6 +3850,7 @@ function ContentVariants(props) {
|
|
|
3793
3850
|
blocksWrapperProps={props.blocksWrapperProps}
|
|
3794
3851
|
contentWrapper={props.contentWrapper}
|
|
3795
3852
|
contentWrapperProps={props.contentWrapperProps}
|
|
3853
|
+
trustedHosts={props.trustedHosts}
|
|
3796
3854
|
/>;
|
|
3797
3855
|
}}</For5>
|
|
3798
3856
|
</Show12>
|
|
@@ -3815,6 +3873,7 @@ function ContentVariants(props) {
|
|
|
3815
3873
|
blocksWrapperProps={props.blocksWrapperProps}
|
|
3816
3874
|
contentWrapper={props.contentWrapper}
|
|
3817
3875
|
contentWrapperProps={props.contentWrapperProps}
|
|
3876
|
+
trustedHosts={props.trustedHosts}
|
|
3818
3877
|
/>
|
|
3819
3878
|
</>;
|
|
3820
3879
|
}
|
|
@@ -3878,7 +3937,10 @@ function Symbol(props) {
|
|
|
3878
3937
|
__isNestedRender={true}
|
|
3879
3938
|
apiVersion={props.builderContext.apiVersion}
|
|
3880
3939
|
apiKey={props.builderContext.apiKey}
|
|
3881
|
-
context={
|
|
3940
|
+
context={{
|
|
3941
|
+
...props.builderContext.context,
|
|
3942
|
+
symbolId: props.builderBlock?.id
|
|
3943
|
+
}}
|
|
3882
3944
|
customComponents={Object.values(props.builderComponents)}
|
|
3883
3945
|
data={{
|
|
3884
3946
|
...props.symbol?.data,
|