@builder.io/sdk-solid 3.0.7 → 4.0.1
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 +15 -15
- package/lib/browser/dev.js +80 -32
- package/lib/browser/dev.jsx +84 -20
- package/lib/browser/index.js +79 -32
- package/lib/browser/index.jsx +83 -20
- package/lib/edge/dev.js +80 -32
- package/lib/edge/dev.jsx +84 -20
- package/lib/edge/index.js +79 -32
- package/lib/edge/index.jsx +83 -20
- package/lib/node/dev.js +80 -32
- package/lib/node/dev.jsx +84 -20
- package/lib/node/index.js +79 -32
- package/lib/node/index.jsx +83 -20
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -683,11 +683,11 @@ interface ContentVariantsPrps extends ExtraFrameworkProps {
|
|
|
683
683
|
/**
|
|
684
684
|
* The Builder content JSON to render (required).
|
|
685
685
|
*/
|
|
686
|
-
content
|
|
686
|
+
content: Nullable<BuilderContent>;
|
|
687
687
|
/**
|
|
688
688
|
* The Builder content `model` to render (required).
|
|
689
689
|
*/
|
|
690
|
-
model
|
|
690
|
+
model: string;
|
|
691
691
|
/**
|
|
692
692
|
* Additional data to inject into your Builder content (optional).
|
|
693
693
|
*/
|
|
@@ -876,19 +876,19 @@ type EventProperties = Pick<Event, 'type'> & Pick<Event['data'], 'contentId' | '
|
|
|
876
876
|
};
|
|
877
877
|
declare const track: (args: EventProperties) => Promise<void | Response>;
|
|
878
878
|
|
|
879
|
-
type SubscribeToEditor = (
|
|
880
|
-
/**
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
model: string
|
|
884
|
-
/**
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
/**
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
879
|
+
type SubscribeToEditor = ({ model, apiKey, callback, trustedHosts }: {
|
|
880
|
+
/**
|
|
881
|
+
* The Builder `model` to subscribe to
|
|
882
|
+
*/
|
|
883
|
+
model: string;
|
|
884
|
+
/**
|
|
885
|
+
* Builder API Key to use for the editor.
|
|
886
|
+
*/
|
|
887
|
+
apiKey: string;
|
|
888
|
+
/**
|
|
889
|
+
* The callback function to call when the content is updated.
|
|
890
|
+
*/
|
|
891
|
+
callback: (updatedContent: BuilderContent) => void;
|
|
892
892
|
/**
|
|
893
893
|
* List of hosts to allow editing content from.
|
|
894
894
|
*/
|
package/lib/browser/dev.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
|
|
@@ -5053,10 +5053,10 @@ var componentInfo20 = {
|
|
|
5053
5053
|
builderBlock: true
|
|
5054
5054
|
}
|
|
5055
5055
|
};
|
|
5056
|
-
var _tmpl$21 = /* @__PURE__ */ template(`<
|
|
5057
|
-
var _tmpl$29 = /* @__PURE__ */ template(`<div>`);
|
|
5058
|
-
var _tmpl$35 = /* @__PURE__ */ template(`<div><video class=builder-video>`);
|
|
5056
|
+
var _tmpl$21 = /* @__PURE__ */ template(`<div>`);
|
|
5057
|
+
var _tmpl$29 = /* @__PURE__ */ template(`<div><video class=builder-video><source type=video/mp4>`);
|
|
5059
5058
|
function Video(props) {
|
|
5059
|
+
const [lazyVideoObserver, setLazyVideoObserver] = createSignal(void 0);
|
|
5060
5060
|
const videoProps = createMemo(() => {
|
|
5061
5061
|
return {
|
|
5062
5062
|
...props.autoPlay === true ? {
|
|
@@ -5081,12 +5081,42 @@ function Video(props) {
|
|
|
5081
5081
|
...videoProps()
|
|
5082
5082
|
};
|
|
5083
5083
|
});
|
|
5084
|
+
let videoRef;
|
|
5085
|
+
onMount(() => {
|
|
5086
|
+
if (props.lazyLoad) {
|
|
5087
|
+
const oberver = new IntersectionObserver(function(entries) {
|
|
5088
|
+
entries.forEach(function(entry) {
|
|
5089
|
+
if (!entry.isIntersecting)
|
|
5090
|
+
return;
|
|
5091
|
+
const videoElement = entry.target;
|
|
5092
|
+
try {
|
|
5093
|
+
Array.from(videoElement.children).filter((child) => child instanceof HTMLElement && child.tagName === "SOURCE").forEach((source) => {
|
|
5094
|
+
const src = source.dataset.src;
|
|
5095
|
+
if (src) {
|
|
5096
|
+
source.src = src;
|
|
5097
|
+
}
|
|
5098
|
+
});
|
|
5099
|
+
videoElement.load();
|
|
5100
|
+
oberver.unobserve(videoElement);
|
|
5101
|
+
} catch (error) {
|
|
5102
|
+
console.error("Error loading lazy video:", error);
|
|
5103
|
+
}
|
|
5104
|
+
});
|
|
5105
|
+
});
|
|
5106
|
+
if (videoRef) {
|
|
5107
|
+
oberver.observe(videoRef);
|
|
5108
|
+
}
|
|
5109
|
+
setLazyVideoObserver(oberver);
|
|
5110
|
+
}
|
|
5111
|
+
});
|
|
5084
5112
|
return (() => {
|
|
5085
|
-
const _el$ = _tmpl$
|
|
5113
|
+
const _el$ = _tmpl$29(), _el$2 = _el$.firstChild, _el$3 = _el$2.firstChild;
|
|
5086
5114
|
_el$.style.setProperty("position", "relative");
|
|
5115
|
+
const _ref$ = videoRef;
|
|
5116
|
+
typeof _ref$ === "function" ? use(_ref$, _el$2) : videoRef = _el$2;
|
|
5087
5117
|
spread(_el$2, mergeProps(spreadProps, {
|
|
5088
5118
|
get preload() {
|
|
5089
|
-
return props.preload || "metadata";
|
|
5119
|
+
return props.lazyLoad ? "none" : props.preload || "metadata";
|
|
5090
5120
|
},
|
|
5091
5121
|
get style() {
|
|
5092
5122
|
return {
|
|
@@ -5103,29 +5133,21 @@ function Video(props) {
|
|
|
5103
5133
|
} : null
|
|
5104
5134
|
};
|
|
5105
5135
|
},
|
|
5106
|
-
get src() {
|
|
5107
|
-
return props.video || "no-src";
|
|
5108
|
-
},
|
|
5109
5136
|
get poster() {
|
|
5110
5137
|
return props.posterImage;
|
|
5111
5138
|
}
|
|
5112
5139
|
}), false, true);
|
|
5113
|
-
|
|
5114
|
-
|
|
5115
|
-
|
|
5116
|
-
|
|
5117
|
-
|
|
5118
|
-
const _el$3 = _tmpl$21();
|
|
5119
|
-
effect(() => setAttribute(_el$3, "src", props.video));
|
|
5120
|
-
return _el$3;
|
|
5121
|
-
}
|
|
5122
|
-
}));
|
|
5140
|
+
spread(_el$3, mergeProps(() => props.lazyLoad ? {
|
|
5141
|
+
"data-src": props.video
|
|
5142
|
+
} : {
|
|
5143
|
+
src: props.video
|
|
5144
|
+
}), false, false);
|
|
5123
5145
|
insert(_el$, createComponent(Show, {
|
|
5124
5146
|
get when() {
|
|
5125
5147
|
return props.aspectRatio && !(props.fitContent && props.builderBlock?.children?.length);
|
|
5126
5148
|
},
|
|
5127
5149
|
get children() {
|
|
5128
|
-
const _el$4 = _tmpl$
|
|
5150
|
+
const _el$4 = _tmpl$21();
|
|
5129
5151
|
_el$4.style.setProperty("width", "100%");
|
|
5130
5152
|
_el$4.style.setProperty("pointer-events", "none");
|
|
5131
5153
|
_el$4.style.setProperty("font-size", "0px");
|
|
@@ -5138,7 +5160,7 @@ function Video(props) {
|
|
|
5138
5160
|
return props.builderBlock?.children?.length && props.fitContent;
|
|
5139
5161
|
},
|
|
5140
5162
|
get children() {
|
|
5141
|
-
const _el$5 = _tmpl$
|
|
5163
|
+
const _el$5 = _tmpl$21();
|
|
5142
5164
|
_el$5.style.setProperty("display", "flex");
|
|
5143
5165
|
_el$5.style.setProperty("flex-direction", "column");
|
|
5144
5166
|
_el$5.style.setProperty("align-items", "stretch");
|
|
@@ -5151,7 +5173,7 @@ function Video(props) {
|
|
|
5151
5173
|
return props.builderBlock?.children?.length && !props.fitContent;
|
|
5152
5174
|
},
|
|
5153
5175
|
get children() {
|
|
5154
|
-
const _el$6 = _tmpl$
|
|
5176
|
+
const _el$6 = _tmpl$21();
|
|
5155
5177
|
_el$6.style.setProperty("pointer-events", "none");
|
|
5156
5178
|
_el$6.style.setProperty("display", "flex");
|
|
5157
5179
|
_el$6.style.setProperty("flex-direction", "column");
|
|
@@ -5308,7 +5330,7 @@ function getPreviewContent(_searchParams) {
|
|
|
5308
5330
|
}
|
|
5309
5331
|
|
|
5310
5332
|
// src/constants/sdk-version.ts
|
|
5311
|
-
var SDK_VERSION = "
|
|
5333
|
+
var SDK_VERSION = "4.0.1";
|
|
5312
5334
|
|
|
5313
5335
|
// src/helpers/sdk-headers.ts
|
|
5314
5336
|
var getSdkHeaders = () => ({
|
|
@@ -5916,7 +5938,7 @@ var registerInsertMenu = () => {
|
|
|
5916
5938
|
});
|
|
5917
5939
|
};
|
|
5918
5940
|
var isSetupForEditing = false;
|
|
5919
|
-
var setupBrowserForEditing = (options
|
|
5941
|
+
var setupBrowserForEditing = (options) => {
|
|
5920
5942
|
if (isSetupForEditing) {
|
|
5921
5943
|
return;
|
|
5922
5944
|
}
|
|
@@ -5932,6 +5954,8 @@ var setupBrowserForEditing = (options = {}) => {
|
|
|
5932
5954
|
// scope our '+ add block' button styling
|
|
5933
5955
|
supportsAddBlockScoping: true,
|
|
5934
5956
|
supportsCustomBreakpoints: true,
|
|
5957
|
+
modelName: options.modelName,
|
|
5958
|
+
apiKey: options.apiKey,
|
|
5935
5959
|
supportsXSmallBreakpoint: TARGET === "reactNative" ? false : true,
|
|
5936
5960
|
blockLevelPersonalization: true
|
|
5937
5961
|
}
|
|
@@ -6024,6 +6048,15 @@ var createEditorListener = ({
|
|
|
6024
6048
|
callbacks.animation(data.data);
|
|
6025
6049
|
break;
|
|
6026
6050
|
}
|
|
6051
|
+
case "builder.resetState": {
|
|
6052
|
+
const messageContent = data.data;
|
|
6053
|
+
const modelName = messageContent.model;
|
|
6054
|
+
const newState = messageContent?.state;
|
|
6055
|
+
if (modelName === model && newState) {
|
|
6056
|
+
callbacks.stateUpdate(newState);
|
|
6057
|
+
}
|
|
6058
|
+
break;
|
|
6059
|
+
}
|
|
6027
6060
|
case "builder.contentUpdate": {
|
|
6028
6061
|
const messageContent = data.data;
|
|
6029
6062
|
const key = messageContent.key || messageContent.alias || messageContent.entry || messageContent.modelName;
|
|
@@ -6037,23 +6070,33 @@ var createEditorListener = ({
|
|
|
6037
6070
|
}
|
|
6038
6071
|
};
|
|
6039
6072
|
};
|
|
6040
|
-
var subscribeToEditor = (
|
|
6073
|
+
var subscribeToEditor = ({
|
|
6074
|
+
model,
|
|
6075
|
+
apiKey,
|
|
6076
|
+
callback,
|
|
6077
|
+
trustedHosts
|
|
6078
|
+
}) => {
|
|
6041
6079
|
if (!isBrowser) {
|
|
6042
6080
|
logger.warn("`subscribeToEditor` only works in the browser. It currently seems to be running on the server.");
|
|
6043
6081
|
return () => {
|
|
6044
6082
|
};
|
|
6045
6083
|
}
|
|
6046
|
-
setupBrowserForEditing(
|
|
6084
|
+
setupBrowserForEditing({
|
|
6085
|
+
modelName: model,
|
|
6086
|
+
apiKey
|
|
6087
|
+
});
|
|
6047
6088
|
const listener = createEditorListener({
|
|
6048
6089
|
callbacks: {
|
|
6049
6090
|
contentUpdate: callback,
|
|
6050
6091
|
animation: () => {
|
|
6051
6092
|
},
|
|
6052
6093
|
configureSdk: () => {
|
|
6094
|
+
},
|
|
6095
|
+
stateUpdate: () => {
|
|
6053
6096
|
}
|
|
6054
6097
|
},
|
|
6055
6098
|
model,
|
|
6056
|
-
trustedHosts
|
|
6099
|
+
trustedHosts
|
|
6057
6100
|
});
|
|
6058
6101
|
window.addEventListener("message", listener);
|
|
6059
6102
|
return () => {
|
|
@@ -6217,6 +6260,9 @@ function EnableEditor(props) {
|
|
|
6217
6260
|
},
|
|
6218
6261
|
contentUpdate: (newContent) => {
|
|
6219
6262
|
mergeNewContent(newContent);
|
|
6263
|
+
},
|
|
6264
|
+
stateUpdate: (newState) => {
|
|
6265
|
+
mergeNewRootState(newState);
|
|
6220
6266
|
}
|
|
6221
6267
|
}
|
|
6222
6268
|
})(event);
|
|
@@ -6299,10 +6345,12 @@ function EnableEditor(props) {
|
|
|
6299
6345
|
} : {},
|
|
6300
6346
|
...props.trustedHosts ? {
|
|
6301
6347
|
trustedHosts: props.trustedHosts
|
|
6302
|
-
} : {}
|
|
6348
|
+
} : {},
|
|
6349
|
+
modelName: props.model ?? "",
|
|
6350
|
+
apiKey: props.apiKey
|
|
6303
6351
|
});
|
|
6304
6352
|
Object.values(props.builderContextSignal.componentInfos).forEach((registeredComponent) => {
|
|
6305
|
-
if (!
|
|
6353
|
+
if (!registeredComponent.models?.length || registeredComponent.models.includes(props.model)) {
|
|
6306
6354
|
const message = createRegisterComponentMessage(registeredComponent);
|
|
6307
6355
|
window.parent?.postMessage(message, "*");
|
|
6308
6356
|
}
|
|
@@ -6330,7 +6378,7 @@ function EnableEditor(props) {
|
|
|
6330
6378
|
const previewApiKey = searchParams.get("apiKey") || searchParams.get("builder.space");
|
|
6331
6379
|
if (searchParamPreviewModel === "BUILDER_STUDIO" || searchParamPreviewModel === props.model && previewApiKey === props.apiKey && (!props.content || searchParamPreviewId === props.content.id)) {
|
|
6332
6380
|
fetchOneEntry({
|
|
6333
|
-
model: props.model
|
|
6381
|
+
model: props.model,
|
|
6334
6382
|
apiKey: props.apiKey,
|
|
6335
6383
|
apiVersion: props.builderContextSignal.apiVersion,
|
|
6336
6384
|
...searchParamPreviewModel === "BUILDER_STUDIO" && props.context?.symbolId ? {
|
|
@@ -6524,7 +6572,7 @@ function ContentComponent(props) {
|
|
|
6524
6572
|
BlocksWrapper: props.blocksWrapper || "div",
|
|
6525
6573
|
BlocksWrapperProps: props.blocksWrapperProps || {},
|
|
6526
6574
|
nonce: props.nonce || "",
|
|
6527
|
-
model: props.model
|
|
6575
|
+
model: props.model
|
|
6528
6576
|
});
|
|
6529
6577
|
function contentSetState(newRootState) {
|
|
6530
6578
|
setBuilderContextSignal((PREVIOUS_VALUE) => ({
|
|
@@ -6965,7 +7013,7 @@ function Symbol(props) {
|
|
|
6965
7013
|
return props.builderContext.canTrack;
|
|
6966
7014
|
},
|
|
6967
7015
|
get model() {
|
|
6968
|
-
return props.symbol?.model;
|
|
7016
|
+
return props.symbol?.model ?? "";
|
|
6969
7017
|
},
|
|
6970
7018
|
get content() {
|
|
6971
7019
|
return contentToUse();
|
package/lib/browser/dev.jsx
CHANGED
|
@@ -1916,10 +1916,10 @@ function SectionComponent(props) {
|
|
|
1916
1916
|
var section_default = SectionComponent;
|
|
1917
1917
|
|
|
1918
1918
|
// src/blocks/symbol/symbol.tsx
|
|
1919
|
-
import { onMount as
|
|
1919
|
+
import { onMount as onMount9, on as on4, createEffect as createEffect4, createMemo as createMemo20, createSignal as createSignal20 } from "solid-js";
|
|
1920
1920
|
|
|
1921
1921
|
// src/components/content-variants/content-variants.tsx
|
|
1922
|
-
import { Show as Show16, For as For9, onMount as
|
|
1922
|
+
import { Show as Show16, For as For9, onMount as onMount8, createSignal as createSignal19, createMemo as createMemo19 } from "solid-js";
|
|
1923
1923
|
|
|
1924
1924
|
// src/helpers/url.ts
|
|
1925
1925
|
var getTopLevelDomain = (host) => {
|
|
@@ -4565,8 +4565,9 @@ var componentInfo20 = {
|
|
|
4565
4565
|
};
|
|
4566
4566
|
|
|
4567
4567
|
// src/blocks/video/video.tsx
|
|
4568
|
-
import { Show as Show13, createMemo as createMemo15 } from "solid-js";
|
|
4568
|
+
import { Show as Show13, onMount as onMount6, createSignal as createSignal15, createMemo as createMemo15 } from "solid-js";
|
|
4569
4569
|
function Video(props) {
|
|
4570
|
+
const [lazyVideoObserver, setLazyVideoObserver] = createSignal15(void 0);
|
|
4570
4571
|
const videoProps = createMemo15(() => {
|
|
4571
4572
|
return {
|
|
4572
4573
|
...props.autoPlay === true ? {
|
|
@@ -4591,6 +4592,36 @@ function Video(props) {
|
|
|
4591
4592
|
...videoProps()
|
|
4592
4593
|
};
|
|
4593
4594
|
});
|
|
4595
|
+
let videoRef;
|
|
4596
|
+
onMount6(() => {
|
|
4597
|
+
if (props.lazyLoad) {
|
|
4598
|
+
const oberver = new IntersectionObserver(function(entries) {
|
|
4599
|
+
entries.forEach(function(entry) {
|
|
4600
|
+
if (!entry.isIntersecting)
|
|
4601
|
+
return;
|
|
4602
|
+
const videoElement = entry.target;
|
|
4603
|
+
try {
|
|
4604
|
+
Array.from(videoElement.children).filter(
|
|
4605
|
+
(child) => child instanceof HTMLElement && child.tagName === "SOURCE"
|
|
4606
|
+
).forEach((source) => {
|
|
4607
|
+
const src = source.dataset.src;
|
|
4608
|
+
if (src) {
|
|
4609
|
+
source.src = src;
|
|
4610
|
+
}
|
|
4611
|
+
});
|
|
4612
|
+
videoElement.load();
|
|
4613
|
+
oberver.unobserve(videoElement);
|
|
4614
|
+
} catch (error) {
|
|
4615
|
+
console.error("Error loading lazy video:", error);
|
|
4616
|
+
}
|
|
4617
|
+
});
|
|
4618
|
+
});
|
|
4619
|
+
if (videoRef) {
|
|
4620
|
+
oberver.observe(videoRef);
|
|
4621
|
+
}
|
|
4622
|
+
setLazyVideoObserver(oberver);
|
|
4623
|
+
}
|
|
4624
|
+
});
|
|
4594
4625
|
return <><div
|
|
4595
4626
|
style={{
|
|
4596
4627
|
position: "relative"
|
|
@@ -4599,7 +4630,8 @@ function Video(props) {
|
|
|
4599
4630
|
<video
|
|
4600
4631
|
class="builder-video"
|
|
4601
4632
|
{...spreadProps()}
|
|
4602
|
-
|
|
4633
|
+
ref={videoRef}
|
|
4634
|
+
preload={props.lazyLoad ? "none" : props.preload || "metadata"}
|
|
4603
4635
|
style={{
|
|
4604
4636
|
width: "100%",
|
|
4605
4637
|
height: "100%",
|
|
@@ -4613,9 +4645,15 @@ function Video(props) {
|
|
|
4613
4645
|
position: "absolute"
|
|
4614
4646
|
} : null
|
|
4615
4647
|
}}
|
|
4616
|
-
src={props.video || "no-src"}
|
|
4617
4648
|
poster={props.posterImage}
|
|
4618
|
-
><
|
|
4649
|
+
><source
|
|
4650
|
+
type="video/mp4"
|
|
4651
|
+
{...props.lazyLoad ? {
|
|
4652
|
+
"data-src": props.video
|
|
4653
|
+
} : {
|
|
4654
|
+
src: props.video
|
|
4655
|
+
}}
|
|
4656
|
+
/></video>
|
|
4619
4657
|
<Show13
|
|
4620
4658
|
when={props.aspectRatio && !(props.fitContent && props.builderBlock?.children?.length)}
|
|
4621
4659
|
><div
|
|
@@ -4785,7 +4823,7 @@ var getUpdateVariantVisibilityScript = ({
|
|
|
4785
4823
|
// src/components/content/components/enable-editor.tsx
|
|
4786
4824
|
import {
|
|
4787
4825
|
Show as Show14,
|
|
4788
|
-
onMount as
|
|
4826
|
+
onMount as onMount7,
|
|
4789
4827
|
on as on3,
|
|
4790
4828
|
createEffect as createEffect3,
|
|
4791
4829
|
createMemo as createMemo16,
|
|
@@ -4799,7 +4837,7 @@ function getPreviewContent(_searchParams) {
|
|
|
4799
4837
|
}
|
|
4800
4838
|
|
|
4801
4839
|
// src/constants/sdk-version.ts
|
|
4802
|
-
var SDK_VERSION = "
|
|
4840
|
+
var SDK_VERSION = "4.0.1";
|
|
4803
4841
|
|
|
4804
4842
|
// src/helpers/sdk-headers.ts
|
|
4805
4843
|
var getSdkHeaders = () => ({
|
|
@@ -5407,7 +5445,7 @@ var registerInsertMenu = () => {
|
|
|
5407
5445
|
});
|
|
5408
5446
|
};
|
|
5409
5447
|
var isSetupForEditing = false;
|
|
5410
|
-
var setupBrowserForEditing = (options
|
|
5448
|
+
var setupBrowserForEditing = (options) => {
|
|
5411
5449
|
if (isSetupForEditing) {
|
|
5412
5450
|
return;
|
|
5413
5451
|
}
|
|
@@ -5423,6 +5461,8 @@ var setupBrowserForEditing = (options = {}) => {
|
|
|
5423
5461
|
// scope our '+ add block' button styling
|
|
5424
5462
|
supportsAddBlockScoping: true,
|
|
5425
5463
|
supportsCustomBreakpoints: true,
|
|
5464
|
+
modelName: options.modelName,
|
|
5465
|
+
apiKey: options.apiKey,
|
|
5426
5466
|
supportsXSmallBreakpoint: TARGET === "reactNative" ? false : true,
|
|
5427
5467
|
blockLevelPersonalization: true
|
|
5428
5468
|
}
|
|
@@ -5515,6 +5555,15 @@ var createEditorListener = ({
|
|
|
5515
5555
|
callbacks.animation(data.data);
|
|
5516
5556
|
break;
|
|
5517
5557
|
}
|
|
5558
|
+
case "builder.resetState": {
|
|
5559
|
+
const messageContent = data.data;
|
|
5560
|
+
const modelName = messageContent.model;
|
|
5561
|
+
const newState = messageContent?.state;
|
|
5562
|
+
if (modelName === model && newState) {
|
|
5563
|
+
callbacks.stateUpdate(newState);
|
|
5564
|
+
}
|
|
5565
|
+
break;
|
|
5566
|
+
}
|
|
5518
5567
|
case "builder.contentUpdate": {
|
|
5519
5568
|
const messageContent = data.data;
|
|
5520
5569
|
const key = messageContent.key || messageContent.alias || messageContent.entry || messageContent.modelName;
|
|
@@ -5528,23 +5577,33 @@ var createEditorListener = ({
|
|
|
5528
5577
|
}
|
|
5529
5578
|
};
|
|
5530
5579
|
};
|
|
5531
|
-
var subscribeToEditor = (
|
|
5580
|
+
var subscribeToEditor = ({
|
|
5581
|
+
model,
|
|
5582
|
+
apiKey,
|
|
5583
|
+
callback,
|
|
5584
|
+
trustedHosts
|
|
5585
|
+
}) => {
|
|
5532
5586
|
if (!isBrowser) {
|
|
5533
5587
|
logger.warn("`subscribeToEditor` only works in the browser. It currently seems to be running on the server.");
|
|
5534
5588
|
return () => {
|
|
5535
5589
|
};
|
|
5536
5590
|
}
|
|
5537
|
-
setupBrowserForEditing(
|
|
5591
|
+
setupBrowserForEditing({
|
|
5592
|
+
modelName: model,
|
|
5593
|
+
apiKey
|
|
5594
|
+
});
|
|
5538
5595
|
const listener = createEditorListener({
|
|
5539
5596
|
callbacks: {
|
|
5540
5597
|
contentUpdate: callback,
|
|
5541
5598
|
animation: () => {
|
|
5542
5599
|
},
|
|
5543
5600
|
configureSdk: () => {
|
|
5601
|
+
},
|
|
5602
|
+
stateUpdate: () => {
|
|
5544
5603
|
}
|
|
5545
5604
|
},
|
|
5546
5605
|
model,
|
|
5547
|
-
trustedHosts
|
|
5606
|
+
trustedHosts
|
|
5548
5607
|
});
|
|
5549
5608
|
window.addEventListener("message", listener);
|
|
5550
5609
|
return () => {
|
|
@@ -5707,6 +5766,9 @@ function EnableEditor(props) {
|
|
|
5707
5766
|
},
|
|
5708
5767
|
contentUpdate: (newContent) => {
|
|
5709
5768
|
mergeNewContent(newContent);
|
|
5769
|
+
},
|
|
5770
|
+
stateUpdate: (newState) => {
|
|
5771
|
+
mergeNewRootState(newState);
|
|
5710
5772
|
}
|
|
5711
5773
|
}
|
|
5712
5774
|
})(event);
|
|
@@ -5785,7 +5847,7 @@ function EnableEditor(props) {
|
|
|
5785
5847
|
let elementRef;
|
|
5786
5848
|
runHttpRequests();
|
|
5787
5849
|
emitStateUpdate();
|
|
5788
|
-
|
|
5850
|
+
onMount7(() => {
|
|
5789
5851
|
if (isBrowser()) {
|
|
5790
5852
|
if (isEditing() && !props.isNestedRender) {
|
|
5791
5853
|
window.addEventListener("message", processMessage);
|
|
@@ -5799,12 +5861,14 @@ function EnableEditor(props) {
|
|
|
5799
5861
|
} : {},
|
|
5800
5862
|
...props.trustedHosts ? {
|
|
5801
5863
|
trustedHosts: props.trustedHosts
|
|
5802
|
-
} : {}
|
|
5864
|
+
} : {},
|
|
5865
|
+
modelName: props.model ?? "",
|
|
5866
|
+
apiKey: props.apiKey
|
|
5803
5867
|
});
|
|
5804
5868
|
Object.values(
|
|
5805
5869
|
props.builderContextSignal.componentInfos
|
|
5806
5870
|
).forEach((registeredComponent) => {
|
|
5807
|
-
if (!
|
|
5871
|
+
if (!registeredComponent.models?.length || registeredComponent.models.includes(props.model)) {
|
|
5808
5872
|
const message = createRegisterComponentMessage(registeredComponent);
|
|
5809
5873
|
window.parent?.postMessage(message, "*");
|
|
5810
5874
|
}
|
|
@@ -5837,7 +5901,7 @@ function EnableEditor(props) {
|
|
|
5837
5901
|
const previewApiKey = searchParams.get("apiKey") || searchParams.get("builder.space");
|
|
5838
5902
|
if (searchParamPreviewModel === "BUILDER_STUDIO" || searchParamPreviewModel === props.model && previewApiKey === props.apiKey && (!props.content || searchParamPreviewId === props.content.id)) {
|
|
5839
5903
|
fetchOneEntry({
|
|
5840
|
-
model: props.model
|
|
5904
|
+
model: props.model,
|
|
5841
5905
|
apiKey: props.apiKey,
|
|
5842
5906
|
apiVersion: props.builderContextSignal.apiVersion,
|
|
5843
5907
|
...searchParamPreviewModel === "BUILDER_STUDIO" && props.context?.symbolId ? {
|
|
@@ -6025,7 +6089,7 @@ function ContentComponent(props) {
|
|
|
6025
6089
|
BlocksWrapper: props.blocksWrapper || "div",
|
|
6026
6090
|
BlocksWrapperProps: props.blocksWrapperProps || {},
|
|
6027
6091
|
nonce: props.nonce || "",
|
|
6028
|
-
model: props.model
|
|
6092
|
+
model: props.model
|
|
6029
6093
|
});
|
|
6030
6094
|
function contentSetState(newRootState) {
|
|
6031
6095
|
setBuilderContextSignal((PREVIOUS_VALUE) => ({
|
|
@@ -6130,7 +6194,7 @@ function ContentVariants(props) {
|
|
|
6130
6194
|
canTrack: getDefaultCanTrack(props.canTrack)
|
|
6131
6195
|
});
|
|
6132
6196
|
});
|
|
6133
|
-
|
|
6197
|
+
onMount8(() => {
|
|
6134
6198
|
setShouldRenderVariants(false);
|
|
6135
6199
|
});
|
|
6136
6200
|
return <><>
|
|
@@ -6260,7 +6324,7 @@ function Symbol(props) {
|
|
|
6260
6324
|
}
|
|
6261
6325
|
});
|
|
6262
6326
|
}
|
|
6263
|
-
|
|
6327
|
+
onMount9(() => {
|
|
6264
6328
|
});
|
|
6265
6329
|
const onUpdateFn_0_props_symbol = createMemo20(() => props.symbol);
|
|
6266
6330
|
function onUpdateFn_0() {
|
|
@@ -6283,7 +6347,7 @@ function Symbol(props) {
|
|
|
6283
6347
|
...contentToUse()?.data?.state
|
|
6284
6348
|
}}
|
|
6285
6349
|
canTrack={props.builderContext.canTrack}
|
|
6286
|
-
model={props.symbol?.model}
|
|
6350
|
+
model={props.symbol?.model ?? ""}
|
|
6287
6351
|
content={contentToUse()}
|
|
6288
6352
|
linkComponent={props.builderLinkComponent}
|
|
6289
6353
|
blocksWrapper={blocksWrapper()}
|