@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/browser/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
|
|
|
@@ -331,10 +331,6 @@ function getProcessedBlock({
|
|
|
331
331
|
}
|
|
332
332
|
|
|
333
333
|
// 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
334
|
var getComponent = ({
|
|
339
335
|
block,
|
|
340
336
|
context,
|
|
@@ -653,48 +649,80 @@ function getStyleAttribute(style) {
|
|
|
653
649
|
}
|
|
654
650
|
}
|
|
655
651
|
|
|
656
|
-
// src/components/
|
|
657
|
-
|
|
652
|
+
// src/components/dynamic-renderer/dynamic-renderer.helpers.ts
|
|
653
|
+
var EMPTY_HTML_ELEMENTS = /* @__PURE__ */ new Set(["area", "base", "br", "col", "embed", "hr", "img", "input", "keygen", "link", "meta", "param", "source", "track", "wbr"]);
|
|
654
|
+
var isEmptyElement = (tagName) => {
|
|
655
|
+
return typeof tagName === "string" && EMPTY_HTML_ELEMENTS.has(tagName.toLowerCase());
|
|
656
|
+
};
|
|
657
|
+
|
|
658
|
+
// src/components/dynamic-renderer/dynamic-renderer.tsx
|
|
659
|
+
function DynamicRenderer(props) {
|
|
658
660
|
return createComponent(Show, {
|
|
659
661
|
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
|
-
}), {
|
|
662
|
+
return createComponent(Dynamic, mergeProps(() => props.attributes, () => props.actionAttributes, {
|
|
671
663
|
get component() {
|
|
672
|
-
return props.
|
|
664
|
+
return props.TagName;
|
|
673
665
|
}
|
|
674
666
|
}));
|
|
675
667
|
},
|
|
676
668
|
get when() {
|
|
677
|
-
return props.
|
|
669
|
+
return !isEmptyElement(props.TagName);
|
|
678
670
|
},
|
|
679
671
|
get children() {
|
|
680
|
-
return createComponent(
|
|
672
|
+
return createComponent(Show, {
|
|
673
|
+
get fallback() {
|
|
674
|
+
return createComponent(Dynamic, mergeProps(() => props.attributes, () => props.actionAttributes, {
|
|
675
|
+
get component() {
|
|
676
|
+
return props.TagName;
|
|
677
|
+
},
|
|
678
|
+
get children() {
|
|
679
|
+
return props.children;
|
|
680
|
+
}
|
|
681
|
+
}));
|
|
682
|
+
},
|
|
683
|
+
get when() {
|
|
684
|
+
return typeof props.TagName === "string";
|
|
685
|
+
},
|
|
686
|
+
get children() {
|
|
687
|
+
return createComponent(Dynamic, mergeProps(() => props.attributes, () => props.actionAttributes, {
|
|
688
|
+
get component() {
|
|
689
|
+
return props.TagName;
|
|
690
|
+
},
|
|
691
|
+
get children() {
|
|
692
|
+
return props.children;
|
|
693
|
+
}
|
|
694
|
+
}));
|
|
695
|
+
}
|
|
696
|
+
});
|
|
697
|
+
}
|
|
698
|
+
});
|
|
699
|
+
}
|
|
700
|
+
var dynamic_renderer_default = DynamicRenderer;
|
|
701
|
+
|
|
702
|
+
// src/components/block/components/block-wrapper.tsx
|
|
703
|
+
function BlockWrapper(props) {
|
|
704
|
+
return createComponent(dynamic_renderer_default, {
|
|
705
|
+
get TagName() {
|
|
706
|
+
return props.Wrapper;
|
|
707
|
+
},
|
|
708
|
+
get attributes() {
|
|
709
|
+
return getBlockProperties({
|
|
681
710
|
block: props.block,
|
|
682
711
|
context: props.context
|
|
683
|
-
})
|
|
712
|
+
});
|
|
713
|
+
},
|
|
714
|
+
get actionAttributes() {
|
|
715
|
+
return getBlockActions({
|
|
684
716
|
block: props.block,
|
|
685
717
|
rootState: props.context.rootState,
|
|
686
718
|
rootSetState: props.context.rootSetState,
|
|
687
719
|
localState: props.context.localState,
|
|
688
720
|
context: props.context.context,
|
|
689
721
|
stripPrefix: true
|
|
690
|
-
})
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
get children() {
|
|
695
|
-
return props.children;
|
|
696
|
-
}
|
|
697
|
-
}));
|
|
722
|
+
});
|
|
723
|
+
},
|
|
724
|
+
get children() {
|
|
725
|
+
return props.children;
|
|
698
726
|
}
|
|
699
727
|
});
|
|
700
728
|
}
|
|
@@ -935,29 +963,8 @@ function Block(props) {
|
|
|
935
963
|
return !blockComponent()?.noWrap;
|
|
936
964
|
},
|
|
937
965
|
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() {
|
|
966
|
+
return createComponent(Show, {
|
|
967
|
+
get fallback() {
|
|
961
968
|
return createComponent(For, {
|
|
962
969
|
get each() {
|
|
963
970
|
return repeatItem();
|
|
@@ -978,10 +985,9 @@ function Block(props) {
|
|
|
978
985
|
});
|
|
979
986
|
}
|
|
980
987
|
});
|
|
981
|
-
}
|
|
982
|
-
}), createComponent(Show, {
|
|
988
|
+
},
|
|
983
989
|
get when() {
|
|
984
|
-
return
|
|
990
|
+
return !repeatItem();
|
|
985
991
|
},
|
|
986
992
|
get children() {
|
|
987
993
|
return createComponent(block_wrapper_default, {
|
|
@@ -994,7 +1000,6 @@ function Block(props) {
|
|
|
994
1000
|
get context() {
|
|
995
1001
|
return props.context;
|
|
996
1002
|
},
|
|
997
|
-
hasChildren: true,
|
|
998
1003
|
get children() {
|
|
999
1004
|
return [createComponent(component_ref_default, {
|
|
1000
1005
|
get componentRef() {
|
|
@@ -1044,7 +1049,7 @@ function Block(props) {
|
|
|
1044
1049
|
}
|
|
1045
1050
|
});
|
|
1046
1051
|
}
|
|
1047
|
-
})
|
|
1052
|
+
});
|
|
1048
1053
|
}
|
|
1049
1054
|
})];
|
|
1050
1055
|
}
|
|
@@ -2366,8 +2371,50 @@ var componentInfo8 = {
|
|
|
2366
2371
|
}]
|
|
2367
2372
|
};
|
|
2368
2373
|
|
|
2369
|
-
// src/blocks/
|
|
2374
|
+
// src/blocks/slot/component-info.ts
|
|
2370
2375
|
var componentInfo9 = {
|
|
2376
|
+
name: "Slot",
|
|
2377
|
+
isRSC: true,
|
|
2378
|
+
description: "Allow child blocks to be inserted into this content when used as a Symbol",
|
|
2379
|
+
docsLink: "https://www.builder.io/c/docs/symbols-with-blocks",
|
|
2380
|
+
image: "https://cdn.builder.io/api/v1/image/assets%2FYJIGb4i01jvw0SRdL5Bt%2F3aad6de36eae43b59b52c85190fdef56",
|
|
2381
|
+
// Maybe wrap this for canHaveChildren so bind children to this hm
|
|
2382
|
+
inputs: [{
|
|
2383
|
+
name: "name",
|
|
2384
|
+
type: "string",
|
|
2385
|
+
required: true,
|
|
2386
|
+
defaultValue: "children"
|
|
2387
|
+
}]
|
|
2388
|
+
};
|
|
2389
|
+
var _tmpl$11 = /* @__PURE__ */ template(`<div>`);
|
|
2390
|
+
function Slot(props) {
|
|
2391
|
+
return (() => {
|
|
2392
|
+
const _el$ = _tmpl$11();
|
|
2393
|
+
_el$.style.setProperty("pointer-events", "auto");
|
|
2394
|
+
spread(_el$, mergeProps(() => !props.builderContext.context?.symbolId && {
|
|
2395
|
+
"builder-slot": props.name
|
|
2396
|
+
}), false, true);
|
|
2397
|
+
insert(_el$, createComponent(blocks_default, {
|
|
2398
|
+
get parent() {
|
|
2399
|
+
return props.builderContext.context?.symbolId;
|
|
2400
|
+
},
|
|
2401
|
+
get path() {
|
|
2402
|
+
return `symbol.data.${props.name}`;
|
|
2403
|
+
},
|
|
2404
|
+
get context() {
|
|
2405
|
+
return props.builderContext;
|
|
2406
|
+
},
|
|
2407
|
+
get blocks() {
|
|
2408
|
+
return props.builderContext.rootState?.[props.name];
|
|
2409
|
+
}
|
|
2410
|
+
}));
|
|
2411
|
+
return _el$;
|
|
2412
|
+
})();
|
|
2413
|
+
}
|
|
2414
|
+
var slot_default = Slot;
|
|
2415
|
+
|
|
2416
|
+
// src/blocks/symbol/component-info.ts
|
|
2417
|
+
var componentInfo10 = {
|
|
2371
2418
|
name: "Symbol",
|
|
2372
2419
|
noWrap: true,
|
|
2373
2420
|
static: true,
|
|
@@ -2403,7 +2450,7 @@ var componentInfo9 = {
|
|
|
2403
2450
|
};
|
|
2404
2451
|
|
|
2405
2452
|
// src/blocks/text/component-info.ts
|
|
2406
|
-
var
|
|
2453
|
+
var componentInfo11 = {
|
|
2407
2454
|
name: "Text",
|
|
2408
2455
|
static: true,
|
|
2409
2456
|
isRSC: true,
|
|
@@ -2422,10 +2469,10 @@ var componentInfo10 = {
|
|
|
2422
2469
|
textAlign: "center"
|
|
2423
2470
|
}
|
|
2424
2471
|
};
|
|
2425
|
-
var _tmpl$
|
|
2472
|
+
var _tmpl$12 = /* @__PURE__ */ template(`<div class=builder-text>`);
|
|
2426
2473
|
function Text(props) {
|
|
2427
2474
|
return (() => {
|
|
2428
|
-
const _el$ = _tmpl$
|
|
2475
|
+
const _el$ = _tmpl$12();
|
|
2429
2476
|
_el$.style.setProperty("outline", "none");
|
|
2430
2477
|
effect(() => _el$.innerHTML = props.text?.toString() || "");
|
|
2431
2478
|
return _el$;
|
|
@@ -2434,7 +2481,7 @@ function Text(props) {
|
|
|
2434
2481
|
var text_default = Text;
|
|
2435
2482
|
|
|
2436
2483
|
// src/blocks/video/component-info.ts
|
|
2437
|
-
var
|
|
2484
|
+
var componentInfo12 = {
|
|
2438
2485
|
name: "Video",
|
|
2439
2486
|
canHaveChildren: true,
|
|
2440
2487
|
defaultStyles: {
|
|
@@ -2516,7 +2563,7 @@ var componentInfo11 = {
|
|
|
2516
2563
|
advanced: true
|
|
2517
2564
|
}]
|
|
2518
2565
|
};
|
|
2519
|
-
var _tmpl$
|
|
2566
|
+
var _tmpl$13 = /* @__PURE__ */ template(`<source type=video/mp4>`);
|
|
2520
2567
|
var _tmpl$23 = /* @__PURE__ */ template(`<div>`);
|
|
2521
2568
|
var _tmpl$33 = /* @__PURE__ */ template(`<div><video class=builder-video>`);
|
|
2522
2569
|
function Video(props) {
|
|
@@ -2579,7 +2626,7 @@ function Video(props) {
|
|
|
2579
2626
|
return !props.lazyLoad;
|
|
2580
2627
|
},
|
|
2581
2628
|
get children() {
|
|
2582
|
-
const _el$3 = _tmpl$
|
|
2629
|
+
const _el$3 = _tmpl$13();
|
|
2583
2630
|
effect(() => setAttribute(_el$3, "src", props.video));
|
|
2584
2631
|
return _el$3;
|
|
2585
2632
|
}
|
|
@@ -2661,13 +2708,16 @@ var getDefaultRegisteredComponents = () => [{
|
|
|
2661
2708
|
...componentInfo8
|
|
2662
2709
|
}, {
|
|
2663
2710
|
component: symbol_default,
|
|
2664
|
-
...
|
|
2711
|
+
...componentInfo10
|
|
2665
2712
|
}, {
|
|
2666
2713
|
component: text_default,
|
|
2667
|
-
...
|
|
2714
|
+
...componentInfo11
|
|
2668
2715
|
}, {
|
|
2669
2716
|
component: video_default,
|
|
2670
|
-
...
|
|
2717
|
+
...componentInfo12
|
|
2718
|
+
}, {
|
|
2719
|
+
component: slot_default,
|
|
2720
|
+
...componentInfo9
|
|
2671
2721
|
}];
|
|
2672
2722
|
|
|
2673
2723
|
// src/functions/register-component.ts
|
|
@@ -2738,10 +2788,10 @@ var getUpdateVariantVisibilityScript = ({
|
|
|
2738
2788
|
}) => `window.${UPDATE_VARIANT_VISIBILITY_SCRIPT_FN_NAME}(
|
|
2739
2789
|
"${variationId}", "${contentId}", ${isHydrationTarget}
|
|
2740
2790
|
)`;
|
|
2741
|
-
var _tmpl$
|
|
2791
|
+
var _tmpl$14 = /* @__PURE__ */ template(`<script>`);
|
|
2742
2792
|
function InlinedScript(props) {
|
|
2743
2793
|
return (() => {
|
|
2744
|
-
const _el$ = _tmpl$
|
|
2794
|
+
const _el$ = _tmpl$14();
|
|
2745
2795
|
effect((_p$) => {
|
|
2746
2796
|
const _v$ = props.scriptStr, _v$2 = props.id || "";
|
|
2747
2797
|
_v$ !== _p$._v$ && (_el$.innerHTML = _p$._v$ = _v$);
|
|
@@ -2988,6 +3038,13 @@ async function fetchEntries(options) {
|
|
|
2988
3038
|
}
|
|
2989
3039
|
var getAllContent = fetchEntries;
|
|
2990
3040
|
|
|
3041
|
+
// src/functions/is-from-trusted-host.ts
|
|
3042
|
+
var DEFAULT_TRUSTED_HOSTS = ["*.beta.builder.io", "beta.builder.io", "builder.io", "localhost", "qa.builder.io"];
|
|
3043
|
+
function isFromTrustedHost(trustedHosts, e) {
|
|
3044
|
+
const url = new URL(e.origin), hostname = url.hostname;
|
|
3045
|
+
return (trustedHosts || DEFAULT_TRUSTED_HOSTS).findIndex((trustedHost) => trustedHost.startsWith("*.") ? hostname.endsWith(trustedHost.slice(1)) : trustedHost === hostname) > -1;
|
|
3046
|
+
}
|
|
3047
|
+
|
|
2991
3048
|
// src/functions/is-previewing.ts
|
|
2992
3049
|
function isPreviewing() {
|
|
2993
3050
|
if (!isBrowser()) {
|
|
@@ -3236,7 +3293,7 @@ var getInteractionPropertiesForEvent = (event) => {
|
|
|
3236
3293
|
};
|
|
3237
3294
|
|
|
3238
3295
|
// src/constants/sdk-version.ts
|
|
3239
|
-
var SDK_VERSION = "0.12.
|
|
3296
|
+
var SDK_VERSION = "0.12.2";
|
|
3240
3297
|
|
|
3241
3298
|
// src/functions/register.ts
|
|
3242
3299
|
var registry = {};
|
|
@@ -3313,9 +3370,13 @@ var setupBrowserForEditing = (options = {}) => {
|
|
|
3313
3370
|
options
|
|
3314
3371
|
}
|
|
3315
3372
|
}, "*");
|
|
3316
|
-
window.addEventListener("message", ({
|
|
3317
|
-
|
|
3318
|
-
|
|
3373
|
+
window.addEventListener("message", (event) => {
|
|
3374
|
+
if (!isFromTrustedHost(options.trustedHosts, event)) {
|
|
3375
|
+
return;
|
|
3376
|
+
}
|
|
3377
|
+
const {
|
|
3378
|
+
data
|
|
3379
|
+
} = event;
|
|
3319
3380
|
if (!data?.type) {
|
|
3320
3381
|
return;
|
|
3321
3382
|
}
|
|
@@ -3411,6 +3472,9 @@ function EnableEditor(props) {
|
|
|
3411
3472
|
}));
|
|
3412
3473
|
}
|
|
3413
3474
|
function processMessage(event) {
|
|
3475
|
+
if (!isFromTrustedHost(props.trustedHosts, event)) {
|
|
3476
|
+
return;
|
|
3477
|
+
}
|
|
3414
3478
|
const {
|
|
3415
3479
|
data
|
|
3416
3480
|
} = event;
|
|
@@ -3541,6 +3605,9 @@ function EnableEditor(props) {
|
|
|
3541
3605
|
} : {},
|
|
3542
3606
|
...props.enrich ? {
|
|
3543
3607
|
enrich: props.enrich
|
|
3608
|
+
} : {},
|
|
3609
|
+
...props.trustedHosts ? {
|
|
3610
|
+
trustedHosts: props.trustedHosts
|
|
3544
3611
|
} : {}
|
|
3545
3612
|
});
|
|
3546
3613
|
Object.values(props.builderContextSignal.componentInfos).forEach((registeredComponent) => {
|
|
@@ -3908,6 +3975,9 @@ function ContentComponent(props) {
|
|
|
3908
3975
|
},
|
|
3909
3976
|
get contentWrapperProps() {
|
|
3910
3977
|
return props.contentWrapperProps;
|
|
3978
|
+
},
|
|
3979
|
+
get trustedHosts() {
|
|
3980
|
+
return props.trustedHosts;
|
|
3911
3981
|
}
|
|
3912
3982
|
}, {
|
|
3913
3983
|
setBuilderContextSignal
|
|
@@ -4067,6 +4137,9 @@ function ContentVariants(props) {
|
|
|
4067
4137
|
},
|
|
4068
4138
|
get contentWrapperProps() {
|
|
4069
4139
|
return props.contentWrapperProps;
|
|
4140
|
+
},
|
|
4141
|
+
get trustedHosts() {
|
|
4142
|
+
return props.trustedHosts;
|
|
4070
4143
|
}
|
|
4071
4144
|
});
|
|
4072
4145
|
}
|
|
@@ -4121,6 +4194,9 @@ function ContentVariants(props) {
|
|
|
4121
4194
|
},
|
|
4122
4195
|
get contentWrapperProps() {
|
|
4123
4196
|
return props.contentWrapperProps;
|
|
4197
|
+
},
|
|
4198
|
+
get trustedHosts() {
|
|
4199
|
+
return props.trustedHosts;
|
|
4124
4200
|
}
|
|
4125
4201
|
}))];
|
|
4126
4202
|
}
|
|
@@ -4151,7 +4227,7 @@ var fetchSymbolContent = async ({
|
|
|
4151
4227
|
};
|
|
4152
4228
|
|
|
4153
4229
|
// src/blocks/symbol/symbol.tsx
|
|
4154
|
-
var _tmpl$
|
|
4230
|
+
var _tmpl$15 = /* @__PURE__ */ template(`<div>`);
|
|
4155
4231
|
function Symbol(props) {
|
|
4156
4232
|
const [contentToUse, setContentToUse] = createSignal(props.symbol?.content);
|
|
4157
4233
|
function className() {
|
|
@@ -4177,7 +4253,7 @@ function Symbol(props) {
|
|
|
4177
4253
|
}
|
|
4178
4254
|
createEffect(on(() => [props.symbol], onUpdateFn_0));
|
|
4179
4255
|
return (() => {
|
|
4180
|
-
const _el$ = _tmpl$
|
|
4256
|
+
const _el$ = _tmpl$15();
|
|
4181
4257
|
spread(_el$, mergeProps({
|
|
4182
4258
|
get ["class"]() {
|
|
4183
4259
|
return className();
|
|
@@ -4192,7 +4268,10 @@ function Symbol(props) {
|
|
|
4192
4268
|
return props.builderContext.apiKey;
|
|
4193
4269
|
},
|
|
4194
4270
|
get context() {
|
|
4195
|
-
return
|
|
4271
|
+
return {
|
|
4272
|
+
...props.builderContext.context,
|
|
4273
|
+
symbolId: props.builderBlock?.id
|
|
4274
|
+
};
|
|
4196
4275
|
},
|
|
4197
4276
|
get customComponents() {
|
|
4198
4277
|
return Object.values(props.builderComponents);
|