@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.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
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';
|
|
@@ -454,10 +454,6 @@ function getProcessedBlock({
|
|
|
454
454
|
}
|
|
455
455
|
|
|
456
456
|
// 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
457
|
var getComponent = ({
|
|
462
458
|
block,
|
|
463
459
|
context,
|
|
@@ -776,48 +772,80 @@ function getStyleAttribute(style) {
|
|
|
776
772
|
}
|
|
777
773
|
}
|
|
778
774
|
|
|
779
|
-
// src/components/
|
|
780
|
-
|
|
775
|
+
// src/components/dynamic-renderer/dynamic-renderer.helpers.ts
|
|
776
|
+
var EMPTY_HTML_ELEMENTS = /* @__PURE__ */ new Set(["area", "base", "br", "col", "embed", "hr", "img", "input", "keygen", "link", "meta", "param", "source", "track", "wbr"]);
|
|
777
|
+
var isEmptyElement = (tagName) => {
|
|
778
|
+
return typeof tagName === "string" && EMPTY_HTML_ELEMENTS.has(tagName.toLowerCase());
|
|
779
|
+
};
|
|
780
|
+
|
|
781
|
+
// src/components/dynamic-renderer/dynamic-renderer.tsx
|
|
782
|
+
function DynamicRenderer(props) {
|
|
781
783
|
return createComponent(Show, {
|
|
782
784
|
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
|
-
}), {
|
|
785
|
+
return createComponent(Dynamic, mergeProps(() => props.attributes, () => props.actionAttributes, {
|
|
794
786
|
get component() {
|
|
795
|
-
return props.
|
|
787
|
+
return props.TagName;
|
|
796
788
|
}
|
|
797
789
|
}));
|
|
798
790
|
},
|
|
799
791
|
get when() {
|
|
800
|
-
return props.
|
|
792
|
+
return !isEmptyElement(props.TagName);
|
|
801
793
|
},
|
|
802
794
|
get children() {
|
|
803
|
-
return createComponent(
|
|
795
|
+
return createComponent(Show, {
|
|
796
|
+
get fallback() {
|
|
797
|
+
return createComponent(Dynamic, mergeProps(() => props.attributes, () => props.actionAttributes, {
|
|
798
|
+
get component() {
|
|
799
|
+
return props.TagName;
|
|
800
|
+
},
|
|
801
|
+
get children() {
|
|
802
|
+
return props.children;
|
|
803
|
+
}
|
|
804
|
+
}));
|
|
805
|
+
},
|
|
806
|
+
get when() {
|
|
807
|
+
return typeof props.TagName === "string";
|
|
808
|
+
},
|
|
809
|
+
get children() {
|
|
810
|
+
return createComponent(Dynamic, mergeProps(() => props.attributes, () => props.actionAttributes, {
|
|
811
|
+
get component() {
|
|
812
|
+
return props.TagName;
|
|
813
|
+
},
|
|
814
|
+
get children() {
|
|
815
|
+
return props.children;
|
|
816
|
+
}
|
|
817
|
+
}));
|
|
818
|
+
}
|
|
819
|
+
});
|
|
820
|
+
}
|
|
821
|
+
});
|
|
822
|
+
}
|
|
823
|
+
var dynamic_renderer_default = DynamicRenderer;
|
|
824
|
+
|
|
825
|
+
// src/components/block/components/block-wrapper.tsx
|
|
826
|
+
function BlockWrapper(props) {
|
|
827
|
+
return createComponent(dynamic_renderer_default, {
|
|
828
|
+
get TagName() {
|
|
829
|
+
return props.Wrapper;
|
|
830
|
+
},
|
|
831
|
+
get attributes() {
|
|
832
|
+
return getBlockProperties({
|
|
804
833
|
block: props.block,
|
|
805
834
|
context: props.context
|
|
806
|
-
})
|
|
835
|
+
});
|
|
836
|
+
},
|
|
837
|
+
get actionAttributes() {
|
|
838
|
+
return getBlockActions({
|
|
807
839
|
block: props.block,
|
|
808
840
|
rootState: props.context.rootState,
|
|
809
841
|
rootSetState: props.context.rootSetState,
|
|
810
842
|
localState: props.context.localState,
|
|
811
843
|
context: props.context.context,
|
|
812
844
|
stripPrefix: true
|
|
813
|
-
})
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
get children() {
|
|
818
|
-
return props.children;
|
|
819
|
-
}
|
|
820
|
-
}));
|
|
845
|
+
});
|
|
846
|
+
},
|
|
847
|
+
get children() {
|
|
848
|
+
return props.children;
|
|
821
849
|
}
|
|
822
850
|
});
|
|
823
851
|
}
|
|
@@ -1058,29 +1086,8 @@ function Block(props) {
|
|
|
1058
1086
|
return !blockComponent()?.noWrap;
|
|
1059
1087
|
},
|
|
1060
1088
|
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() {
|
|
1089
|
+
return createComponent(Show, {
|
|
1090
|
+
get fallback() {
|
|
1084
1091
|
return createComponent(For, {
|
|
1085
1092
|
get each() {
|
|
1086
1093
|
return repeatItem();
|
|
@@ -1101,10 +1108,9 @@ function Block(props) {
|
|
|
1101
1108
|
});
|
|
1102
1109
|
}
|
|
1103
1110
|
});
|
|
1104
|
-
}
|
|
1105
|
-
}), createComponent(Show, {
|
|
1111
|
+
},
|
|
1106
1112
|
get when() {
|
|
1107
|
-
return
|
|
1113
|
+
return !repeatItem();
|
|
1108
1114
|
},
|
|
1109
1115
|
get children() {
|
|
1110
1116
|
return createComponent(block_wrapper_default, {
|
|
@@ -1117,7 +1123,6 @@ function Block(props) {
|
|
|
1117
1123
|
get context() {
|
|
1118
1124
|
return props.context;
|
|
1119
1125
|
},
|
|
1120
|
-
hasChildren: true,
|
|
1121
1126
|
get children() {
|
|
1122
1127
|
return [createComponent(component_ref_default, {
|
|
1123
1128
|
get componentRef() {
|
|
@@ -1167,7 +1172,7 @@ function Block(props) {
|
|
|
1167
1172
|
}
|
|
1168
1173
|
});
|
|
1169
1174
|
}
|
|
1170
|
-
})
|
|
1175
|
+
});
|
|
1171
1176
|
}
|
|
1172
1177
|
})];
|
|
1173
1178
|
}
|
|
@@ -2489,8 +2494,50 @@ var componentInfo8 = {
|
|
|
2489
2494
|
}]
|
|
2490
2495
|
};
|
|
2491
2496
|
|
|
2492
|
-
// src/blocks/
|
|
2497
|
+
// src/blocks/slot/component-info.ts
|
|
2493
2498
|
var componentInfo9 = {
|
|
2499
|
+
name: "Slot",
|
|
2500
|
+
isRSC: true,
|
|
2501
|
+
description: "Allow child blocks to be inserted into this content when used as a Symbol",
|
|
2502
|
+
docsLink: "https://www.builder.io/c/docs/symbols-with-blocks",
|
|
2503
|
+
image: "https://cdn.builder.io/api/v1/image/assets%2FYJIGb4i01jvw0SRdL5Bt%2F3aad6de36eae43b59b52c85190fdef56",
|
|
2504
|
+
// Maybe wrap this for canHaveChildren so bind children to this hm
|
|
2505
|
+
inputs: [{
|
|
2506
|
+
name: "name",
|
|
2507
|
+
type: "string",
|
|
2508
|
+
required: true,
|
|
2509
|
+
defaultValue: "children"
|
|
2510
|
+
}]
|
|
2511
|
+
};
|
|
2512
|
+
var _tmpl$11 = /* @__PURE__ */ template(`<div>`);
|
|
2513
|
+
function Slot(props) {
|
|
2514
|
+
return (() => {
|
|
2515
|
+
const _el$ = _tmpl$11();
|
|
2516
|
+
_el$.style.setProperty("pointer-events", "auto");
|
|
2517
|
+
spread(_el$, mergeProps(() => !props.builderContext.context?.symbolId && {
|
|
2518
|
+
"builder-slot": props.name
|
|
2519
|
+
}), false, true);
|
|
2520
|
+
insert(_el$, createComponent(blocks_default, {
|
|
2521
|
+
get parent() {
|
|
2522
|
+
return props.builderContext.context?.symbolId;
|
|
2523
|
+
},
|
|
2524
|
+
get path() {
|
|
2525
|
+
return `symbol.data.${props.name}`;
|
|
2526
|
+
},
|
|
2527
|
+
get context() {
|
|
2528
|
+
return props.builderContext;
|
|
2529
|
+
},
|
|
2530
|
+
get blocks() {
|
|
2531
|
+
return props.builderContext.rootState?.[props.name];
|
|
2532
|
+
}
|
|
2533
|
+
}));
|
|
2534
|
+
return _el$;
|
|
2535
|
+
})();
|
|
2536
|
+
}
|
|
2537
|
+
var slot_default = Slot;
|
|
2538
|
+
|
|
2539
|
+
// src/blocks/symbol/component-info.ts
|
|
2540
|
+
var componentInfo10 = {
|
|
2494
2541
|
name: "Symbol",
|
|
2495
2542
|
noWrap: true,
|
|
2496
2543
|
static: true,
|
|
@@ -2526,7 +2573,7 @@ var componentInfo9 = {
|
|
|
2526
2573
|
};
|
|
2527
2574
|
|
|
2528
2575
|
// src/blocks/text/component-info.ts
|
|
2529
|
-
var
|
|
2576
|
+
var componentInfo11 = {
|
|
2530
2577
|
name: "Text",
|
|
2531
2578
|
static: true,
|
|
2532
2579
|
isRSC: true,
|
|
@@ -2545,10 +2592,10 @@ var componentInfo10 = {
|
|
|
2545
2592
|
textAlign: "center"
|
|
2546
2593
|
}
|
|
2547
2594
|
};
|
|
2548
|
-
var _tmpl$
|
|
2595
|
+
var _tmpl$12 = /* @__PURE__ */ template(`<div class=builder-text>`);
|
|
2549
2596
|
function Text(props) {
|
|
2550
2597
|
return (() => {
|
|
2551
|
-
const _el$ = _tmpl$
|
|
2598
|
+
const _el$ = _tmpl$12();
|
|
2552
2599
|
_el$.style.setProperty("outline", "none");
|
|
2553
2600
|
effect(() => _el$.innerHTML = props.text?.toString() || "");
|
|
2554
2601
|
return _el$;
|
|
@@ -2557,7 +2604,7 @@ function Text(props) {
|
|
|
2557
2604
|
var text_default = Text;
|
|
2558
2605
|
|
|
2559
2606
|
// src/blocks/video/component-info.ts
|
|
2560
|
-
var
|
|
2607
|
+
var componentInfo12 = {
|
|
2561
2608
|
name: "Video",
|
|
2562
2609
|
canHaveChildren: true,
|
|
2563
2610
|
defaultStyles: {
|
|
@@ -2639,7 +2686,7 @@ var componentInfo11 = {
|
|
|
2639
2686
|
advanced: true
|
|
2640
2687
|
}]
|
|
2641
2688
|
};
|
|
2642
|
-
var _tmpl$
|
|
2689
|
+
var _tmpl$13 = /* @__PURE__ */ template(`<source type=video/mp4>`);
|
|
2643
2690
|
var _tmpl$23 = /* @__PURE__ */ template(`<div>`);
|
|
2644
2691
|
var _tmpl$33 = /* @__PURE__ */ template(`<div><video class=builder-video>`);
|
|
2645
2692
|
function Video(props) {
|
|
@@ -2702,7 +2749,7 @@ function Video(props) {
|
|
|
2702
2749
|
return !props.lazyLoad;
|
|
2703
2750
|
},
|
|
2704
2751
|
get children() {
|
|
2705
|
-
const _el$3 = _tmpl$
|
|
2752
|
+
const _el$3 = _tmpl$13();
|
|
2706
2753
|
effect(() => setAttribute(_el$3, "src", props.video));
|
|
2707
2754
|
return _el$3;
|
|
2708
2755
|
}
|
|
@@ -2784,13 +2831,16 @@ var getDefaultRegisteredComponents = () => [{
|
|
|
2784
2831
|
...componentInfo8
|
|
2785
2832
|
}, {
|
|
2786
2833
|
component: symbol_default,
|
|
2787
|
-
...
|
|
2834
|
+
...componentInfo10
|
|
2788
2835
|
}, {
|
|
2789
2836
|
component: text_default,
|
|
2790
|
-
...
|
|
2837
|
+
...componentInfo11
|
|
2791
2838
|
}, {
|
|
2792
2839
|
component: video_default,
|
|
2793
|
-
...
|
|
2840
|
+
...componentInfo12
|
|
2841
|
+
}, {
|
|
2842
|
+
component: slot_default,
|
|
2843
|
+
...componentInfo9
|
|
2794
2844
|
}];
|
|
2795
2845
|
|
|
2796
2846
|
// src/functions/register-component.ts
|
|
@@ -2861,10 +2911,10 @@ var getUpdateVariantVisibilityScript = ({
|
|
|
2861
2911
|
}) => `window.${UPDATE_VARIANT_VISIBILITY_SCRIPT_FN_NAME}(
|
|
2862
2912
|
"${variationId}", "${contentId}", ${isHydrationTarget}
|
|
2863
2913
|
)`;
|
|
2864
|
-
var _tmpl$
|
|
2914
|
+
var _tmpl$14 = /* @__PURE__ */ template(`<script>`);
|
|
2865
2915
|
function InlinedScript(props) {
|
|
2866
2916
|
return (() => {
|
|
2867
|
-
const _el$ = _tmpl$
|
|
2917
|
+
const _el$ = _tmpl$14();
|
|
2868
2918
|
effect((_p$) => {
|
|
2869
2919
|
const _v$ = props.scriptStr, _v$2 = props.id || "";
|
|
2870
2920
|
_v$ !== _p$._v$ && (_el$.innerHTML = _p$._v$ = _v$);
|
|
@@ -3111,6 +3161,13 @@ async function fetchEntries(options) {
|
|
|
3111
3161
|
}
|
|
3112
3162
|
var getAllContent = fetchEntries;
|
|
3113
3163
|
|
|
3164
|
+
// src/functions/is-from-trusted-host.ts
|
|
3165
|
+
var DEFAULT_TRUSTED_HOSTS = ["*.beta.builder.io", "beta.builder.io", "builder.io", "localhost", "qa.builder.io"];
|
|
3166
|
+
function isFromTrustedHost(trustedHosts, e) {
|
|
3167
|
+
const url = new URL(e.origin), hostname = url.hostname;
|
|
3168
|
+
return (trustedHosts || DEFAULT_TRUSTED_HOSTS).findIndex((trustedHost) => trustedHost.startsWith("*.") ? hostname.endsWith(trustedHost.slice(1)) : trustedHost === hostname) > -1;
|
|
3169
|
+
}
|
|
3170
|
+
|
|
3114
3171
|
// src/functions/is-previewing.ts
|
|
3115
3172
|
function isPreviewing() {
|
|
3116
3173
|
if (!isBrowser()) {
|
|
@@ -3359,7 +3416,7 @@ var getInteractionPropertiesForEvent = (event) => {
|
|
|
3359
3416
|
};
|
|
3360
3417
|
|
|
3361
3418
|
// src/constants/sdk-version.ts
|
|
3362
|
-
var SDK_VERSION = "0.12.
|
|
3419
|
+
var SDK_VERSION = "0.12.2";
|
|
3363
3420
|
|
|
3364
3421
|
// src/functions/register.ts
|
|
3365
3422
|
var registry = {};
|
|
@@ -3436,9 +3493,13 @@ var setupBrowserForEditing = (options = {}) => {
|
|
|
3436
3493
|
options
|
|
3437
3494
|
}
|
|
3438
3495
|
}, "*");
|
|
3439
|
-
window.addEventListener("message", ({
|
|
3440
|
-
|
|
3441
|
-
|
|
3496
|
+
window.addEventListener("message", (event) => {
|
|
3497
|
+
if (!isFromTrustedHost(options.trustedHosts, event)) {
|
|
3498
|
+
return;
|
|
3499
|
+
}
|
|
3500
|
+
const {
|
|
3501
|
+
data
|
|
3502
|
+
} = event;
|
|
3442
3503
|
if (!data?.type) {
|
|
3443
3504
|
return;
|
|
3444
3505
|
}
|
|
@@ -3534,6 +3595,9 @@ function EnableEditor(props) {
|
|
|
3534
3595
|
}));
|
|
3535
3596
|
}
|
|
3536
3597
|
function processMessage(event) {
|
|
3598
|
+
if (!isFromTrustedHost(props.trustedHosts, event)) {
|
|
3599
|
+
return;
|
|
3600
|
+
}
|
|
3537
3601
|
const {
|
|
3538
3602
|
data
|
|
3539
3603
|
} = event;
|
|
@@ -3664,6 +3728,9 @@ function EnableEditor(props) {
|
|
|
3664
3728
|
} : {},
|
|
3665
3729
|
...props.enrich ? {
|
|
3666
3730
|
enrich: props.enrich
|
|
3731
|
+
} : {},
|
|
3732
|
+
...props.trustedHosts ? {
|
|
3733
|
+
trustedHosts: props.trustedHosts
|
|
3667
3734
|
} : {}
|
|
3668
3735
|
});
|
|
3669
3736
|
Object.values(props.builderContextSignal.componentInfos).forEach((registeredComponent) => {
|
|
@@ -4031,6 +4098,9 @@ function ContentComponent(props) {
|
|
|
4031
4098
|
},
|
|
4032
4099
|
get contentWrapperProps() {
|
|
4033
4100
|
return props.contentWrapperProps;
|
|
4101
|
+
},
|
|
4102
|
+
get trustedHosts() {
|
|
4103
|
+
return props.trustedHosts;
|
|
4034
4104
|
}
|
|
4035
4105
|
}, {
|
|
4036
4106
|
setBuilderContextSignal
|
|
@@ -4190,6 +4260,9 @@ function ContentVariants(props) {
|
|
|
4190
4260
|
},
|
|
4191
4261
|
get contentWrapperProps() {
|
|
4192
4262
|
return props.contentWrapperProps;
|
|
4263
|
+
},
|
|
4264
|
+
get trustedHosts() {
|
|
4265
|
+
return props.trustedHosts;
|
|
4193
4266
|
}
|
|
4194
4267
|
});
|
|
4195
4268
|
}
|
|
@@ -4244,6 +4317,9 @@ function ContentVariants(props) {
|
|
|
4244
4317
|
},
|
|
4245
4318
|
get contentWrapperProps() {
|
|
4246
4319
|
return props.contentWrapperProps;
|
|
4320
|
+
},
|
|
4321
|
+
get trustedHosts() {
|
|
4322
|
+
return props.trustedHosts;
|
|
4247
4323
|
}
|
|
4248
4324
|
}))];
|
|
4249
4325
|
}
|
|
@@ -4274,7 +4350,7 @@ var fetchSymbolContent = async ({
|
|
|
4274
4350
|
};
|
|
4275
4351
|
|
|
4276
4352
|
// src/blocks/symbol/symbol.tsx
|
|
4277
|
-
var _tmpl$
|
|
4353
|
+
var _tmpl$15 = /* @__PURE__ */ template(`<div>`);
|
|
4278
4354
|
function Symbol(props) {
|
|
4279
4355
|
const [contentToUse, setContentToUse] = createSignal(props.symbol?.content);
|
|
4280
4356
|
function className() {
|
|
@@ -4300,7 +4376,7 @@ function Symbol(props) {
|
|
|
4300
4376
|
}
|
|
4301
4377
|
createEffect(on(() => [props.symbol], onUpdateFn_0));
|
|
4302
4378
|
return (() => {
|
|
4303
|
-
const _el$ = _tmpl$
|
|
4379
|
+
const _el$ = _tmpl$15();
|
|
4304
4380
|
spread(_el$, mergeProps({
|
|
4305
4381
|
get ["class"]() {
|
|
4306
4382
|
return className();
|
|
@@ -4315,7 +4391,10 @@ function Symbol(props) {
|
|
|
4315
4391
|
return props.builderContext.apiKey;
|
|
4316
4392
|
},
|
|
4317
4393
|
get context() {
|
|
4318
|
-
return
|
|
4394
|
+
return {
|
|
4395
|
+
...props.builderContext.context,
|
|
4396
|
+
symbolId: props.builderBlock?.id
|
|
4397
|
+
};
|
|
4319
4398
|
},
|
|
4320
4399
|
get customComponents() {
|
|
4321
4400
|
return Object.values(props.builderComponents);
|