@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/edge/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
|
|
|
@@ -3484,10 +3484,6 @@ function getProcessedBlock({
|
|
|
3484
3484
|
}
|
|
3485
3485
|
|
|
3486
3486
|
// src/components/block/block.helpers.ts
|
|
3487
|
-
var EMPTY_HTML_ELEMENTS = ["area", "base", "br", "col", "embed", "hr", "img", "input", "keygen", "link", "meta", "param", "source", "track", "wbr"];
|
|
3488
|
-
var isEmptyHtmlElement = (tagName) => {
|
|
3489
|
-
return typeof tagName === "string" && EMPTY_HTML_ELEMENTS.includes(tagName.toLowerCase());
|
|
3490
|
-
};
|
|
3491
3487
|
var getComponent = ({
|
|
3492
3488
|
block,
|
|
3493
3489
|
context,
|
|
@@ -3806,48 +3802,80 @@ function getStyleAttribute(style) {
|
|
|
3806
3802
|
}
|
|
3807
3803
|
}
|
|
3808
3804
|
|
|
3809
|
-
// src/components/
|
|
3810
|
-
|
|
3805
|
+
// src/components/dynamic-renderer/dynamic-renderer.helpers.ts
|
|
3806
|
+
var EMPTY_HTML_ELEMENTS = /* @__PURE__ */ new Set(["area", "base", "br", "col", "embed", "hr", "img", "input", "keygen", "link", "meta", "param", "source", "track", "wbr"]);
|
|
3807
|
+
var isEmptyElement = (tagName) => {
|
|
3808
|
+
return typeof tagName === "string" && EMPTY_HTML_ELEMENTS.has(tagName.toLowerCase());
|
|
3809
|
+
};
|
|
3810
|
+
|
|
3811
|
+
// src/components/dynamic-renderer/dynamic-renderer.tsx
|
|
3812
|
+
function DynamicRenderer(props) {
|
|
3811
3813
|
return createComponent(Show, {
|
|
3812
3814
|
get fallback() {
|
|
3813
|
-
return createComponent(Dynamic, mergeProps(() =>
|
|
3814
|
-
block: props.block,
|
|
3815
|
-
context: props.context
|
|
3816
|
-
}), () => getBlockActions({
|
|
3817
|
-
block: props.block,
|
|
3818
|
-
rootState: props.context.rootState,
|
|
3819
|
-
rootSetState: props.context.rootSetState,
|
|
3820
|
-
localState: props.context.localState,
|
|
3821
|
-
context: props.context.context,
|
|
3822
|
-
stripPrefix: true
|
|
3823
|
-
}), {
|
|
3815
|
+
return createComponent(Dynamic, mergeProps(() => props.attributes, () => props.actionAttributes, {
|
|
3824
3816
|
get component() {
|
|
3825
|
-
return props.
|
|
3817
|
+
return props.TagName;
|
|
3826
3818
|
}
|
|
3827
3819
|
}));
|
|
3828
3820
|
},
|
|
3829
3821
|
get when() {
|
|
3830
|
-
return props.
|
|
3822
|
+
return !isEmptyElement(props.TagName);
|
|
3831
3823
|
},
|
|
3832
3824
|
get children() {
|
|
3833
|
-
return createComponent(
|
|
3825
|
+
return createComponent(Show, {
|
|
3826
|
+
get fallback() {
|
|
3827
|
+
return createComponent(Dynamic, mergeProps(() => props.attributes, () => props.actionAttributes, {
|
|
3828
|
+
get component() {
|
|
3829
|
+
return props.TagName;
|
|
3830
|
+
},
|
|
3831
|
+
get children() {
|
|
3832
|
+
return props.children;
|
|
3833
|
+
}
|
|
3834
|
+
}));
|
|
3835
|
+
},
|
|
3836
|
+
get when() {
|
|
3837
|
+
return typeof props.TagName === "string";
|
|
3838
|
+
},
|
|
3839
|
+
get children() {
|
|
3840
|
+
return createComponent(Dynamic, mergeProps(() => props.attributes, () => props.actionAttributes, {
|
|
3841
|
+
get component() {
|
|
3842
|
+
return props.TagName;
|
|
3843
|
+
},
|
|
3844
|
+
get children() {
|
|
3845
|
+
return props.children;
|
|
3846
|
+
}
|
|
3847
|
+
}));
|
|
3848
|
+
}
|
|
3849
|
+
});
|
|
3850
|
+
}
|
|
3851
|
+
});
|
|
3852
|
+
}
|
|
3853
|
+
var dynamic_renderer_default = DynamicRenderer;
|
|
3854
|
+
|
|
3855
|
+
// src/components/block/components/block-wrapper.tsx
|
|
3856
|
+
function BlockWrapper(props) {
|
|
3857
|
+
return createComponent(dynamic_renderer_default, {
|
|
3858
|
+
get TagName() {
|
|
3859
|
+
return props.Wrapper;
|
|
3860
|
+
},
|
|
3861
|
+
get attributes() {
|
|
3862
|
+
return getBlockProperties({
|
|
3834
3863
|
block: props.block,
|
|
3835
3864
|
context: props.context
|
|
3836
|
-
})
|
|
3865
|
+
});
|
|
3866
|
+
},
|
|
3867
|
+
get actionAttributes() {
|
|
3868
|
+
return getBlockActions({
|
|
3837
3869
|
block: props.block,
|
|
3838
3870
|
rootState: props.context.rootState,
|
|
3839
3871
|
rootSetState: props.context.rootSetState,
|
|
3840
3872
|
localState: props.context.localState,
|
|
3841
3873
|
context: props.context.context,
|
|
3842
3874
|
stripPrefix: true
|
|
3843
|
-
})
|
|
3844
|
-
|
|
3845
|
-
|
|
3846
|
-
|
|
3847
|
-
get children() {
|
|
3848
|
-
return props.children;
|
|
3849
|
-
}
|
|
3850
|
-
}));
|
|
3875
|
+
});
|
|
3876
|
+
},
|
|
3877
|
+
get children() {
|
|
3878
|
+
return props.children;
|
|
3851
3879
|
}
|
|
3852
3880
|
});
|
|
3853
3881
|
}
|
|
@@ -4088,29 +4116,8 @@ function Block(props) {
|
|
|
4088
4116
|
return !blockComponent()?.noWrap;
|
|
4089
4117
|
},
|
|
4090
4118
|
get children() {
|
|
4091
|
-
return
|
|
4092
|
-
get
|
|
4093
|
-
return isEmptyHtmlElement(Tag());
|
|
4094
|
-
},
|
|
4095
|
-
get children() {
|
|
4096
|
-
return createComponent(block_wrapper_default, {
|
|
4097
|
-
get Wrapper() {
|
|
4098
|
-
return Tag();
|
|
4099
|
-
},
|
|
4100
|
-
get block() {
|
|
4101
|
-
return processedBlock();
|
|
4102
|
-
},
|
|
4103
|
-
get context() {
|
|
4104
|
-
return props.context;
|
|
4105
|
-
},
|
|
4106
|
-
hasChildren: false
|
|
4107
|
-
});
|
|
4108
|
-
}
|
|
4109
|
-
}), createComponent(Show, {
|
|
4110
|
-
get when() {
|
|
4111
|
-
return memo(() => !!!isEmptyHtmlElement(Tag()))() && repeatItem();
|
|
4112
|
-
},
|
|
4113
|
-
get children() {
|
|
4119
|
+
return createComponent(Show, {
|
|
4120
|
+
get fallback() {
|
|
4114
4121
|
return createComponent(For, {
|
|
4115
4122
|
get each() {
|
|
4116
4123
|
return repeatItem();
|
|
@@ -4131,10 +4138,9 @@ function Block(props) {
|
|
|
4131
4138
|
});
|
|
4132
4139
|
}
|
|
4133
4140
|
});
|
|
4134
|
-
}
|
|
4135
|
-
}), createComponent(Show, {
|
|
4141
|
+
},
|
|
4136
4142
|
get when() {
|
|
4137
|
-
return
|
|
4143
|
+
return !repeatItem();
|
|
4138
4144
|
},
|
|
4139
4145
|
get children() {
|
|
4140
4146
|
return createComponent(block_wrapper_default, {
|
|
@@ -4147,7 +4153,6 @@ function Block(props) {
|
|
|
4147
4153
|
get context() {
|
|
4148
4154
|
return props.context;
|
|
4149
4155
|
},
|
|
4150
|
-
hasChildren: true,
|
|
4151
4156
|
get children() {
|
|
4152
4157
|
return [createComponent(component_ref_default, {
|
|
4153
4158
|
get componentRef() {
|
|
@@ -4197,7 +4202,7 @@ function Block(props) {
|
|
|
4197
4202
|
}
|
|
4198
4203
|
});
|
|
4199
4204
|
}
|
|
4200
|
-
})
|
|
4205
|
+
});
|
|
4201
4206
|
}
|
|
4202
4207
|
})];
|
|
4203
4208
|
}
|
|
@@ -5519,8 +5524,50 @@ var componentInfo8 = {
|
|
|
5519
5524
|
}]
|
|
5520
5525
|
};
|
|
5521
5526
|
|
|
5522
|
-
// src/blocks/
|
|
5527
|
+
// src/blocks/slot/component-info.ts
|
|
5523
5528
|
var componentInfo9 = {
|
|
5529
|
+
name: "Slot",
|
|
5530
|
+
isRSC: true,
|
|
5531
|
+
description: "Allow child blocks to be inserted into this content when used as a Symbol",
|
|
5532
|
+
docsLink: "https://www.builder.io/c/docs/symbols-with-blocks",
|
|
5533
|
+
image: "https://cdn.builder.io/api/v1/image/assets%2FYJIGb4i01jvw0SRdL5Bt%2F3aad6de36eae43b59b52c85190fdef56",
|
|
5534
|
+
// Maybe wrap this for canHaveChildren so bind children to this hm
|
|
5535
|
+
inputs: [{
|
|
5536
|
+
name: "name",
|
|
5537
|
+
type: "string",
|
|
5538
|
+
required: true,
|
|
5539
|
+
defaultValue: "children"
|
|
5540
|
+
}]
|
|
5541
|
+
};
|
|
5542
|
+
var _tmpl$11 = /* @__PURE__ */ template(`<div>`);
|
|
5543
|
+
function Slot(props) {
|
|
5544
|
+
return (() => {
|
|
5545
|
+
const _el$ = _tmpl$11();
|
|
5546
|
+
_el$.style.setProperty("pointer-events", "auto");
|
|
5547
|
+
spread(_el$, mergeProps(() => !props.builderContext.context?.symbolId && {
|
|
5548
|
+
"builder-slot": props.name
|
|
5549
|
+
}), false, true);
|
|
5550
|
+
insert(_el$, createComponent(blocks_default, {
|
|
5551
|
+
get parent() {
|
|
5552
|
+
return props.builderContext.context?.symbolId;
|
|
5553
|
+
},
|
|
5554
|
+
get path() {
|
|
5555
|
+
return `symbol.data.${props.name}`;
|
|
5556
|
+
},
|
|
5557
|
+
get context() {
|
|
5558
|
+
return props.builderContext;
|
|
5559
|
+
},
|
|
5560
|
+
get blocks() {
|
|
5561
|
+
return props.builderContext.rootState?.[props.name];
|
|
5562
|
+
}
|
|
5563
|
+
}));
|
|
5564
|
+
return _el$;
|
|
5565
|
+
})();
|
|
5566
|
+
}
|
|
5567
|
+
var slot_default = Slot;
|
|
5568
|
+
|
|
5569
|
+
// src/blocks/symbol/component-info.ts
|
|
5570
|
+
var componentInfo10 = {
|
|
5524
5571
|
name: "Symbol",
|
|
5525
5572
|
noWrap: true,
|
|
5526
5573
|
static: true,
|
|
@@ -5556,7 +5603,7 @@ var componentInfo9 = {
|
|
|
5556
5603
|
};
|
|
5557
5604
|
|
|
5558
5605
|
// src/blocks/text/component-info.ts
|
|
5559
|
-
var
|
|
5606
|
+
var componentInfo11 = {
|
|
5560
5607
|
name: "Text",
|
|
5561
5608
|
static: true,
|
|
5562
5609
|
isRSC: true,
|
|
@@ -5575,10 +5622,10 @@ var componentInfo10 = {
|
|
|
5575
5622
|
textAlign: "center"
|
|
5576
5623
|
}
|
|
5577
5624
|
};
|
|
5578
|
-
var _tmpl$
|
|
5625
|
+
var _tmpl$12 = /* @__PURE__ */ template(`<div class=builder-text>`);
|
|
5579
5626
|
function Text(props) {
|
|
5580
5627
|
return (() => {
|
|
5581
|
-
const _el$ = _tmpl$
|
|
5628
|
+
const _el$ = _tmpl$12();
|
|
5582
5629
|
_el$.style.setProperty("outline", "none");
|
|
5583
5630
|
effect(() => _el$.innerHTML = props.text?.toString() || "");
|
|
5584
5631
|
return _el$;
|
|
@@ -5587,7 +5634,7 @@ function Text(props) {
|
|
|
5587
5634
|
var text_default = Text;
|
|
5588
5635
|
|
|
5589
5636
|
// src/blocks/video/component-info.ts
|
|
5590
|
-
var
|
|
5637
|
+
var componentInfo12 = {
|
|
5591
5638
|
name: "Video",
|
|
5592
5639
|
canHaveChildren: true,
|
|
5593
5640
|
defaultStyles: {
|
|
@@ -5669,7 +5716,7 @@ var componentInfo11 = {
|
|
|
5669
5716
|
advanced: true
|
|
5670
5717
|
}]
|
|
5671
5718
|
};
|
|
5672
|
-
var _tmpl$
|
|
5719
|
+
var _tmpl$13 = /* @__PURE__ */ template(`<source type=video/mp4>`);
|
|
5673
5720
|
var _tmpl$23 = /* @__PURE__ */ template(`<div>`);
|
|
5674
5721
|
var _tmpl$33 = /* @__PURE__ */ template(`<div><video class=builder-video>`);
|
|
5675
5722
|
function Video(props) {
|
|
@@ -5732,7 +5779,7 @@ function Video(props) {
|
|
|
5732
5779
|
return !props.lazyLoad;
|
|
5733
5780
|
},
|
|
5734
5781
|
get children() {
|
|
5735
|
-
const _el$3 = _tmpl$
|
|
5782
|
+
const _el$3 = _tmpl$13();
|
|
5736
5783
|
effect(() => setAttribute(_el$3, "src", props.video));
|
|
5737
5784
|
return _el$3;
|
|
5738
5785
|
}
|
|
@@ -5814,13 +5861,16 @@ var getDefaultRegisteredComponents = () => [{
|
|
|
5814
5861
|
...componentInfo8
|
|
5815
5862
|
}, {
|
|
5816
5863
|
component: symbol_default,
|
|
5817
|
-
...
|
|
5864
|
+
...componentInfo10
|
|
5818
5865
|
}, {
|
|
5819
5866
|
component: text_default,
|
|
5820
|
-
...
|
|
5867
|
+
...componentInfo11
|
|
5821
5868
|
}, {
|
|
5822
5869
|
component: video_default,
|
|
5823
|
-
...
|
|
5870
|
+
...componentInfo12
|
|
5871
|
+
}, {
|
|
5872
|
+
component: slot_default,
|
|
5873
|
+
...componentInfo9
|
|
5824
5874
|
}];
|
|
5825
5875
|
|
|
5826
5876
|
// src/functions/register-component.ts
|
|
@@ -5891,10 +5941,10 @@ var getUpdateVariantVisibilityScript = ({
|
|
|
5891
5941
|
}) => `window.${UPDATE_VARIANT_VISIBILITY_SCRIPT_FN_NAME}(
|
|
5892
5942
|
"${variationId}", "${contentId}", ${isHydrationTarget}
|
|
5893
5943
|
)`;
|
|
5894
|
-
var _tmpl$
|
|
5944
|
+
var _tmpl$14 = /* @__PURE__ */ template(`<script>`);
|
|
5895
5945
|
function InlinedScript(props) {
|
|
5896
5946
|
return (() => {
|
|
5897
|
-
const _el$ = _tmpl$
|
|
5947
|
+
const _el$ = _tmpl$14();
|
|
5898
5948
|
effect((_p$) => {
|
|
5899
5949
|
const _v$ = props.scriptStr, _v$2 = props.id || "";
|
|
5900
5950
|
_v$ !== _p$._v$ && (_el$.innerHTML = _p$._v$ = _v$);
|
|
@@ -6141,6 +6191,13 @@ async function fetchEntries(options) {
|
|
|
6141
6191
|
}
|
|
6142
6192
|
var getAllContent = fetchEntries;
|
|
6143
6193
|
|
|
6194
|
+
// src/functions/is-from-trusted-host.ts
|
|
6195
|
+
var DEFAULT_TRUSTED_HOSTS = ["*.beta.builder.io", "beta.builder.io", "builder.io", "localhost", "qa.builder.io"];
|
|
6196
|
+
function isFromTrustedHost(trustedHosts, e) {
|
|
6197
|
+
const url = new URL(e.origin), hostname = url.hostname;
|
|
6198
|
+
return (trustedHosts || DEFAULT_TRUSTED_HOSTS).findIndex((trustedHost) => trustedHost.startsWith("*.") ? hostname.endsWith(trustedHost.slice(1)) : trustedHost === hostname) > -1;
|
|
6199
|
+
}
|
|
6200
|
+
|
|
6144
6201
|
// src/functions/is-previewing.ts
|
|
6145
6202
|
function isPreviewing() {
|
|
6146
6203
|
if (!isBrowser()) {
|
|
@@ -6389,7 +6446,7 @@ var getInteractionPropertiesForEvent = (event) => {
|
|
|
6389
6446
|
};
|
|
6390
6447
|
|
|
6391
6448
|
// src/constants/sdk-version.ts
|
|
6392
|
-
var SDK_VERSION = "0.12.
|
|
6449
|
+
var SDK_VERSION = "0.12.2";
|
|
6393
6450
|
|
|
6394
6451
|
// src/functions/register.ts
|
|
6395
6452
|
var registry = {};
|
|
@@ -6466,9 +6523,13 @@ var setupBrowserForEditing = (options = {}) => {
|
|
|
6466
6523
|
options
|
|
6467
6524
|
}
|
|
6468
6525
|
}, "*");
|
|
6469
|
-
window.addEventListener("message", ({
|
|
6470
|
-
|
|
6471
|
-
|
|
6526
|
+
window.addEventListener("message", (event) => {
|
|
6527
|
+
if (!isFromTrustedHost(options.trustedHosts, event)) {
|
|
6528
|
+
return;
|
|
6529
|
+
}
|
|
6530
|
+
const {
|
|
6531
|
+
data
|
|
6532
|
+
} = event;
|
|
6472
6533
|
if (!data?.type) {
|
|
6473
6534
|
return;
|
|
6474
6535
|
}
|
|
@@ -6564,6 +6625,9 @@ function EnableEditor(props) {
|
|
|
6564
6625
|
}));
|
|
6565
6626
|
}
|
|
6566
6627
|
function processMessage(event) {
|
|
6628
|
+
if (!isFromTrustedHost(props.trustedHosts, event)) {
|
|
6629
|
+
return;
|
|
6630
|
+
}
|
|
6567
6631
|
const {
|
|
6568
6632
|
data
|
|
6569
6633
|
} = event;
|
|
@@ -6694,6 +6758,9 @@ function EnableEditor(props) {
|
|
|
6694
6758
|
} : {},
|
|
6695
6759
|
...props.enrich ? {
|
|
6696
6760
|
enrich: props.enrich
|
|
6761
|
+
} : {},
|
|
6762
|
+
...props.trustedHosts ? {
|
|
6763
|
+
trustedHosts: props.trustedHosts
|
|
6697
6764
|
} : {}
|
|
6698
6765
|
});
|
|
6699
6766
|
Object.values(props.builderContextSignal.componentInfos).forEach((registeredComponent) => {
|
|
@@ -7061,6 +7128,9 @@ function ContentComponent(props) {
|
|
|
7061
7128
|
},
|
|
7062
7129
|
get contentWrapperProps() {
|
|
7063
7130
|
return props.contentWrapperProps;
|
|
7131
|
+
},
|
|
7132
|
+
get trustedHosts() {
|
|
7133
|
+
return props.trustedHosts;
|
|
7064
7134
|
}
|
|
7065
7135
|
}, {
|
|
7066
7136
|
setBuilderContextSignal
|
|
@@ -7220,6 +7290,9 @@ function ContentVariants(props) {
|
|
|
7220
7290
|
},
|
|
7221
7291
|
get contentWrapperProps() {
|
|
7222
7292
|
return props.contentWrapperProps;
|
|
7293
|
+
},
|
|
7294
|
+
get trustedHosts() {
|
|
7295
|
+
return props.trustedHosts;
|
|
7223
7296
|
}
|
|
7224
7297
|
});
|
|
7225
7298
|
}
|
|
@@ -7274,6 +7347,9 @@ function ContentVariants(props) {
|
|
|
7274
7347
|
},
|
|
7275
7348
|
get contentWrapperProps() {
|
|
7276
7349
|
return props.contentWrapperProps;
|
|
7350
|
+
},
|
|
7351
|
+
get trustedHosts() {
|
|
7352
|
+
return props.trustedHosts;
|
|
7277
7353
|
}
|
|
7278
7354
|
}))];
|
|
7279
7355
|
}
|
|
@@ -7304,7 +7380,7 @@ var fetchSymbolContent = async ({
|
|
|
7304
7380
|
};
|
|
7305
7381
|
|
|
7306
7382
|
// src/blocks/symbol/symbol.tsx
|
|
7307
|
-
var _tmpl$
|
|
7383
|
+
var _tmpl$15 = /* @__PURE__ */ template(`<div>`);
|
|
7308
7384
|
function Symbol2(props) {
|
|
7309
7385
|
const [contentToUse, setContentToUse] = createSignal(props.symbol?.content);
|
|
7310
7386
|
function className() {
|
|
@@ -7330,7 +7406,7 @@ function Symbol2(props) {
|
|
|
7330
7406
|
}
|
|
7331
7407
|
createEffect(on(() => [props.symbol], onUpdateFn_0));
|
|
7332
7408
|
return (() => {
|
|
7333
|
-
const _el$ = _tmpl$
|
|
7409
|
+
const _el$ = _tmpl$15();
|
|
7334
7410
|
spread(_el$, mergeProps({
|
|
7335
7411
|
get ["class"]() {
|
|
7336
7412
|
return className();
|
|
@@ -7345,7 +7421,10 @@ function Symbol2(props) {
|
|
|
7345
7421
|
return props.builderContext.apiKey;
|
|
7346
7422
|
},
|
|
7347
7423
|
get context() {
|
|
7348
|
-
return
|
|
7424
|
+
return {
|
|
7425
|
+
...props.builderContext.context,
|
|
7426
|
+
symbolId: props.builderBlock?.id
|
|
7427
|
+
};
|
|
7349
7428
|
},
|
|
7350
7429
|
get customComponents() {
|
|
7351
7430
|
return Object.values(props.builderComponents);
|