@builder.io/sdk-solid 4.0.2 → 4.0.4
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 +1 -0
- package/lib/browser/dev.js +45 -23
- package/lib/browser/dev.jsx +54 -30
- package/lib/browser/index.js +45 -21
- package/lib/browser/index.jsx +54 -28
- package/lib/edge/dev.js +45 -23
- package/lib/edge/dev.jsx +54 -30
- package/lib/edge/index.js +45 -21
- package/lib/edge/index.jsx +54 -28
- package/lib/node/dev.js +45 -23
- package/lib/node/dev.jsx +54 -30
- package/lib/node/index.js +45 -21
- package/lib/node/index.jsx +54 -28
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
package/lib/browser/dev.js
CHANGED
|
@@ -1641,12 +1641,13 @@ function Block(props) {
|
|
|
1641
1641
|
});
|
|
1642
1642
|
}
|
|
1643
1643
|
var block_default = Block;
|
|
1644
|
-
var _tmpl$2 = /* @__PURE__ */ template(`<style>.dynamic-
|
|
1644
|
+
var _tmpl$2 = /* @__PURE__ */ template(`<style>.dynamic-023c60f2 {
|
|
1645
1645
|
display: flex;
|
|
1646
1646
|
flex-direction: column;
|
|
1647
1647
|
align-items: stretch;
|
|
1648
1648
|
}`);
|
|
1649
1649
|
function BlocksWrapper(props) {
|
|
1650
|
+
createSignal(false);
|
|
1650
1651
|
const className = createMemo(() => {
|
|
1651
1652
|
return ["builder-blocks", !props.blocks?.length ? "no-blocks" : "", props.classNameProp].filter(Boolean).join(" ");
|
|
1652
1653
|
});
|
|
@@ -1683,9 +1684,13 @@ function BlocksWrapper(props) {
|
|
|
1683
1684
|
let blocksWrapperRef;
|
|
1684
1685
|
onMount(() => {
|
|
1685
1686
|
});
|
|
1687
|
+
const onUpdateFn_0_props_blocks = createMemo(() => props.blocks);
|
|
1688
|
+
function onUpdateFn_0() {
|
|
1689
|
+
}
|
|
1690
|
+
createEffect(on(() => [onUpdateFn_0_props_blocks()], onUpdateFn_0));
|
|
1686
1691
|
return [createComponent(Dynamic, mergeProps({
|
|
1687
1692
|
get ["class"]() {
|
|
1688
|
-
return className() + " dynamic-
|
|
1693
|
+
return className() + " dynamic-023c60f2";
|
|
1689
1694
|
},
|
|
1690
1695
|
ref(r$) {
|
|
1691
1696
|
const _ref$ = blocksWrapperRef;
|
|
@@ -2038,16 +2043,16 @@ function getSrcSet(url) {
|
|
|
2038
2043
|
// src/blocks/image/image.tsx
|
|
2039
2044
|
var _tmpl$5 = /* @__PURE__ */ template(`<source type=image/webp>`);
|
|
2040
2045
|
var _tmpl$23 = /* @__PURE__ */ template(`<picture><img>`);
|
|
2041
|
-
var _tmpl$32 = /* @__PURE__ */ template(`<div class="builder-image-sizer div-
|
|
2042
|
-
var _tmpl$42 = /* @__PURE__ */ template(`<div class=div-
|
|
2043
|
-
var _tmpl$52 = /* @__PURE__ */ template(`<style>.img-
|
|
2046
|
+
var _tmpl$32 = /* @__PURE__ */ template(`<div class="builder-image-sizer div-040e729e">`);
|
|
2047
|
+
var _tmpl$42 = /* @__PURE__ */ template(`<div class=div-040e729e-2>`);
|
|
2048
|
+
var _tmpl$52 = /* @__PURE__ */ template(`<style>.img-040e729e {
|
|
2044
2049
|
opacity: 1;
|
|
2045
2050
|
transition: opacity 0.2s ease-in-out;
|
|
2046
|
-
}.div-
|
|
2051
|
+
}.div-040e729e {
|
|
2047
2052
|
width: 100%;
|
|
2048
2053
|
pointer-events: none;
|
|
2049
2054
|
font-size: 0;
|
|
2050
|
-
}.div-
|
|
2055
|
+
}.div-040e729e-2 {
|
|
2051
2056
|
display: flex;
|
|
2052
2057
|
flex-direction: column;
|
|
2053
2058
|
align-items: stretch;
|
|
@@ -2110,20 +2115,21 @@ function Image(props) {
|
|
|
2110
2115
|
}
|
|
2111
2116
|
}), _el$3);
|
|
2112
2117
|
effect((_p$) => {
|
|
2113
|
-
const _v$ = "builder-image" + (props.className ? " " + props.className : "") + " img-
|
|
2118
|
+
const _v$ = "builder-image" + (props.className ? " " + props.className : "") + " img-040e729e", _v$2 = props.highPriority ? "eager" : "lazy", _v$3 = props.highPriority ? "high" : "auto", _v$4 = props.altText, _v$5 = props.title, _v$6 = props.altText ? void 0 : "presentation", _v$7 = {
|
|
2114
2119
|
"object-position": props.backgroundPosition || "center",
|
|
2115
2120
|
"object-fit": props.backgroundSize || "cover",
|
|
2116
2121
|
...aspectRatioCss()
|
|
2117
|
-
}, _v$
|
|
2122
|
+
}, _v$8 = props.image, _v$9 = srcSetToUse(), _v$10 = props.sizes;
|
|
2118
2123
|
_v$ !== _p$._v$ && className(_el$3, _p$._v$ = _v$);
|
|
2119
2124
|
_v$2 !== _p$._v$2 && setAttribute(_el$3, "loading", _p$._v$2 = _v$2);
|
|
2120
2125
|
_v$3 !== _p$._v$3 && setAttribute(_el$3, "fetchpriority", _p$._v$3 = _v$3);
|
|
2121
2126
|
_v$4 !== _p$._v$4 && setAttribute(_el$3, "alt", _p$._v$4 = _v$4);
|
|
2122
|
-
_v$5 !== _p$._v$5 && setAttribute(_el$3, "
|
|
2123
|
-
_p$._v$6
|
|
2124
|
-
|
|
2125
|
-
_v$8 !== _p$._v$8 && setAttribute(_el$3, "
|
|
2126
|
-
_v$9 !== _p$._v$9 && setAttribute(_el$3, "
|
|
2127
|
+
_v$5 !== _p$._v$5 && setAttribute(_el$3, "title", _p$._v$5 = _v$5);
|
|
2128
|
+
_v$6 !== _p$._v$6 && setAttribute(_el$3, "role", _p$._v$6 = _v$6);
|
|
2129
|
+
_p$._v$7 = style(_el$3, _v$7, _p$._v$7);
|
|
2130
|
+
_v$8 !== _p$._v$8 && setAttribute(_el$3, "src", _p$._v$8 = _v$8);
|
|
2131
|
+
_v$9 !== _p$._v$9 && setAttribute(_el$3, "srcset", _p$._v$9 = _v$9);
|
|
2132
|
+
_v$10 !== _p$._v$10 && setAttribute(_el$3, "sizes", _p$._v$10 = _v$10);
|
|
2127
2133
|
return _p$;
|
|
2128
2134
|
}, {
|
|
2129
2135
|
_v$: void 0,
|
|
@@ -2134,7 +2140,8 @@ function Image(props) {
|
|
|
2134
2140
|
_v$6: void 0,
|
|
2135
2141
|
_v$7: void 0,
|
|
2136
2142
|
_v$8: void 0,
|
|
2137
|
-
_v$9: void 0
|
|
2143
|
+
_v$9: void 0,
|
|
2144
|
+
_v$10: void 0
|
|
2138
2145
|
});
|
|
2139
2146
|
return _el$;
|
|
2140
2147
|
})(), createComponent(Show, {
|
|
@@ -3118,6 +3125,10 @@ var componentInfo5 = {
|
|
|
3118
3125
|
name: "altText",
|
|
3119
3126
|
type: "string",
|
|
3120
3127
|
helperText: "Text to display when the user has images off"
|
|
3128
|
+
}, {
|
|
3129
|
+
name: "title",
|
|
3130
|
+
type: "string",
|
|
3131
|
+
helperText: "Text to display when hovering over the asset"
|
|
3121
3132
|
}, {
|
|
3122
3133
|
name: "height",
|
|
3123
3134
|
type: "number",
|
|
@@ -4001,9 +4012,8 @@ var _tmpl$13 = /* @__PURE__ */ template(`<div>`);
|
|
|
4001
4012
|
function CustomCode(props) {
|
|
4002
4013
|
const [scriptsInserted, setScriptsInserted] = createSignal([]);
|
|
4003
4014
|
const [scriptsRun, setScriptsRun] = createSignal([]);
|
|
4004
|
-
|
|
4005
|
-
|
|
4006
|
-
if (!elementRef?.getElementsByTagName || typeof window === "undefined") {
|
|
4015
|
+
function runScripts() {
|
|
4016
|
+
if (!elementRef || !elementRef?.getElementsByTagName || typeof window === "undefined") {
|
|
4007
4017
|
return;
|
|
4008
4018
|
}
|
|
4009
4019
|
const scripts = elementRef.getElementsByTagName("script");
|
|
@@ -4026,11 +4036,22 @@ function CustomCode(props) {
|
|
|
4026
4036
|
scriptsRun().push(script.innerText);
|
|
4027
4037
|
new Function(script.innerText)();
|
|
4028
4038
|
} catch (error) {
|
|
4029
|
-
|
|
4039
|
+
logger.warn("[BUILDER.IO] `CustomCode`: Error running script:", error);
|
|
4030
4040
|
}
|
|
4031
4041
|
}
|
|
4032
4042
|
}
|
|
4043
|
+
}
|
|
4044
|
+
let elementRef;
|
|
4045
|
+
onMount(() => {
|
|
4046
|
+
runScripts();
|
|
4033
4047
|
});
|
|
4048
|
+
const onUpdateFn_0_props_code = createMemo(() => props.code);
|
|
4049
|
+
function onUpdateFn_0() {
|
|
4050
|
+
if (isEditing()) {
|
|
4051
|
+
runScripts();
|
|
4052
|
+
}
|
|
4053
|
+
}
|
|
4054
|
+
createEffect(on(() => [onUpdateFn_0_props_code()], onUpdateFn_0));
|
|
4034
4055
|
return (() => {
|
|
4035
4056
|
const _el$ = _tmpl$13();
|
|
4036
4057
|
const _ref$ = elementRef;
|
|
@@ -4094,7 +4115,7 @@ function Embed(props) {
|
|
|
4094
4115
|
scriptsRun().push(script.innerText);
|
|
4095
4116
|
new Function(script.innerText)();
|
|
4096
4117
|
} catch (error) {
|
|
4097
|
-
|
|
4118
|
+
logger.warn("[BUILDER.IO] `Embed`: Error running script:", error);
|
|
4098
4119
|
}
|
|
4099
4120
|
}
|
|
4100
4121
|
}
|
|
@@ -5279,7 +5300,7 @@ function serializeIncludingFunctions(info) {
|
|
|
5279
5300
|
}
|
|
5280
5301
|
|
|
5281
5302
|
// src/components/content-variants/inlined-fns.ts
|
|
5282
|
-
var UPDATE_COOKIES_AND_STYLES_SCRIPT = "function updateCookiesAndStyles(contentId, variants, isHydrationTarget) {\n function getAndSetVariantId() {\n function setCookie(name, value, days) {\n let expires = '';\n if (days) {\n const date = new Date();\n date.setTime(date.getTime() + days * 24 * 60 * 60 * 1000);\n expires = '; expires=' + date.toUTCString();\n }\n document.cookie = name + '=' + (value || '') + expires + '; path=/' + '; Secure; SameSite=None';\n }\n function getCookie(name) {\n const nameEQ = name + '=';\n const ca = document.cookie.split(';');\n for (let i = 0; i < ca.length; i++) {\n let c = ca[i];\n while (c.charAt(0) === ' ') c = c.substring(1, c.length);\n if (c.indexOf(nameEQ) === 0) return c.substring(nameEQ.length, c.length);\n }\n return null;\n }\n const cookieName = `builder.tests.${contentId}`;\n const variantInCookie = getCookie(cookieName);\n const availableIDs = variants.map(vr => vr.id).concat(contentId);\n if (variantInCookie && availableIDs.includes(variantInCookie)) {\n return variantInCookie;\n }\n let n = 0;\n const random = Math.random();\n for (let i = 0; i < variants.length; i++) {\n const variant = variants[i];\n const testRatio = variant.testRatio;\n n += testRatio;\n if (random < n) {\n setCookie(cookieName, variant.id);\n return variant.id;\n }\n }\n setCookie(cookieName, contentId);\n return contentId;\n }\n const winningVariantId = getAndSetVariantId();\n
|
|
5303
|
+
var UPDATE_COOKIES_AND_STYLES_SCRIPT = "function updateCookiesAndStyles(contentId, variants, isHydrationTarget, isAngularSDK) {\n function getAndSetVariantId() {\n function setCookie(name, value, days) {\n let expires = '';\n if (days) {\n const date = new Date();\n date.setTime(date.getTime() + days * 24 * 60 * 60 * 1000);\n expires = '; expires=' + date.toUTCString();\n }\n document.cookie = name + '=' + (value || '') + expires + '; path=/' + '; Secure; SameSite=None';\n }\n function getCookie(name) {\n const nameEQ = name + '=';\n const ca = document.cookie.split(';');\n for (let i = 0; i < ca.length; i++) {\n let c = ca[i];\n while (c.charAt(0) === ' ') c = c.substring(1, c.length);\n if (c.indexOf(nameEQ) === 0) return c.substring(nameEQ.length, c.length);\n }\n return null;\n }\n const cookieName = `builder.tests.${contentId}`;\n const variantInCookie = getCookie(cookieName);\n const availableIDs = variants.map(vr => vr.id).concat(contentId);\n if (variantInCookie && availableIDs.includes(variantInCookie)) {\n return variantInCookie;\n }\n let n = 0;\n const random = Math.random();\n for (let i = 0; i < variants.length; i++) {\n const variant = variants[i];\n const testRatio = variant.testRatio;\n n += testRatio;\n if (random < n) {\n setCookie(cookieName, variant.id);\n return variant.id;\n }\n }\n setCookie(cookieName, contentId);\n return contentId;\n }\n const winningVariantId = getAndSetVariantId();\n let styleEl = document.currentScript?.previousElementSibling;\n if (isAngularSDK) {\n styleEl = document.currentScript?.parentElement?.previousElementSibling?.querySelector('style');\n }\n if (isHydrationTarget) {\n styleEl.remove();\n const thisScriptEl = document.currentScript;\n thisScriptEl?.remove();\n } else {\n const newStyleStr = variants.concat({\n id: contentId\n }).filter(variant => variant.id !== winningVariantId).map(value => {\n return `.variant-${value.id} { display: none; }\n `;\n }).join('');\n styleEl.innerHTML = newStyleStr;\n }\n}";
|
|
5283
5304
|
var UPDATE_VARIANT_VISIBILITY_SCRIPT = "function updateVariantVisibility(variantContentId, defaultContentId, isHydrationTarget) {\n if (!navigator.cookieEnabled) {\n return;\n }\n function getCookie(name) {\n const nameEQ = name + '=';\n const ca = document.cookie.split(';');\n for (let i = 0; i < ca.length; i++) {\n let c = ca[i];\n while (c.charAt(0) === ' ') c = c.substring(1, c.length);\n if (c.indexOf(nameEQ) === 0) return c.substring(nameEQ.length, c.length);\n }\n return null;\n }\n const cookieName = `builder.tests.${defaultContentId}`;\n const winningVariant = getCookie(cookieName);\n const parentDiv = document.currentScript?.parentElement;\n const isDefaultContent = variantContentId === defaultContentId;\n const isWinningVariant = winningVariant === variantContentId;\n if (isWinningVariant && !isDefaultContent) {\n parentDiv?.removeAttribute('hidden');\n parentDiv?.removeAttribute('aria-hidden');\n } else if (!isWinningVariant && isDefaultContent) {\n parentDiv?.setAttribute('hidden', 'true');\n parentDiv?.setAttribute('aria-hidden', 'true');\n }\n if (isHydrationTarget) {\n if (!isWinningVariant) {\n parentDiv?.remove();\n }\n const thisScriptEl = document.currentScript;\n thisScriptEl?.remove();\n }\n return;\n}";
|
|
5284
5305
|
|
|
5285
5306
|
// src/components/content-variants/helpers.ts
|
|
@@ -5308,6 +5329,7 @@ var checkShouldRenderVariants2 = ({
|
|
|
5308
5329
|
return true;
|
|
5309
5330
|
};
|
|
5310
5331
|
var getIsHydrationTarget = (target) => target === "react" || target === "reactNative";
|
|
5332
|
+
var isAngularSDK = TARGET === "angular";
|
|
5311
5333
|
var isHydrationTarget = getIsHydrationTarget(TARGET);
|
|
5312
5334
|
var getInitVariantsFnsScriptString = () => `
|
|
5313
5335
|
window.${UPDATE_COOKIES_AND_STYLES_SCRIPT_NAME} = ${UPDATE_COOKIES_AND_STYLES_SCRIPT}
|
|
@@ -5315,7 +5337,7 @@ var getInitVariantsFnsScriptString = () => `
|
|
|
5315
5337
|
`;
|
|
5316
5338
|
var getUpdateCookieAndStylesScript = (variants, contentId) => `
|
|
5317
5339
|
window.${UPDATE_COOKIES_AND_STYLES_SCRIPT_NAME}(
|
|
5318
|
-
"${contentId}",${JSON.stringify(variants)}, ${isHydrationTarget}
|
|
5340
|
+
"${contentId}",${JSON.stringify(variants)}, ${isHydrationTarget}, ${isAngularSDK}
|
|
5319
5341
|
)`;
|
|
5320
5342
|
var getUpdateVariantVisibilityScript = ({
|
|
5321
5343
|
contentId,
|
|
@@ -5330,7 +5352,7 @@ function getPreviewContent(_searchParams) {
|
|
|
5330
5352
|
}
|
|
5331
5353
|
|
|
5332
5354
|
// src/constants/sdk-version.ts
|
|
5333
|
-
var SDK_VERSION = "4.0.
|
|
5355
|
+
var SDK_VERSION = "4.0.4";
|
|
5334
5356
|
|
|
5335
5357
|
// src/helpers/sdk-headers.ts
|
|
5336
5358
|
var getSdkHeaders = () => ({
|
package/lib/browser/dev.jsx
CHANGED
|
@@ -1480,9 +1480,10 @@ function Block(props) {
|
|
|
1480
1480
|
var Block_default = Block;
|
|
1481
1481
|
|
|
1482
1482
|
// src/components/blocks/blocks-wrapper.tsx
|
|
1483
|
-
import { onMount as onMount3, createMemo as createMemo6 } from "solid-js";
|
|
1483
|
+
import { onMount as onMount3, on as on2, createEffect as createEffect2, createMemo as createMemo6, createSignal as createSignal6 } from "solid-js";
|
|
1484
1484
|
import { Dynamic as Dynamic4 } from "solid-js/web";
|
|
1485
1485
|
function BlocksWrapper(props) {
|
|
1486
|
+
const [shouldUpdate, setShouldUpdate] = createSignal6(false);
|
|
1486
1487
|
const className = createMemo6(() => {
|
|
1487
1488
|
return [
|
|
1488
1489
|
"builder-blocks",
|
|
@@ -1529,9 +1530,13 @@ function BlocksWrapper(props) {
|
|
|
1529
1530
|
let blocksWrapperRef;
|
|
1530
1531
|
onMount3(() => {
|
|
1531
1532
|
});
|
|
1533
|
+
const onUpdateFn_0_props_blocks = createMemo6(() => props.blocks);
|
|
1534
|
+
function onUpdateFn_0() {
|
|
1535
|
+
}
|
|
1536
|
+
createEffect2(on2(() => [onUpdateFn_0_props_blocks()], onUpdateFn_0));
|
|
1532
1537
|
return <>
|
|
1533
1538
|
<Dynamic4
|
|
1534
|
-
class={className() + " dynamic-
|
|
1539
|
+
class={className() + " dynamic-023c60f2"}
|
|
1535
1540
|
ref={blocksWrapperRef}
|
|
1536
1541
|
builder-path={dataPath()}
|
|
1537
1542
|
builder-parent-id={props.parent}
|
|
@@ -1543,7 +1548,7 @@ function BlocksWrapper(props) {
|
|
|
1543
1548
|
{...props.BlocksWrapperProps}
|
|
1544
1549
|
component={props.BlocksWrapper}
|
|
1545
1550
|
>{props.children}</Dynamic4>
|
|
1546
|
-
<style>{`.dynamic-
|
|
1551
|
+
<style>{`.dynamic-023c60f2 {
|
|
1547
1552
|
display: flex;
|
|
1548
1553
|
flex-direction: column;
|
|
1549
1554
|
align-items: stretch;
|
|
@@ -1847,10 +1852,11 @@ function Image(props) {
|
|
|
1847
1852
|
<picture>
|
|
1848
1853
|
<Show8 when={webpSrcSet()}><source type="image/webp" srcset={webpSrcSet()} /></Show8>
|
|
1849
1854
|
<img
|
|
1850
|
-
class={"builder-image" + (props.className ? " " + props.className : "") + " img-
|
|
1855
|
+
class={"builder-image" + (props.className ? " " + props.className : "") + " img-040e729e"}
|
|
1851
1856
|
loading={props.highPriority ? "eager" : "lazy"}
|
|
1852
1857
|
fetchpriority={props.highPriority ? "high" : "auto"}
|
|
1853
1858
|
alt={props.altText}
|
|
1859
|
+
title={props.title}
|
|
1854
1860
|
role={props.altText ? void 0 : "presentation"}
|
|
1855
1861
|
style={{
|
|
1856
1862
|
"object-position": props.backgroundPosition || "center",
|
|
@@ -1865,22 +1871,22 @@ function Image(props) {
|
|
|
1865
1871
|
<Show8
|
|
1866
1872
|
when={props.aspectRatio && !(props.builderBlock?.children?.length && props.fitContent)}
|
|
1867
1873
|
><div
|
|
1868
|
-
class="builder-image-sizer div-
|
|
1874
|
+
class="builder-image-sizer div-040e729e"
|
|
1869
1875
|
style={{
|
|
1870
1876
|
"padding-top": props.aspectRatio * 100 + "%"
|
|
1871
1877
|
}}
|
|
1872
1878
|
/></Show8>
|
|
1873
1879
|
<Show8 when={props.builderBlock?.children?.length && props.fitContent}>{props.children}</Show8>
|
|
1874
|
-
<Show8 when={!props.fitContent && props.builderBlock?.children?.length}><div class="div-
|
|
1880
|
+
<Show8 when={!props.fitContent && props.builderBlock?.children?.length}><div class="div-040e729e-2">{props.children}</div></Show8>
|
|
1875
1881
|
</>
|
|
1876
|
-
<style>{`.img-
|
|
1882
|
+
<style>{`.img-040e729e {
|
|
1877
1883
|
opacity: 1;
|
|
1878
1884
|
transition: opacity 0.2s ease-in-out;
|
|
1879
|
-
}.div-
|
|
1885
|
+
}.div-040e729e {
|
|
1880
1886
|
width: 100%;
|
|
1881
1887
|
pointer-events: none;
|
|
1882
1888
|
font-size: 0;
|
|
1883
|
-
}.div-
|
|
1889
|
+
}.div-040e729e-2 {
|
|
1884
1890
|
display: flex;
|
|
1885
1891
|
flex-direction: column;
|
|
1886
1892
|
align-items: stretch;
|
|
@@ -1916,7 +1922,7 @@ function SectionComponent(props) {
|
|
|
1916
1922
|
var section_default = SectionComponent;
|
|
1917
1923
|
|
|
1918
1924
|
// src/blocks/symbol/symbol.tsx
|
|
1919
|
-
import { onMount as onMount9, on as
|
|
1925
|
+
import { onMount as onMount9, on as on6, createEffect as createEffect6, createMemo as createMemo20, createSignal as createSignal20 } from "solid-js";
|
|
1920
1926
|
|
|
1921
1927
|
// src/components/content-variants/content-variants.tsx
|
|
1922
1928
|
import { Show as Show16, For as For9, onMount as onMount8, createSignal as createSignal19, createMemo as createMemo19 } from "solid-js";
|
|
@@ -2815,6 +2821,10 @@ var componentInfo5 = {
|
|
|
2815
2821
|
name: "altText",
|
|
2816
2822
|
type: "string",
|
|
2817
2823
|
helperText: "Text to display when the user has images off"
|
|
2824
|
+
}, {
|
|
2825
|
+
name: "title",
|
|
2826
|
+
type: "string",
|
|
2827
|
+
helperText: "Text to display when hovering over the asset"
|
|
2818
2828
|
}, {
|
|
2819
2829
|
name: "height",
|
|
2820
2830
|
type: "number",
|
|
@@ -3625,13 +3635,12 @@ var componentInfo12 = {
|
|
|
3625
3635
|
};
|
|
3626
3636
|
|
|
3627
3637
|
// src/blocks/custom-code/custom-code.tsx
|
|
3628
|
-
import { onMount as onMount5, createSignal as createSignal12 } from "solid-js";
|
|
3638
|
+
import { onMount as onMount5, on as on3, createEffect as createEffect3, createMemo as createMemo12, createSignal as createSignal12 } from "solid-js";
|
|
3629
3639
|
function CustomCode(props) {
|
|
3630
3640
|
const [scriptsInserted, setScriptsInserted] = createSignal12([]);
|
|
3631
3641
|
const [scriptsRun, setScriptsRun] = createSignal12([]);
|
|
3632
|
-
|
|
3633
|
-
|
|
3634
|
-
if (!elementRef?.getElementsByTagName || typeof window === "undefined") {
|
|
3642
|
+
function runScripts() {
|
|
3643
|
+
if (!elementRef || !elementRef?.getElementsByTagName || typeof window === "undefined") {
|
|
3635
3644
|
return;
|
|
3636
3645
|
}
|
|
3637
3646
|
const scripts = elementRef.getElementsByTagName("script");
|
|
@@ -3658,11 +3667,25 @@ function CustomCode(props) {
|
|
|
3658
3667
|
scriptsRun().push(script.innerText);
|
|
3659
3668
|
new Function(script.innerText)();
|
|
3660
3669
|
} catch (error) {
|
|
3661
|
-
|
|
3670
|
+
logger.warn(
|
|
3671
|
+
"[BUILDER.IO] `CustomCode`: Error running script:",
|
|
3672
|
+
error
|
|
3673
|
+
);
|
|
3662
3674
|
}
|
|
3663
3675
|
}
|
|
3664
3676
|
}
|
|
3677
|
+
}
|
|
3678
|
+
let elementRef;
|
|
3679
|
+
onMount5(() => {
|
|
3680
|
+
runScripts();
|
|
3665
3681
|
});
|
|
3682
|
+
const onUpdateFn_0_props_code = createMemo12(() => props.code);
|
|
3683
|
+
function onUpdateFn_0() {
|
|
3684
|
+
if (isEditing()) {
|
|
3685
|
+
runScripts();
|
|
3686
|
+
}
|
|
3687
|
+
}
|
|
3688
|
+
createEffect3(on3(() => [onUpdateFn_0_props_code()], onUpdateFn_0));
|
|
3666
3689
|
return <><div
|
|
3667
3690
|
class={"builder-custom-code" + (props.replaceNodes ? " replace-nodes" : "")}
|
|
3668
3691
|
ref={elementRef}
|
|
@@ -3690,7 +3713,7 @@ var componentInfo13 = {
|
|
|
3690
3713
|
};
|
|
3691
3714
|
|
|
3692
3715
|
// src/blocks/embed/embed.tsx
|
|
3693
|
-
import { on as
|
|
3716
|
+
import { on as on4, createEffect as createEffect4, createMemo as createMemo13, createSignal as createSignal13 } from "solid-js";
|
|
3694
3717
|
|
|
3695
3718
|
// src/blocks/embed/helpers.ts
|
|
3696
3719
|
var SCRIPT_MIME_TYPES = ["text/javascript", "application/javascript", "application/ecmascript"];
|
|
@@ -3718,7 +3741,7 @@ function Embed(props) {
|
|
|
3718
3741
|
scriptsRun().push(script.innerText);
|
|
3719
3742
|
new Function(script.innerText)();
|
|
3720
3743
|
} catch (error) {
|
|
3721
|
-
|
|
3744
|
+
logger.warn("[BUILDER.IO] `Embed`: Error running script:", error);
|
|
3722
3745
|
}
|
|
3723
3746
|
}
|
|
3724
3747
|
}
|
|
@@ -3732,8 +3755,8 @@ function Embed(props) {
|
|
|
3732
3755
|
findAndRunScripts();
|
|
3733
3756
|
}
|
|
3734
3757
|
}
|
|
3735
|
-
|
|
3736
|
-
|
|
3758
|
+
createEffect4(
|
|
3759
|
+
on4(() => [onUpdateFn_0_elem(), onUpdateFn_0_ranInitFn__()], onUpdateFn_0)
|
|
3737
3760
|
);
|
|
3738
3761
|
return <><div class="builder-embed" ref={elem} innerHTML={props.content} /></>;
|
|
3739
3762
|
}
|
|
@@ -4775,7 +4798,7 @@ function serializeIncludingFunctions(info) {
|
|
|
4775
4798
|
}
|
|
4776
4799
|
|
|
4777
4800
|
// src/components/content-variants/inlined-fns.ts
|
|
4778
|
-
var UPDATE_COOKIES_AND_STYLES_SCRIPT = "function updateCookiesAndStyles(contentId, variants, isHydrationTarget) {\n function getAndSetVariantId() {\n function setCookie(name, value, days) {\n let expires = '';\n if (days) {\n const date = new Date();\n date.setTime(date.getTime() + days * 24 * 60 * 60 * 1000);\n expires = '; expires=' + date.toUTCString();\n }\n document.cookie = name + '=' + (value || '') + expires + '; path=/' + '; Secure; SameSite=None';\n }\n function getCookie(name) {\n const nameEQ = name + '=';\n const ca = document.cookie.split(';');\n for (let i = 0; i < ca.length; i++) {\n let c = ca[i];\n while (c.charAt(0) === ' ') c = c.substring(1, c.length);\n if (c.indexOf(nameEQ) === 0) return c.substring(nameEQ.length, c.length);\n }\n return null;\n }\n const cookieName = `builder.tests.${contentId}`;\n const variantInCookie = getCookie(cookieName);\n const availableIDs = variants.map(vr => vr.id).concat(contentId);\n if (variantInCookie && availableIDs.includes(variantInCookie)) {\n return variantInCookie;\n }\n let n = 0;\n const random = Math.random();\n for (let i = 0; i < variants.length; i++) {\n const variant = variants[i];\n const testRatio = variant.testRatio;\n n += testRatio;\n if (random < n) {\n setCookie(cookieName, variant.id);\n return variant.id;\n }\n }\n setCookie(cookieName, contentId);\n return contentId;\n }\n const winningVariantId = getAndSetVariantId();\n
|
|
4801
|
+
var UPDATE_COOKIES_AND_STYLES_SCRIPT = "function updateCookiesAndStyles(contentId, variants, isHydrationTarget, isAngularSDK) {\n function getAndSetVariantId() {\n function setCookie(name, value, days) {\n let expires = '';\n if (days) {\n const date = new Date();\n date.setTime(date.getTime() + days * 24 * 60 * 60 * 1000);\n expires = '; expires=' + date.toUTCString();\n }\n document.cookie = name + '=' + (value || '') + expires + '; path=/' + '; Secure; SameSite=None';\n }\n function getCookie(name) {\n const nameEQ = name + '=';\n const ca = document.cookie.split(';');\n for (let i = 0; i < ca.length; i++) {\n let c = ca[i];\n while (c.charAt(0) === ' ') c = c.substring(1, c.length);\n if (c.indexOf(nameEQ) === 0) return c.substring(nameEQ.length, c.length);\n }\n return null;\n }\n const cookieName = `builder.tests.${contentId}`;\n const variantInCookie = getCookie(cookieName);\n const availableIDs = variants.map(vr => vr.id).concat(contentId);\n if (variantInCookie && availableIDs.includes(variantInCookie)) {\n return variantInCookie;\n }\n let n = 0;\n const random = Math.random();\n for (let i = 0; i < variants.length; i++) {\n const variant = variants[i];\n const testRatio = variant.testRatio;\n n += testRatio;\n if (random < n) {\n setCookie(cookieName, variant.id);\n return variant.id;\n }\n }\n setCookie(cookieName, contentId);\n return contentId;\n }\n const winningVariantId = getAndSetVariantId();\n let styleEl = document.currentScript?.previousElementSibling;\n if (isAngularSDK) {\n styleEl = document.currentScript?.parentElement?.previousElementSibling?.querySelector('style');\n }\n if (isHydrationTarget) {\n styleEl.remove();\n const thisScriptEl = document.currentScript;\n thisScriptEl?.remove();\n } else {\n const newStyleStr = variants.concat({\n id: contentId\n }).filter(variant => variant.id !== winningVariantId).map(value => {\n return `.variant-${value.id} { display: none; }\n `;\n }).join('');\n styleEl.innerHTML = newStyleStr;\n }\n}";
|
|
4779
4802
|
var UPDATE_VARIANT_VISIBILITY_SCRIPT = "function updateVariantVisibility(variantContentId, defaultContentId, isHydrationTarget) {\n if (!navigator.cookieEnabled) {\n return;\n }\n function getCookie(name) {\n const nameEQ = name + '=';\n const ca = document.cookie.split(';');\n for (let i = 0; i < ca.length; i++) {\n let c = ca[i];\n while (c.charAt(0) === ' ') c = c.substring(1, c.length);\n if (c.indexOf(nameEQ) === 0) return c.substring(nameEQ.length, c.length);\n }\n return null;\n }\n const cookieName = `builder.tests.${defaultContentId}`;\n const winningVariant = getCookie(cookieName);\n const parentDiv = document.currentScript?.parentElement;\n const isDefaultContent = variantContentId === defaultContentId;\n const isWinningVariant = winningVariant === variantContentId;\n if (isWinningVariant && !isDefaultContent) {\n parentDiv?.removeAttribute('hidden');\n parentDiv?.removeAttribute('aria-hidden');\n } else if (!isWinningVariant && isDefaultContent) {\n parentDiv?.setAttribute('hidden', 'true');\n parentDiv?.setAttribute('aria-hidden', 'true');\n }\n if (isHydrationTarget) {\n if (!isWinningVariant) {\n parentDiv?.remove();\n }\n const thisScriptEl = document.currentScript;\n thisScriptEl?.remove();\n }\n return;\n}";
|
|
4780
4803
|
|
|
4781
4804
|
// src/components/content-variants/helpers.ts
|
|
@@ -4804,6 +4827,7 @@ var checkShouldRenderVariants2 = ({
|
|
|
4804
4827
|
return true;
|
|
4805
4828
|
};
|
|
4806
4829
|
var getIsHydrationTarget = (target) => target === "react" || target === "reactNative";
|
|
4830
|
+
var isAngularSDK = TARGET === "angular";
|
|
4807
4831
|
var isHydrationTarget = getIsHydrationTarget(TARGET);
|
|
4808
4832
|
var getInitVariantsFnsScriptString = () => `
|
|
4809
4833
|
window.${UPDATE_COOKIES_AND_STYLES_SCRIPT_NAME} = ${UPDATE_COOKIES_AND_STYLES_SCRIPT}
|
|
@@ -4811,7 +4835,7 @@ var getInitVariantsFnsScriptString = () => `
|
|
|
4811
4835
|
`;
|
|
4812
4836
|
var getUpdateCookieAndStylesScript = (variants, contentId) => `
|
|
4813
4837
|
window.${UPDATE_COOKIES_AND_STYLES_SCRIPT_NAME}(
|
|
4814
|
-
"${contentId}",${JSON.stringify(variants)}, ${isHydrationTarget}
|
|
4838
|
+
"${contentId}",${JSON.stringify(variants)}, ${isHydrationTarget}, ${isAngularSDK}
|
|
4815
4839
|
)`;
|
|
4816
4840
|
var getUpdateVariantVisibilityScript = ({
|
|
4817
4841
|
contentId,
|
|
@@ -4824,8 +4848,8 @@ var getUpdateVariantVisibilityScript = ({
|
|
|
4824
4848
|
import {
|
|
4825
4849
|
Show as Show14,
|
|
4826
4850
|
onMount as onMount7,
|
|
4827
|
-
on as
|
|
4828
|
-
createEffect as
|
|
4851
|
+
on as on5,
|
|
4852
|
+
createEffect as createEffect5,
|
|
4829
4853
|
createMemo as createMemo16,
|
|
4830
4854
|
createSignal as createSignal16
|
|
4831
4855
|
} from "solid-js";
|
|
@@ -4837,7 +4861,7 @@ function getPreviewContent(_searchParams) {
|
|
|
4837
4861
|
}
|
|
4838
4862
|
|
|
4839
4863
|
// src/constants/sdk-version.ts
|
|
4840
|
-
var SDK_VERSION = "4.0.
|
|
4864
|
+
var SDK_VERSION = "4.0.4";
|
|
4841
4865
|
|
|
4842
4866
|
// src/helpers/sdk-headers.ts
|
|
4843
4867
|
var getSdkHeaders = () => ({
|
|
@@ -5929,15 +5953,15 @@ function EnableEditor(props) {
|
|
|
5929
5953
|
mergeNewContent(props.content);
|
|
5930
5954
|
}
|
|
5931
5955
|
}
|
|
5932
|
-
|
|
5956
|
+
createEffect5(on5(() => [onUpdateFn_0_props_content()], onUpdateFn_0));
|
|
5933
5957
|
const onUpdateFn_1_props_builderContextSignal_rootState = createMemo16(
|
|
5934
5958
|
() => props.builderContextSignal.rootState
|
|
5935
5959
|
);
|
|
5936
5960
|
function onUpdateFn_1() {
|
|
5937
5961
|
emitStateUpdate();
|
|
5938
5962
|
}
|
|
5939
|
-
|
|
5940
|
-
|
|
5963
|
+
createEffect5(
|
|
5964
|
+
on5(
|
|
5941
5965
|
() => [onUpdateFn_1_props_builderContextSignal_rootState()],
|
|
5942
5966
|
onUpdateFn_1
|
|
5943
5967
|
)
|
|
@@ -5948,7 +5972,7 @@ function EnableEditor(props) {
|
|
|
5948
5972
|
mergeNewRootState(props.data);
|
|
5949
5973
|
}
|
|
5950
5974
|
}
|
|
5951
|
-
|
|
5975
|
+
createEffect5(on5(() => [onUpdateFn_2_props_data()], onUpdateFn_2));
|
|
5952
5976
|
const onUpdateFn_3_props_locale = createMemo16(() => props.locale);
|
|
5953
5977
|
function onUpdateFn_3() {
|
|
5954
5978
|
if (props.locale) {
|
|
@@ -5957,7 +5981,7 @@ function EnableEditor(props) {
|
|
|
5957
5981
|
});
|
|
5958
5982
|
}
|
|
5959
5983
|
}
|
|
5960
|
-
|
|
5984
|
+
createEffect5(on5(() => [onUpdateFn_3_props_locale()], onUpdateFn_3));
|
|
5961
5985
|
return <><builder_context_default.Provider value={props.builderContextSignal}><Show14
|
|
5962
5986
|
when={props.builderContextSignal.content || needsElementRefDivForEditing()}
|
|
5963
5987
|
><Dynamic5
|
|
@@ -6335,7 +6359,7 @@ function Symbol(props) {
|
|
|
6335
6359
|
function onUpdateFn_0() {
|
|
6336
6360
|
setContent();
|
|
6337
6361
|
}
|
|
6338
|
-
|
|
6362
|
+
createEffect6(on6(() => [onUpdateFn_0_props_symbol()], onUpdateFn_0));
|
|
6339
6363
|
return <><div class={className()} {...{}} {...props.attributes} {...{}}><Content_variants_default
|
|
6340
6364
|
nonce={props.builderContext.nonce}
|
|
6341
6365
|
isNestedRender={true}
|
package/lib/browser/index.js
CHANGED
|
@@ -1632,12 +1632,13 @@ function Block(props) {
|
|
|
1632
1632
|
});
|
|
1633
1633
|
}
|
|
1634
1634
|
var block_default = Block;
|
|
1635
|
-
var _tmpl$2 = /* @__PURE__ */ template(`<style>.dynamic-
|
|
1635
|
+
var _tmpl$2 = /* @__PURE__ */ template(`<style>.dynamic-023c60f2 {
|
|
1636
1636
|
display: flex;
|
|
1637
1637
|
flex-direction: column;
|
|
1638
1638
|
align-items: stretch;
|
|
1639
1639
|
}`);
|
|
1640
1640
|
function BlocksWrapper(props) {
|
|
1641
|
+
createSignal(false);
|
|
1641
1642
|
const className = createMemo(() => {
|
|
1642
1643
|
return ["builder-blocks", !props.blocks?.length ? "no-blocks" : "", props.classNameProp].filter(Boolean).join(" ");
|
|
1643
1644
|
});
|
|
@@ -1674,9 +1675,13 @@ function BlocksWrapper(props) {
|
|
|
1674
1675
|
let blocksWrapperRef;
|
|
1675
1676
|
onMount(() => {
|
|
1676
1677
|
});
|
|
1678
|
+
const onUpdateFn_0_props_blocks = createMemo(() => props.blocks);
|
|
1679
|
+
function onUpdateFn_0() {
|
|
1680
|
+
}
|
|
1681
|
+
createEffect(on(() => [onUpdateFn_0_props_blocks()], onUpdateFn_0));
|
|
1677
1682
|
return [createComponent(Dynamic, mergeProps({
|
|
1678
1683
|
get ["class"]() {
|
|
1679
|
-
return className() + " dynamic-
|
|
1684
|
+
return className() + " dynamic-023c60f2";
|
|
1680
1685
|
},
|
|
1681
1686
|
ref(r$) {
|
|
1682
1687
|
const _ref$ = blocksWrapperRef;
|
|
@@ -2029,16 +2034,16 @@ function getSrcSet(url) {
|
|
|
2029
2034
|
// src/blocks/image/image.tsx
|
|
2030
2035
|
var _tmpl$5 = /* @__PURE__ */ template(`<source type=image/webp>`);
|
|
2031
2036
|
var _tmpl$23 = /* @__PURE__ */ template(`<picture><img>`);
|
|
2032
|
-
var _tmpl$32 = /* @__PURE__ */ template(`<div class="builder-image-sizer div-
|
|
2033
|
-
var _tmpl$42 = /* @__PURE__ */ template(`<div class=div-
|
|
2034
|
-
var _tmpl$52 = /* @__PURE__ */ template(`<style>.img-
|
|
2037
|
+
var _tmpl$32 = /* @__PURE__ */ template(`<div class="builder-image-sizer div-040e729e">`);
|
|
2038
|
+
var _tmpl$42 = /* @__PURE__ */ template(`<div class=div-040e729e-2>`);
|
|
2039
|
+
var _tmpl$52 = /* @__PURE__ */ template(`<style>.img-040e729e {
|
|
2035
2040
|
opacity: 1;
|
|
2036
2041
|
transition: opacity 0.2s ease-in-out;
|
|
2037
|
-
}.div-
|
|
2042
|
+
}.div-040e729e {
|
|
2038
2043
|
width: 100%;
|
|
2039
2044
|
pointer-events: none;
|
|
2040
2045
|
font-size: 0;
|
|
2041
|
-
}.div-
|
|
2046
|
+
}.div-040e729e-2 {
|
|
2042
2047
|
display: flex;
|
|
2043
2048
|
flex-direction: column;
|
|
2044
2049
|
align-items: stretch;
|
|
@@ -2100,20 +2105,21 @@ function Image(props) {
|
|
|
2100
2105
|
}
|
|
2101
2106
|
}), _el$3);
|
|
2102
2107
|
effect((_p$) => {
|
|
2103
|
-
const _v$ = "builder-image" + (props.className ? " " + props.className : "") + " img-
|
|
2108
|
+
const _v$ = "builder-image" + (props.className ? " " + props.className : "") + " img-040e729e", _v$2 = props.highPriority ? "eager" : "lazy", _v$3 = props.highPriority ? "high" : "auto", _v$4 = props.altText, _v$5 = props.title, _v$6 = props.altText ? void 0 : "presentation", _v$7 = {
|
|
2104
2109
|
"object-position": props.backgroundPosition || "center",
|
|
2105
2110
|
"object-fit": props.backgroundSize || "cover",
|
|
2106
2111
|
...aspectRatioCss()
|
|
2107
|
-
}, _v$
|
|
2112
|
+
}, _v$8 = props.image, _v$9 = srcSetToUse(), _v$10 = props.sizes;
|
|
2108
2113
|
_v$ !== _p$._v$ && className(_el$3, _p$._v$ = _v$);
|
|
2109
2114
|
_v$2 !== _p$._v$2 && setAttribute(_el$3, "loading", _p$._v$2 = _v$2);
|
|
2110
2115
|
_v$3 !== _p$._v$3 && setAttribute(_el$3, "fetchpriority", _p$._v$3 = _v$3);
|
|
2111
2116
|
_v$4 !== _p$._v$4 && setAttribute(_el$3, "alt", _p$._v$4 = _v$4);
|
|
2112
|
-
_v$5 !== _p$._v$5 && setAttribute(_el$3, "
|
|
2113
|
-
_p$._v$6
|
|
2114
|
-
|
|
2115
|
-
_v$8 !== _p$._v$8 && setAttribute(_el$3, "
|
|
2116
|
-
_v$9 !== _p$._v$9 && setAttribute(_el$3, "
|
|
2117
|
+
_v$5 !== _p$._v$5 && setAttribute(_el$3, "title", _p$._v$5 = _v$5);
|
|
2118
|
+
_v$6 !== _p$._v$6 && setAttribute(_el$3, "role", _p$._v$6 = _v$6);
|
|
2119
|
+
_p$._v$7 = style(_el$3, _v$7, _p$._v$7);
|
|
2120
|
+
_v$8 !== _p$._v$8 && setAttribute(_el$3, "src", _p$._v$8 = _v$8);
|
|
2121
|
+
_v$9 !== _p$._v$9 && setAttribute(_el$3, "srcset", _p$._v$9 = _v$9);
|
|
2122
|
+
_v$10 !== _p$._v$10 && setAttribute(_el$3, "sizes", _p$._v$10 = _v$10);
|
|
2117
2123
|
return _p$;
|
|
2118
2124
|
}, {
|
|
2119
2125
|
_v$: void 0,
|
|
@@ -2124,7 +2130,8 @@ function Image(props) {
|
|
|
2124
2130
|
_v$6: void 0,
|
|
2125
2131
|
_v$7: void 0,
|
|
2126
2132
|
_v$8: void 0,
|
|
2127
|
-
_v$9: void 0
|
|
2133
|
+
_v$9: void 0,
|
|
2134
|
+
_v$10: void 0
|
|
2128
2135
|
});
|
|
2129
2136
|
return _el$;
|
|
2130
2137
|
})(), createComponent(Show, {
|
|
@@ -3107,6 +3114,10 @@ var componentInfo5 = {
|
|
|
3107
3114
|
name: "altText",
|
|
3108
3115
|
type: "string",
|
|
3109
3116
|
helperText: "Text to display when the user has images off"
|
|
3117
|
+
}, {
|
|
3118
|
+
name: "title",
|
|
3119
|
+
type: "string",
|
|
3120
|
+
helperText: "Text to display when hovering over the asset"
|
|
3110
3121
|
}, {
|
|
3111
3122
|
name: "height",
|
|
3112
3123
|
type: "number",
|
|
@@ -3990,9 +4001,8 @@ var _tmpl$13 = /* @__PURE__ */ template(`<div>`);
|
|
|
3990
4001
|
function CustomCode(props) {
|
|
3991
4002
|
const [scriptsInserted, setScriptsInserted] = createSignal([]);
|
|
3992
4003
|
const [scriptsRun, setScriptsRun] = createSignal([]);
|
|
3993
|
-
|
|
3994
|
-
|
|
3995
|
-
if (!elementRef?.getElementsByTagName || typeof window === "undefined") {
|
|
4004
|
+
function runScripts() {
|
|
4005
|
+
if (!elementRef || !elementRef?.getElementsByTagName || typeof window === "undefined") {
|
|
3996
4006
|
return;
|
|
3997
4007
|
}
|
|
3998
4008
|
const scripts = elementRef.getElementsByTagName("script");
|
|
@@ -4015,10 +4025,22 @@ function CustomCode(props) {
|
|
|
4015
4025
|
scriptsRun().push(script.innerText);
|
|
4016
4026
|
new Function(script.innerText)();
|
|
4017
4027
|
} catch (error) {
|
|
4028
|
+
logger.warn("[BUILDER.IO] `CustomCode`: Error running script:", error);
|
|
4018
4029
|
}
|
|
4019
4030
|
}
|
|
4020
4031
|
}
|
|
4032
|
+
}
|
|
4033
|
+
let elementRef;
|
|
4034
|
+
onMount(() => {
|
|
4035
|
+
runScripts();
|
|
4021
4036
|
});
|
|
4037
|
+
const onUpdateFn_0_props_code = createMemo(() => props.code);
|
|
4038
|
+
function onUpdateFn_0() {
|
|
4039
|
+
if (isEditing()) {
|
|
4040
|
+
runScripts();
|
|
4041
|
+
}
|
|
4042
|
+
}
|
|
4043
|
+
createEffect(on(() => [onUpdateFn_0_props_code()], onUpdateFn_0));
|
|
4022
4044
|
return (() => {
|
|
4023
4045
|
const _el$ = _tmpl$13();
|
|
4024
4046
|
const _ref$ = elementRef;
|
|
@@ -4082,6 +4104,7 @@ function Embed(props) {
|
|
|
4082
4104
|
scriptsRun().push(script.innerText);
|
|
4083
4105
|
new Function(script.innerText)();
|
|
4084
4106
|
} catch (error) {
|
|
4107
|
+
logger.warn("[BUILDER.IO] `Embed`: Error running script:", error);
|
|
4085
4108
|
}
|
|
4086
4109
|
}
|
|
4087
4110
|
}
|
|
@@ -5265,7 +5288,7 @@ function serializeIncludingFunctions(info) {
|
|
|
5265
5288
|
}
|
|
5266
5289
|
|
|
5267
5290
|
// src/components/content-variants/inlined-fns.ts
|
|
5268
|
-
var UPDATE_COOKIES_AND_STYLES_SCRIPT = "function updateCookiesAndStyles(contentId, variants, isHydrationTarget) {\n function getAndSetVariantId() {\n function setCookie(name, value, days) {\n let expires = '';\n if (days) {\n const date = new Date();\n date.setTime(date.getTime() + days * 24 * 60 * 60 * 1000);\n expires = '; expires=' + date.toUTCString();\n }\n document.cookie = name + '=' + (value || '') + expires + '; path=/' + '; Secure; SameSite=None';\n }\n function getCookie(name) {\n const nameEQ = name + '=';\n const ca = document.cookie.split(';');\n for (let i = 0; i < ca.length; i++) {\n let c = ca[i];\n while (c.charAt(0) === ' ') c = c.substring(1, c.length);\n if (c.indexOf(nameEQ) === 0) return c.substring(nameEQ.length, c.length);\n }\n return null;\n }\n const cookieName = `builder.tests.${contentId}`;\n const variantInCookie = getCookie(cookieName);\n const availableIDs = variants.map(vr => vr.id).concat(contentId);\n if (variantInCookie && availableIDs.includes(variantInCookie)) {\n return variantInCookie;\n }\n let n = 0;\n const random = Math.random();\n for (let i = 0; i < variants.length; i++) {\n const variant = variants[i];\n const testRatio = variant.testRatio;\n n += testRatio;\n if (random < n) {\n setCookie(cookieName, variant.id);\n return variant.id;\n }\n }\n setCookie(cookieName, contentId);\n return contentId;\n }\n const winningVariantId = getAndSetVariantId();\n
|
|
5291
|
+
var UPDATE_COOKIES_AND_STYLES_SCRIPT = "function updateCookiesAndStyles(contentId, variants, isHydrationTarget, isAngularSDK) {\n function getAndSetVariantId() {\n function setCookie(name, value, days) {\n let expires = '';\n if (days) {\n const date = new Date();\n date.setTime(date.getTime() + days * 24 * 60 * 60 * 1000);\n expires = '; expires=' + date.toUTCString();\n }\n document.cookie = name + '=' + (value || '') + expires + '; path=/' + '; Secure; SameSite=None';\n }\n function getCookie(name) {\n const nameEQ = name + '=';\n const ca = document.cookie.split(';');\n for (let i = 0; i < ca.length; i++) {\n let c = ca[i];\n while (c.charAt(0) === ' ') c = c.substring(1, c.length);\n if (c.indexOf(nameEQ) === 0) return c.substring(nameEQ.length, c.length);\n }\n return null;\n }\n const cookieName = `builder.tests.${contentId}`;\n const variantInCookie = getCookie(cookieName);\n const availableIDs = variants.map(vr => vr.id).concat(contentId);\n if (variantInCookie && availableIDs.includes(variantInCookie)) {\n return variantInCookie;\n }\n let n = 0;\n const random = Math.random();\n for (let i = 0; i < variants.length; i++) {\n const variant = variants[i];\n const testRatio = variant.testRatio;\n n += testRatio;\n if (random < n) {\n setCookie(cookieName, variant.id);\n return variant.id;\n }\n }\n setCookie(cookieName, contentId);\n return contentId;\n }\n const winningVariantId = getAndSetVariantId();\n let styleEl = document.currentScript?.previousElementSibling;\n if (isAngularSDK) {\n styleEl = document.currentScript?.parentElement?.previousElementSibling?.querySelector('style');\n }\n if (isHydrationTarget) {\n styleEl.remove();\n const thisScriptEl = document.currentScript;\n thisScriptEl?.remove();\n } else {\n const newStyleStr = variants.concat({\n id: contentId\n }).filter(variant => variant.id !== winningVariantId).map(value => {\n return `.variant-${value.id} { display: none; }\n `;\n }).join('');\n styleEl.innerHTML = newStyleStr;\n }\n}";
|
|
5269
5292
|
var UPDATE_VARIANT_VISIBILITY_SCRIPT = "function updateVariantVisibility(variantContentId, defaultContentId, isHydrationTarget) {\n if (!navigator.cookieEnabled) {\n return;\n }\n function getCookie(name) {\n const nameEQ = name + '=';\n const ca = document.cookie.split(';');\n for (let i = 0; i < ca.length; i++) {\n let c = ca[i];\n while (c.charAt(0) === ' ') c = c.substring(1, c.length);\n if (c.indexOf(nameEQ) === 0) return c.substring(nameEQ.length, c.length);\n }\n return null;\n }\n const cookieName = `builder.tests.${defaultContentId}`;\n const winningVariant = getCookie(cookieName);\n const parentDiv = document.currentScript?.parentElement;\n const isDefaultContent = variantContentId === defaultContentId;\n const isWinningVariant = winningVariant === variantContentId;\n if (isWinningVariant && !isDefaultContent) {\n parentDiv?.removeAttribute('hidden');\n parentDiv?.removeAttribute('aria-hidden');\n } else if (!isWinningVariant && isDefaultContent) {\n parentDiv?.setAttribute('hidden', 'true');\n parentDiv?.setAttribute('aria-hidden', 'true');\n }\n if (isHydrationTarget) {\n if (!isWinningVariant) {\n parentDiv?.remove();\n }\n const thisScriptEl = document.currentScript;\n thisScriptEl?.remove();\n }\n return;\n}";
|
|
5270
5293
|
|
|
5271
5294
|
// src/components/content-variants/helpers.ts
|
|
@@ -5294,6 +5317,7 @@ var checkShouldRenderVariants2 = ({
|
|
|
5294
5317
|
return true;
|
|
5295
5318
|
};
|
|
5296
5319
|
var getIsHydrationTarget = (target) => target === "react" || target === "reactNative";
|
|
5320
|
+
var isAngularSDK = TARGET === "angular";
|
|
5297
5321
|
var isHydrationTarget = getIsHydrationTarget(TARGET);
|
|
5298
5322
|
var getInitVariantsFnsScriptString = () => `
|
|
5299
5323
|
window.${UPDATE_COOKIES_AND_STYLES_SCRIPT_NAME} = ${UPDATE_COOKIES_AND_STYLES_SCRIPT}
|
|
@@ -5301,7 +5325,7 @@ var getInitVariantsFnsScriptString = () => `
|
|
|
5301
5325
|
`;
|
|
5302
5326
|
var getUpdateCookieAndStylesScript = (variants, contentId) => `
|
|
5303
5327
|
window.${UPDATE_COOKIES_AND_STYLES_SCRIPT_NAME}(
|
|
5304
|
-
"${contentId}",${JSON.stringify(variants)}, ${isHydrationTarget}
|
|
5328
|
+
"${contentId}",${JSON.stringify(variants)}, ${isHydrationTarget}, ${isAngularSDK}
|
|
5305
5329
|
)`;
|
|
5306
5330
|
var getUpdateVariantVisibilityScript = ({
|
|
5307
5331
|
contentId,
|
|
@@ -5316,7 +5340,7 @@ function getPreviewContent(_searchParams) {
|
|
|
5316
5340
|
}
|
|
5317
5341
|
|
|
5318
5342
|
// src/constants/sdk-version.ts
|
|
5319
|
-
var SDK_VERSION = "4.0.
|
|
5343
|
+
var SDK_VERSION = "4.0.4";
|
|
5320
5344
|
|
|
5321
5345
|
// src/helpers/sdk-headers.ts
|
|
5322
5346
|
var getSdkHeaders = () => ({
|