@builder.io/sdk-solid 3.0.6 → 4.0.0
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 +16 -16
- package/lib/browser/dev.js +99 -39
- package/lib/browser/dev.jsx +108 -26
- package/lib/browser/index.js +98 -39
- package/lib/browser/index.jsx +107 -26
- package/lib/edge/dev.js +99 -39
- package/lib/edge/dev.jsx +108 -26
- package/lib/edge/index.js +98 -39
- package/lib/edge/index.jsx +107 -26
- package/lib/node/dev.js +99 -39
- package/lib/node/dev.jsx +108 -26
- package/lib/node/index.js +98 -39
- package/lib/node/index.jsx +107 -26
- package/package.json +1 -1
package/lib/browser/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { delegateEvents, createComponent, spread, mergeProps, insert, effect, setAttribute, className, style, template, Dynamic, memo
|
|
1
|
+
import { delegateEvents, createComponent, spread, mergeProps, insert, effect, setAttribute, className, style, template, use, Dynamic, memo } from 'solid-js/web';
|
|
2
2
|
import { createContext, useContext, Show, For, createMemo, createSignal, onMount, createEffect, on } from 'solid-js';
|
|
3
3
|
|
|
4
4
|
// src/blocks/button/button.tsx
|
|
@@ -930,8 +930,13 @@ var provideBuilderContext = (block, context) => {
|
|
|
930
930
|
|
|
931
931
|
// src/constants/device-sizes.ts
|
|
932
932
|
var SIZES = {
|
|
933
|
+
xsmall: {
|
|
934
|
+
min: 0,
|
|
935
|
+
default: 160,
|
|
936
|
+
max: 320
|
|
937
|
+
},
|
|
933
938
|
small: {
|
|
934
|
-
min:
|
|
939
|
+
min: 321,
|
|
935
940
|
default: 321,
|
|
936
941
|
max: 640
|
|
937
942
|
},
|
|
@@ -947,15 +952,28 @@ var SIZES = {
|
|
|
947
952
|
}
|
|
948
953
|
};
|
|
949
954
|
var getMaxWidthQueryForSize = (size, sizeValues = SIZES) => `@media (max-width: ${sizeValues[size].max}px)`;
|
|
950
|
-
var getSizesForBreakpoints = ({
|
|
951
|
-
small,
|
|
952
|
-
medium
|
|
953
|
-
}) => {
|
|
955
|
+
var getSizesForBreakpoints = (breakpoints) => {
|
|
954
956
|
const newSizes = fastClone(SIZES);
|
|
957
|
+
if (!breakpoints) {
|
|
958
|
+
return newSizes;
|
|
959
|
+
}
|
|
960
|
+
const {
|
|
961
|
+
xsmall,
|
|
962
|
+
small,
|
|
963
|
+
medium
|
|
964
|
+
} = breakpoints;
|
|
965
|
+
if (xsmall) {
|
|
966
|
+
const xsmallMin = Math.floor(xsmall / 2);
|
|
967
|
+
newSizes.xsmall = {
|
|
968
|
+
max: xsmall,
|
|
969
|
+
min: xsmallMin,
|
|
970
|
+
default: xsmallMin + 1
|
|
971
|
+
};
|
|
972
|
+
}
|
|
955
973
|
if (!small || !medium) {
|
|
956
974
|
return newSizes;
|
|
957
975
|
}
|
|
958
|
-
const smallMin = Math.floor(small / 2);
|
|
976
|
+
const smallMin = xsmall ? newSizes.xsmall.max + 1 : Math.floor(small / 2);
|
|
959
977
|
newSizes.small = {
|
|
960
978
|
max: small,
|
|
961
979
|
min: smallMin,
|
|
@@ -1013,9 +1031,11 @@ function BlockStyles(props) {
|
|
|
1013
1031
|
const styles = processedBlock.responsiveStyles;
|
|
1014
1032
|
const content = props.context.content;
|
|
1015
1033
|
const sizesWithUpdatedBreakpoints = getSizesForBreakpoints(content?.meta?.breakpoints || {});
|
|
1034
|
+
const contentHasXSmallBreakpoint = Boolean(content?.meta?.breakpoints?.xsmall);
|
|
1016
1035
|
const largeStyles = styles?.large;
|
|
1017
1036
|
const mediumStyles = styles?.medium;
|
|
1018
1037
|
const smallStyles = styles?.small;
|
|
1038
|
+
const xsmallStyles = styles?.xsmall;
|
|
1019
1039
|
const className = processedBlock.id;
|
|
1020
1040
|
if (!className) {
|
|
1021
1041
|
return "";
|
|
@@ -1034,6 +1054,11 @@ function BlockStyles(props) {
|
|
|
1034
1054
|
styles: smallStyles,
|
|
1035
1055
|
mediaQuery: getMaxWidthQueryForSize("small", sizesWithUpdatedBreakpoints)
|
|
1036
1056
|
}) : "";
|
|
1057
|
+
const xsmallStylesClass = xsmallStyles && contentHasXSmallBreakpoint ? createCssClass({
|
|
1058
|
+
className,
|
|
1059
|
+
styles: xsmallStyles,
|
|
1060
|
+
mediaQuery: getMaxWidthQueryForSize("xsmall", sizesWithUpdatedBreakpoints)
|
|
1061
|
+
}) : "";
|
|
1037
1062
|
const hoverAnimation = processedBlock.animations && processedBlock.animations.find((item) => item.trigger === "hover");
|
|
1038
1063
|
let hoverStylesClass = "";
|
|
1039
1064
|
if (hoverAnimation) {
|
|
@@ -1047,7 +1072,7 @@ function BlockStyles(props) {
|
|
|
1047
1072
|
}
|
|
1048
1073
|
}) || "";
|
|
1049
1074
|
}
|
|
1050
|
-
return [largeStylesClass, mediumStylesClass, smallStylesClass, hoverStylesClass].join(" ");
|
|
1075
|
+
return [largeStylesClass, mediumStylesClass, smallStylesClass, xsmallStylesClass, hoverStylesClass].join(" ");
|
|
1051
1076
|
});
|
|
1052
1077
|
return createComponent(Show, {
|
|
1053
1078
|
get when() {
|
|
@@ -5015,10 +5040,10 @@ var componentInfo20 = {
|
|
|
5015
5040
|
builderBlock: true
|
|
5016
5041
|
}
|
|
5017
5042
|
};
|
|
5018
|
-
var _tmpl$21 = /* @__PURE__ */ template(`<
|
|
5019
|
-
var _tmpl$29 = /* @__PURE__ */ template(`<div>`);
|
|
5020
|
-
var _tmpl$35 = /* @__PURE__ */ template(`<div><video class=builder-video>`);
|
|
5043
|
+
var _tmpl$21 = /* @__PURE__ */ template(`<div>`);
|
|
5044
|
+
var _tmpl$29 = /* @__PURE__ */ template(`<div><video class=builder-video><source type=video/mp4>`);
|
|
5021
5045
|
function Video(props) {
|
|
5046
|
+
const [lazyVideoObserver, setLazyVideoObserver] = createSignal(void 0);
|
|
5022
5047
|
const videoProps = createMemo(() => {
|
|
5023
5048
|
return {
|
|
5024
5049
|
...props.autoPlay === true ? {
|
|
@@ -5043,12 +5068,41 @@ function Video(props) {
|
|
|
5043
5068
|
...videoProps()
|
|
5044
5069
|
};
|
|
5045
5070
|
});
|
|
5071
|
+
let videoRef;
|
|
5072
|
+
onMount(() => {
|
|
5073
|
+
if (props.lazyLoad) {
|
|
5074
|
+
const oberver = new IntersectionObserver(function(entries) {
|
|
5075
|
+
entries.forEach(function(entry) {
|
|
5076
|
+
if (!entry.isIntersecting)
|
|
5077
|
+
return;
|
|
5078
|
+
const videoElement = entry.target;
|
|
5079
|
+
try {
|
|
5080
|
+
Array.from(videoElement.children).filter((child) => child instanceof HTMLElement && child.tagName === "SOURCE").forEach((source) => {
|
|
5081
|
+
const src = source.dataset.src;
|
|
5082
|
+
if (src) {
|
|
5083
|
+
source.src = src;
|
|
5084
|
+
}
|
|
5085
|
+
});
|
|
5086
|
+
videoElement.load();
|
|
5087
|
+
oberver.unobserve(videoElement);
|
|
5088
|
+
} catch (error) {
|
|
5089
|
+
}
|
|
5090
|
+
});
|
|
5091
|
+
});
|
|
5092
|
+
if (videoRef) {
|
|
5093
|
+
oberver.observe(videoRef);
|
|
5094
|
+
}
|
|
5095
|
+
setLazyVideoObserver(oberver);
|
|
5096
|
+
}
|
|
5097
|
+
});
|
|
5046
5098
|
return (() => {
|
|
5047
|
-
const _el$ = _tmpl$
|
|
5099
|
+
const _el$ = _tmpl$29(), _el$2 = _el$.firstChild, _el$3 = _el$2.firstChild;
|
|
5048
5100
|
_el$.style.setProperty("position", "relative");
|
|
5101
|
+
const _ref$ = videoRef;
|
|
5102
|
+
typeof _ref$ === "function" ? use(_ref$, _el$2) : videoRef = _el$2;
|
|
5049
5103
|
spread(_el$2, mergeProps(spreadProps, {
|
|
5050
5104
|
get preload() {
|
|
5051
|
-
return props.preload || "metadata";
|
|
5105
|
+
return props.lazyLoad ? "none" : props.preload || "metadata";
|
|
5052
5106
|
},
|
|
5053
5107
|
get style() {
|
|
5054
5108
|
return {
|
|
@@ -5065,29 +5119,21 @@ function Video(props) {
|
|
|
5065
5119
|
} : null
|
|
5066
5120
|
};
|
|
5067
5121
|
},
|
|
5068
|
-
get src() {
|
|
5069
|
-
return props.video || "no-src";
|
|
5070
|
-
},
|
|
5071
5122
|
get poster() {
|
|
5072
5123
|
return props.posterImage;
|
|
5073
5124
|
}
|
|
5074
5125
|
}), false, true);
|
|
5075
|
-
|
|
5076
|
-
|
|
5077
|
-
|
|
5078
|
-
|
|
5079
|
-
|
|
5080
|
-
const _el$3 = _tmpl$21();
|
|
5081
|
-
effect(() => setAttribute(_el$3, "src", props.video));
|
|
5082
|
-
return _el$3;
|
|
5083
|
-
}
|
|
5084
|
-
}));
|
|
5126
|
+
spread(_el$3, mergeProps(() => props.lazyLoad ? {
|
|
5127
|
+
"data-src": props.video
|
|
5128
|
+
} : {
|
|
5129
|
+
src: props.video
|
|
5130
|
+
}), false, false);
|
|
5085
5131
|
insert(_el$, createComponent(Show, {
|
|
5086
5132
|
get when() {
|
|
5087
5133
|
return props.aspectRatio && !(props.fitContent && props.builderBlock?.children?.length);
|
|
5088
5134
|
},
|
|
5089
5135
|
get children() {
|
|
5090
|
-
const _el$4 = _tmpl$
|
|
5136
|
+
const _el$4 = _tmpl$21();
|
|
5091
5137
|
_el$4.style.setProperty("width", "100%");
|
|
5092
5138
|
_el$4.style.setProperty("pointer-events", "none");
|
|
5093
5139
|
_el$4.style.setProperty("font-size", "0px");
|
|
@@ -5100,7 +5146,7 @@ function Video(props) {
|
|
|
5100
5146
|
return props.builderBlock?.children?.length && props.fitContent;
|
|
5101
5147
|
},
|
|
5102
5148
|
get children() {
|
|
5103
|
-
const _el$5 = _tmpl$
|
|
5149
|
+
const _el$5 = _tmpl$21();
|
|
5104
5150
|
_el$5.style.setProperty("display", "flex");
|
|
5105
5151
|
_el$5.style.setProperty("flex-direction", "column");
|
|
5106
5152
|
_el$5.style.setProperty("align-items", "stretch");
|
|
@@ -5113,7 +5159,7 @@ function Video(props) {
|
|
|
5113
5159
|
return props.builderBlock?.children?.length && !props.fitContent;
|
|
5114
5160
|
},
|
|
5115
5161
|
get children() {
|
|
5116
|
-
const _el$6 = _tmpl$
|
|
5162
|
+
const _el$6 = _tmpl$21();
|
|
5117
5163
|
_el$6.style.setProperty("pointer-events", "none");
|
|
5118
5164
|
_el$6.style.setProperty("display", "flex");
|
|
5119
5165
|
_el$6.style.setProperty("flex-direction", "column");
|
|
@@ -5270,7 +5316,7 @@ function getPreviewContent(_searchParams) {
|
|
|
5270
5316
|
}
|
|
5271
5317
|
|
|
5272
5318
|
// src/constants/sdk-version.ts
|
|
5273
|
-
var SDK_VERSION = "
|
|
5319
|
+
var SDK_VERSION = "4.0.0";
|
|
5274
5320
|
|
|
5275
5321
|
// src/helpers/sdk-headers.ts
|
|
5276
5322
|
var getSdkHeaders = () => ({
|
|
@@ -5872,7 +5918,7 @@ var registerInsertMenu = () => {
|
|
|
5872
5918
|
});
|
|
5873
5919
|
};
|
|
5874
5920
|
var isSetupForEditing = false;
|
|
5875
|
-
var setupBrowserForEditing = (options
|
|
5921
|
+
var setupBrowserForEditing = (options) => {
|
|
5876
5922
|
if (isSetupForEditing) {
|
|
5877
5923
|
return;
|
|
5878
5924
|
}
|
|
@@ -5888,6 +5934,9 @@ var setupBrowserForEditing = (options = {}) => {
|
|
|
5888
5934
|
// scope our '+ add block' button styling
|
|
5889
5935
|
supportsAddBlockScoping: true,
|
|
5890
5936
|
supportsCustomBreakpoints: true,
|
|
5937
|
+
modelName: options.modelName,
|
|
5938
|
+
apiKey: options.apiKey,
|
|
5939
|
+
supportsXSmallBreakpoint: TARGET === "reactNative" ? false : true,
|
|
5891
5940
|
blockLevelPersonalization: true
|
|
5892
5941
|
}
|
|
5893
5942
|
}, "*");
|
|
@@ -5992,13 +6041,21 @@ var createEditorListener = ({
|
|
|
5992
6041
|
}
|
|
5993
6042
|
};
|
|
5994
6043
|
};
|
|
5995
|
-
var subscribeToEditor = (
|
|
6044
|
+
var subscribeToEditor = ({
|
|
6045
|
+
model,
|
|
6046
|
+
apiKey,
|
|
6047
|
+
callback,
|
|
6048
|
+
trustedHosts
|
|
6049
|
+
}) => {
|
|
5996
6050
|
if (!isBrowser) {
|
|
5997
6051
|
logger.warn("`subscribeToEditor` only works in the browser. It currently seems to be running on the server.");
|
|
5998
6052
|
return () => {
|
|
5999
6053
|
};
|
|
6000
6054
|
}
|
|
6001
|
-
setupBrowserForEditing(
|
|
6055
|
+
setupBrowserForEditing({
|
|
6056
|
+
modelName: model,
|
|
6057
|
+
apiKey
|
|
6058
|
+
});
|
|
6002
6059
|
const listener = createEditorListener({
|
|
6003
6060
|
callbacks: {
|
|
6004
6061
|
contentUpdate: callback,
|
|
@@ -6008,7 +6065,7 @@ var subscribeToEditor = (model, callback, options) => {
|
|
|
6008
6065
|
}
|
|
6009
6066
|
},
|
|
6010
6067
|
model,
|
|
6011
|
-
trustedHosts
|
|
6068
|
+
trustedHosts
|
|
6012
6069
|
});
|
|
6013
6070
|
window.addEventListener("message", listener);
|
|
6014
6071
|
return () => {
|
|
@@ -6253,10 +6310,12 @@ function EnableEditor(props) {
|
|
|
6253
6310
|
} : {},
|
|
6254
6311
|
...props.trustedHosts ? {
|
|
6255
6312
|
trustedHosts: props.trustedHosts
|
|
6256
|
-
} : {}
|
|
6313
|
+
} : {},
|
|
6314
|
+
modelName: props.model ?? "",
|
|
6315
|
+
apiKey: props.apiKey
|
|
6257
6316
|
});
|
|
6258
6317
|
Object.values(props.builderContextSignal.componentInfos).forEach((registeredComponent) => {
|
|
6259
|
-
if (!
|
|
6318
|
+
if (!registeredComponent.models?.length || registeredComponent.models.includes(props.model)) {
|
|
6260
6319
|
const message = createRegisterComponentMessage(registeredComponent);
|
|
6261
6320
|
window.parent?.postMessage(message, "*");
|
|
6262
6321
|
}
|
|
@@ -6284,7 +6343,7 @@ function EnableEditor(props) {
|
|
|
6284
6343
|
const previewApiKey = searchParams.get("apiKey") || searchParams.get("builder.space");
|
|
6285
6344
|
if (searchParamPreviewModel === "BUILDER_STUDIO" || searchParamPreviewModel === props.model && previewApiKey === props.apiKey && (!props.content || searchParamPreviewId === props.content.id)) {
|
|
6286
6345
|
fetchOneEntry({
|
|
6287
|
-
model: props.model
|
|
6346
|
+
model: props.model,
|
|
6288
6347
|
apiKey: props.apiKey,
|
|
6289
6348
|
apiVersion: props.builderContextSignal.apiVersion,
|
|
6290
6349
|
...searchParamPreviewModel === "BUILDER_STUDIO" && props.context?.symbolId ? {
|
|
@@ -6478,7 +6537,7 @@ function ContentComponent(props) {
|
|
|
6478
6537
|
BlocksWrapper: props.blocksWrapper || "div",
|
|
6479
6538
|
BlocksWrapperProps: props.blocksWrapperProps || {},
|
|
6480
6539
|
nonce: props.nonce || "",
|
|
6481
|
-
model: props.model
|
|
6540
|
+
model: props.model
|
|
6482
6541
|
});
|
|
6483
6542
|
function contentSetState(newRootState) {
|
|
6484
6543
|
setBuilderContextSignal((PREVIOUS_VALUE) => ({
|
|
@@ -6919,7 +6978,7 @@ function Symbol(props) {
|
|
|
6919
6978
|
return props.builderContext.canTrack;
|
|
6920
6979
|
},
|
|
6921
6980
|
get model() {
|
|
6922
|
-
return props.symbol?.model;
|
|
6981
|
+
return props.symbol?.model ?? "";
|
|
6923
6982
|
},
|
|
6924
6983
|
get content() {
|
|
6925
6984
|
return contentToUse();
|
package/lib/browser/index.jsx
CHANGED
|
@@ -928,8 +928,13 @@ import { Show as Show2, createMemo } from "solid-js";
|
|
|
928
928
|
|
|
929
929
|
// src/constants/device-sizes.ts
|
|
930
930
|
var SIZES = {
|
|
931
|
+
xsmall: {
|
|
932
|
+
min: 0,
|
|
933
|
+
default: 160,
|
|
934
|
+
max: 320
|
|
935
|
+
},
|
|
931
936
|
small: {
|
|
932
|
-
min:
|
|
937
|
+
min: 321,
|
|
933
938
|
default: 321,
|
|
934
939
|
max: 640
|
|
935
940
|
},
|
|
@@ -945,15 +950,28 @@ var SIZES = {
|
|
|
945
950
|
}
|
|
946
951
|
};
|
|
947
952
|
var getMaxWidthQueryForSize = (size, sizeValues = SIZES) => `@media (max-width: ${sizeValues[size].max}px)`;
|
|
948
|
-
var getSizesForBreakpoints = ({
|
|
949
|
-
small,
|
|
950
|
-
medium
|
|
951
|
-
}) => {
|
|
953
|
+
var getSizesForBreakpoints = (breakpoints) => {
|
|
952
954
|
const newSizes = fastClone(SIZES);
|
|
955
|
+
if (!breakpoints) {
|
|
956
|
+
return newSizes;
|
|
957
|
+
}
|
|
958
|
+
const {
|
|
959
|
+
xsmall,
|
|
960
|
+
small,
|
|
961
|
+
medium
|
|
962
|
+
} = breakpoints;
|
|
963
|
+
if (xsmall) {
|
|
964
|
+
const xsmallMin = Math.floor(xsmall / 2);
|
|
965
|
+
newSizes.xsmall = {
|
|
966
|
+
max: xsmall,
|
|
967
|
+
min: xsmallMin,
|
|
968
|
+
default: xsmallMin + 1
|
|
969
|
+
};
|
|
970
|
+
}
|
|
953
971
|
if (!small || !medium) {
|
|
954
972
|
return newSizes;
|
|
955
973
|
}
|
|
956
|
-
const smallMin = Math.floor(small / 2);
|
|
974
|
+
const smallMin = xsmall ? newSizes.xsmall.max + 1 : Math.floor(small / 2);
|
|
957
975
|
newSizes.small = {
|
|
958
976
|
max: small,
|
|
959
977
|
min: smallMin,
|
|
@@ -1004,9 +1022,13 @@ function BlockStyles(props) {
|
|
|
1004
1022
|
const sizesWithUpdatedBreakpoints = getSizesForBreakpoints(
|
|
1005
1023
|
content?.meta?.breakpoints || {}
|
|
1006
1024
|
);
|
|
1025
|
+
const contentHasXSmallBreakpoint = Boolean(
|
|
1026
|
+
content?.meta?.breakpoints?.xsmall
|
|
1027
|
+
);
|
|
1007
1028
|
const largeStyles = styles?.large;
|
|
1008
1029
|
const mediumStyles = styles?.medium;
|
|
1009
1030
|
const smallStyles = styles?.small;
|
|
1031
|
+
const xsmallStyles = styles?.xsmall;
|
|
1010
1032
|
const className = processedBlock.id;
|
|
1011
1033
|
if (!className) {
|
|
1012
1034
|
return "";
|
|
@@ -1031,6 +1053,14 @@ function BlockStyles(props) {
|
|
|
1031
1053
|
sizesWithUpdatedBreakpoints
|
|
1032
1054
|
)
|
|
1033
1055
|
}) : "";
|
|
1056
|
+
const xsmallStylesClass = xsmallStyles && contentHasXSmallBreakpoint ? createCssClass({
|
|
1057
|
+
className,
|
|
1058
|
+
styles: xsmallStyles,
|
|
1059
|
+
mediaQuery: getMaxWidthQueryForSize(
|
|
1060
|
+
"xsmall",
|
|
1061
|
+
sizesWithUpdatedBreakpoints
|
|
1062
|
+
)
|
|
1063
|
+
}) : "";
|
|
1034
1064
|
const hoverAnimation = processedBlock.animations && processedBlock.animations.find((item) => item.trigger === "hover");
|
|
1035
1065
|
let hoverStylesClass = "";
|
|
1036
1066
|
if (hoverAnimation) {
|
|
@@ -1050,6 +1080,7 @@ function BlockStyles(props) {
|
|
|
1050
1080
|
largeStylesClass,
|
|
1051
1081
|
mediumStylesClass,
|
|
1052
1082
|
smallStylesClass,
|
|
1083
|
+
xsmallStylesClass,
|
|
1053
1084
|
hoverStylesClass
|
|
1054
1085
|
].join(" ");
|
|
1055
1086
|
});
|
|
@@ -1877,10 +1908,10 @@ function SectionComponent(props) {
|
|
|
1877
1908
|
var section_default = SectionComponent;
|
|
1878
1909
|
|
|
1879
1910
|
// src/blocks/symbol/symbol.tsx
|
|
1880
|
-
import { onMount as
|
|
1911
|
+
import { onMount as onMount9, on as on4, createEffect as createEffect4, createMemo as createMemo20, createSignal as createSignal20 } from "solid-js";
|
|
1881
1912
|
|
|
1882
1913
|
// src/components/content-variants/content-variants.tsx
|
|
1883
|
-
import { Show as Show16, For as For9, onMount as
|
|
1914
|
+
import { Show as Show16, For as For9, onMount as onMount8, createSignal as createSignal19, createMemo as createMemo19 } from "solid-js";
|
|
1884
1915
|
|
|
1885
1916
|
// src/helpers/url.ts
|
|
1886
1917
|
var getTopLevelDomain = (host) => {
|
|
@@ -4523,8 +4554,9 @@ var componentInfo20 = {
|
|
|
4523
4554
|
};
|
|
4524
4555
|
|
|
4525
4556
|
// src/blocks/video/video.tsx
|
|
4526
|
-
import { Show as Show13, createMemo as createMemo15 } from "solid-js";
|
|
4557
|
+
import { Show as Show13, onMount as onMount6, createSignal as createSignal15, createMemo as createMemo15 } from "solid-js";
|
|
4527
4558
|
function Video(props) {
|
|
4559
|
+
const [lazyVideoObserver, setLazyVideoObserver] = createSignal15(void 0);
|
|
4528
4560
|
const videoProps = createMemo15(() => {
|
|
4529
4561
|
return {
|
|
4530
4562
|
...props.autoPlay === true ? {
|
|
@@ -4549,6 +4581,35 @@ function Video(props) {
|
|
|
4549
4581
|
...videoProps()
|
|
4550
4582
|
};
|
|
4551
4583
|
});
|
|
4584
|
+
let videoRef;
|
|
4585
|
+
onMount6(() => {
|
|
4586
|
+
if (props.lazyLoad) {
|
|
4587
|
+
const oberver = new IntersectionObserver(function(entries) {
|
|
4588
|
+
entries.forEach(function(entry) {
|
|
4589
|
+
if (!entry.isIntersecting)
|
|
4590
|
+
return;
|
|
4591
|
+
const videoElement = entry.target;
|
|
4592
|
+
try {
|
|
4593
|
+
Array.from(videoElement.children).filter(
|
|
4594
|
+
(child) => child instanceof HTMLElement && child.tagName === "SOURCE"
|
|
4595
|
+
).forEach((source) => {
|
|
4596
|
+
const src = source.dataset.src;
|
|
4597
|
+
if (src) {
|
|
4598
|
+
source.src = src;
|
|
4599
|
+
}
|
|
4600
|
+
});
|
|
4601
|
+
videoElement.load();
|
|
4602
|
+
oberver.unobserve(videoElement);
|
|
4603
|
+
} catch (error) {
|
|
4604
|
+
}
|
|
4605
|
+
});
|
|
4606
|
+
});
|
|
4607
|
+
if (videoRef) {
|
|
4608
|
+
oberver.observe(videoRef);
|
|
4609
|
+
}
|
|
4610
|
+
setLazyVideoObserver(oberver);
|
|
4611
|
+
}
|
|
4612
|
+
});
|
|
4552
4613
|
return <><div
|
|
4553
4614
|
style={{
|
|
4554
4615
|
position: "relative"
|
|
@@ -4557,7 +4618,8 @@ function Video(props) {
|
|
|
4557
4618
|
<video
|
|
4558
4619
|
class="builder-video"
|
|
4559
4620
|
{...spreadProps()}
|
|
4560
|
-
|
|
4621
|
+
ref={videoRef}
|
|
4622
|
+
preload={props.lazyLoad ? "none" : props.preload || "metadata"}
|
|
4561
4623
|
style={{
|
|
4562
4624
|
width: "100%",
|
|
4563
4625
|
height: "100%",
|
|
@@ -4571,9 +4633,15 @@ function Video(props) {
|
|
|
4571
4633
|
position: "absolute"
|
|
4572
4634
|
} : null
|
|
4573
4635
|
}}
|
|
4574
|
-
src={props.video || "no-src"}
|
|
4575
4636
|
poster={props.posterImage}
|
|
4576
|
-
><
|
|
4637
|
+
><source
|
|
4638
|
+
type="video/mp4"
|
|
4639
|
+
{...props.lazyLoad ? {
|
|
4640
|
+
"data-src": props.video
|
|
4641
|
+
} : {
|
|
4642
|
+
src: props.video
|
|
4643
|
+
}}
|
|
4644
|
+
/></video>
|
|
4577
4645
|
<Show13
|
|
4578
4646
|
when={props.aspectRatio && !(props.fitContent && props.builderBlock?.children?.length)}
|
|
4579
4647
|
><div
|
|
@@ -4743,7 +4811,7 @@ var getUpdateVariantVisibilityScript = ({
|
|
|
4743
4811
|
// src/components/content/components/enable-editor.tsx
|
|
4744
4812
|
import {
|
|
4745
4813
|
Show as Show14,
|
|
4746
|
-
onMount as
|
|
4814
|
+
onMount as onMount7,
|
|
4747
4815
|
on as on3,
|
|
4748
4816
|
createEffect as createEffect3,
|
|
4749
4817
|
createMemo as createMemo16,
|
|
@@ -4757,7 +4825,7 @@ function getPreviewContent(_searchParams) {
|
|
|
4757
4825
|
}
|
|
4758
4826
|
|
|
4759
4827
|
// src/constants/sdk-version.ts
|
|
4760
|
-
var SDK_VERSION = "
|
|
4828
|
+
var SDK_VERSION = "4.0.0";
|
|
4761
4829
|
|
|
4762
4830
|
// src/helpers/sdk-headers.ts
|
|
4763
4831
|
var getSdkHeaders = () => ({
|
|
@@ -5359,7 +5427,7 @@ var registerInsertMenu = () => {
|
|
|
5359
5427
|
});
|
|
5360
5428
|
};
|
|
5361
5429
|
var isSetupForEditing = false;
|
|
5362
|
-
var setupBrowserForEditing = (options
|
|
5430
|
+
var setupBrowserForEditing = (options) => {
|
|
5363
5431
|
if (isSetupForEditing) {
|
|
5364
5432
|
return;
|
|
5365
5433
|
}
|
|
@@ -5375,6 +5443,9 @@ var setupBrowserForEditing = (options = {}) => {
|
|
|
5375
5443
|
// scope our '+ add block' button styling
|
|
5376
5444
|
supportsAddBlockScoping: true,
|
|
5377
5445
|
supportsCustomBreakpoints: true,
|
|
5446
|
+
modelName: options.modelName,
|
|
5447
|
+
apiKey: options.apiKey,
|
|
5448
|
+
supportsXSmallBreakpoint: TARGET === "reactNative" ? false : true,
|
|
5378
5449
|
blockLevelPersonalization: true
|
|
5379
5450
|
}
|
|
5380
5451
|
}, "*");
|
|
@@ -5479,13 +5550,21 @@ var createEditorListener = ({
|
|
|
5479
5550
|
}
|
|
5480
5551
|
};
|
|
5481
5552
|
};
|
|
5482
|
-
var subscribeToEditor = (
|
|
5553
|
+
var subscribeToEditor = ({
|
|
5554
|
+
model,
|
|
5555
|
+
apiKey,
|
|
5556
|
+
callback,
|
|
5557
|
+
trustedHosts
|
|
5558
|
+
}) => {
|
|
5483
5559
|
if (!isBrowser) {
|
|
5484
5560
|
logger.warn("`subscribeToEditor` only works in the browser. It currently seems to be running on the server.");
|
|
5485
5561
|
return () => {
|
|
5486
5562
|
};
|
|
5487
5563
|
}
|
|
5488
|
-
setupBrowserForEditing(
|
|
5564
|
+
setupBrowserForEditing({
|
|
5565
|
+
modelName: model,
|
|
5566
|
+
apiKey
|
|
5567
|
+
});
|
|
5489
5568
|
const listener = createEditorListener({
|
|
5490
5569
|
callbacks: {
|
|
5491
5570
|
contentUpdate: callback,
|
|
@@ -5495,7 +5574,7 @@ var subscribeToEditor = (model, callback, options) => {
|
|
|
5495
5574
|
}
|
|
5496
5575
|
},
|
|
5497
5576
|
model,
|
|
5498
|
-
trustedHosts
|
|
5577
|
+
trustedHosts
|
|
5499
5578
|
});
|
|
5500
5579
|
window.addEventListener("message", listener);
|
|
5501
5580
|
return () => {
|
|
@@ -5735,7 +5814,7 @@ function EnableEditor(props) {
|
|
|
5735
5814
|
let elementRef;
|
|
5736
5815
|
runHttpRequests();
|
|
5737
5816
|
emitStateUpdate();
|
|
5738
|
-
|
|
5817
|
+
onMount7(() => {
|
|
5739
5818
|
if (isBrowser()) {
|
|
5740
5819
|
if (isEditing() && !props.isNestedRender) {
|
|
5741
5820
|
window.addEventListener("message", processMessage);
|
|
@@ -5749,12 +5828,14 @@ function EnableEditor(props) {
|
|
|
5749
5828
|
} : {},
|
|
5750
5829
|
...props.trustedHosts ? {
|
|
5751
5830
|
trustedHosts: props.trustedHosts
|
|
5752
|
-
} : {}
|
|
5831
|
+
} : {},
|
|
5832
|
+
modelName: props.model ?? "",
|
|
5833
|
+
apiKey: props.apiKey
|
|
5753
5834
|
});
|
|
5754
5835
|
Object.values(
|
|
5755
5836
|
props.builderContextSignal.componentInfos
|
|
5756
5837
|
).forEach((registeredComponent) => {
|
|
5757
|
-
if (!
|
|
5838
|
+
if (!registeredComponent.models?.length || registeredComponent.models.includes(props.model)) {
|
|
5758
5839
|
const message = createRegisterComponentMessage(registeredComponent);
|
|
5759
5840
|
window.parent?.postMessage(message, "*");
|
|
5760
5841
|
}
|
|
@@ -5787,7 +5868,7 @@ function EnableEditor(props) {
|
|
|
5787
5868
|
const previewApiKey = searchParams.get("apiKey") || searchParams.get("builder.space");
|
|
5788
5869
|
if (searchParamPreviewModel === "BUILDER_STUDIO" || searchParamPreviewModel === props.model && previewApiKey === props.apiKey && (!props.content || searchParamPreviewId === props.content.id)) {
|
|
5789
5870
|
fetchOneEntry({
|
|
5790
|
-
model: props.model
|
|
5871
|
+
model: props.model,
|
|
5791
5872
|
apiKey: props.apiKey,
|
|
5792
5873
|
apiVersion: props.builderContextSignal.apiVersion,
|
|
5793
5874
|
...searchParamPreviewModel === "BUILDER_STUDIO" && props.context?.symbolId ? {
|
|
@@ -5975,7 +6056,7 @@ function ContentComponent(props) {
|
|
|
5975
6056
|
BlocksWrapper: props.blocksWrapper || "div",
|
|
5976
6057
|
BlocksWrapperProps: props.blocksWrapperProps || {},
|
|
5977
6058
|
nonce: props.nonce || "",
|
|
5978
|
-
model: props.model
|
|
6059
|
+
model: props.model
|
|
5979
6060
|
});
|
|
5980
6061
|
function contentSetState(newRootState) {
|
|
5981
6062
|
setBuilderContextSignal((PREVIOUS_VALUE) => ({
|
|
@@ -6080,7 +6161,7 @@ function ContentVariants(props) {
|
|
|
6080
6161
|
canTrack: getDefaultCanTrack(props.canTrack)
|
|
6081
6162
|
});
|
|
6082
6163
|
});
|
|
6083
|
-
|
|
6164
|
+
onMount8(() => {
|
|
6084
6165
|
setShouldRenderVariants(false);
|
|
6085
6166
|
});
|
|
6086
6167
|
return <><>
|
|
@@ -6210,7 +6291,7 @@ function Symbol(props) {
|
|
|
6210
6291
|
}
|
|
6211
6292
|
});
|
|
6212
6293
|
}
|
|
6213
|
-
|
|
6294
|
+
onMount9(() => {
|
|
6214
6295
|
});
|
|
6215
6296
|
const onUpdateFn_0_props_symbol = createMemo20(() => props.symbol);
|
|
6216
6297
|
function onUpdateFn_0() {
|
|
@@ -6233,7 +6314,7 @@ function Symbol(props) {
|
|
|
6233
6314
|
...contentToUse()?.data?.state
|
|
6234
6315
|
}}
|
|
6235
6316
|
canTrack={props.builderContext.canTrack}
|
|
6236
|
-
model={props.symbol?.model}
|
|
6317
|
+
model={props.symbol?.model ?? ""}
|
|
6237
6318
|
content={contentToUse()}
|
|
6238
6319
|
linkComponent={props.builderLinkComponent}
|
|
6239
6320
|
blocksWrapper={blocksWrapper()}
|