@builder.io/sdk-solid 4.0.2 → 4.0.3
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/lib/browser/dev.js +19 -8
- package/lib/browser/dev.jsx +35 -21
- package/lib/browser/index.js +19 -6
- package/lib/browser/index.jsx +35 -19
- package/lib/edge/dev.js +19 -8
- package/lib/edge/dev.jsx +35 -21
- package/lib/edge/index.js +19 -6
- package/lib/edge/index.jsx +35 -19
- package/lib/node/dev.js +19 -8
- package/lib/node/dev.jsx +35 -21
- package/lib/node/index.js +19 -6
- package/lib/node/index.jsx +35 -19
- package/package.json +1 -1
package/lib/edge/dev.jsx
CHANGED
|
@@ -5099,7 +5099,7 @@ function SectionComponent(props) {
|
|
|
5099
5099
|
var section_default = SectionComponent;
|
|
5100
5100
|
|
|
5101
5101
|
// src/blocks/symbol/symbol.tsx
|
|
5102
|
-
import { onMount as onMount9, on as
|
|
5102
|
+
import { onMount as onMount9, on as on5, createEffect as createEffect5, createMemo as createMemo20, createSignal as createSignal20 } from "solid-js";
|
|
5103
5103
|
|
|
5104
5104
|
// src/components/content-variants/content-variants.tsx
|
|
5105
5105
|
import { Show as Show16, For as For9, onMount as onMount8, createSignal as createSignal19, createMemo as createMemo19 } from "solid-js";
|
|
@@ -6808,13 +6808,12 @@ var componentInfo12 = {
|
|
|
6808
6808
|
};
|
|
6809
6809
|
|
|
6810
6810
|
// src/blocks/custom-code/custom-code.tsx
|
|
6811
|
-
import { onMount as onMount5, createSignal as createSignal12 } from "solid-js";
|
|
6811
|
+
import { onMount as onMount5, on as on2, createEffect as createEffect2, createMemo as createMemo12, createSignal as createSignal12 } from "solid-js";
|
|
6812
6812
|
function CustomCode(props) {
|
|
6813
6813
|
const [scriptsInserted, setScriptsInserted] = createSignal12([]);
|
|
6814
6814
|
const [scriptsRun, setScriptsRun] = createSignal12([]);
|
|
6815
|
-
|
|
6816
|
-
|
|
6817
|
-
if (!elementRef?.getElementsByTagName || typeof window === "undefined") {
|
|
6815
|
+
function runScripts() {
|
|
6816
|
+
if (!elementRef || !elementRef?.getElementsByTagName || typeof window === "undefined") {
|
|
6818
6817
|
return;
|
|
6819
6818
|
}
|
|
6820
6819
|
const scripts = elementRef.getElementsByTagName("script");
|
|
@@ -6841,11 +6840,25 @@ function CustomCode(props) {
|
|
|
6841
6840
|
scriptsRun().push(script.innerText);
|
|
6842
6841
|
new Function(script.innerText)();
|
|
6843
6842
|
} catch (error) {
|
|
6844
|
-
|
|
6843
|
+
logger.warn(
|
|
6844
|
+
"[BUILDER.IO] `CustomCode`: Error running script:",
|
|
6845
|
+
error
|
|
6846
|
+
);
|
|
6845
6847
|
}
|
|
6846
6848
|
}
|
|
6847
6849
|
}
|
|
6850
|
+
}
|
|
6851
|
+
let elementRef;
|
|
6852
|
+
onMount5(() => {
|
|
6853
|
+
runScripts();
|
|
6848
6854
|
});
|
|
6855
|
+
const onUpdateFn_0_props_code = createMemo12(() => props.code);
|
|
6856
|
+
function onUpdateFn_0() {
|
|
6857
|
+
if (isEditing()) {
|
|
6858
|
+
runScripts();
|
|
6859
|
+
}
|
|
6860
|
+
}
|
|
6861
|
+
createEffect2(on2(() => [onUpdateFn_0_props_code()], onUpdateFn_0));
|
|
6849
6862
|
return <><div
|
|
6850
6863
|
class={"builder-custom-code" + (props.replaceNodes ? " replace-nodes" : "")}
|
|
6851
6864
|
ref={elementRef}
|
|
@@ -6873,7 +6886,7 @@ var componentInfo13 = {
|
|
|
6873
6886
|
};
|
|
6874
6887
|
|
|
6875
6888
|
// src/blocks/embed/embed.tsx
|
|
6876
|
-
import { on as
|
|
6889
|
+
import { on as on3, createEffect as createEffect3, createMemo as createMemo13, createSignal as createSignal13 } from "solid-js";
|
|
6877
6890
|
|
|
6878
6891
|
// src/blocks/embed/helpers.ts
|
|
6879
6892
|
var SCRIPT_MIME_TYPES = ["text/javascript", "application/javascript", "application/ecmascript"];
|
|
@@ -6901,7 +6914,7 @@ function Embed(props) {
|
|
|
6901
6914
|
scriptsRun().push(script.innerText);
|
|
6902
6915
|
new Function(script.innerText)();
|
|
6903
6916
|
} catch (error) {
|
|
6904
|
-
|
|
6917
|
+
logger.warn("[BUILDER.IO] `Embed`: Error running script:", error);
|
|
6905
6918
|
}
|
|
6906
6919
|
}
|
|
6907
6920
|
}
|
|
@@ -6915,8 +6928,8 @@ function Embed(props) {
|
|
|
6915
6928
|
findAndRunScripts();
|
|
6916
6929
|
}
|
|
6917
6930
|
}
|
|
6918
|
-
|
|
6919
|
-
|
|
6931
|
+
createEffect3(
|
|
6932
|
+
on3(() => [onUpdateFn_0_elem(), onUpdateFn_0_ranInitFn__()], onUpdateFn_0)
|
|
6920
6933
|
);
|
|
6921
6934
|
return <><div class="builder-embed" ref={elem} innerHTML={props.content} /></>;
|
|
6922
6935
|
}
|
|
@@ -7958,7 +7971,7 @@ function serializeIncludingFunctions(info) {
|
|
|
7958
7971
|
}
|
|
7959
7972
|
|
|
7960
7973
|
// src/components/content-variants/inlined-fns.ts
|
|
7961
|
-
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
|
|
7974
|
+
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}";
|
|
7962
7975
|
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}";
|
|
7963
7976
|
|
|
7964
7977
|
// src/components/content-variants/helpers.ts
|
|
@@ -7987,6 +8000,7 @@ var checkShouldRenderVariants2 = ({
|
|
|
7987
8000
|
return true;
|
|
7988
8001
|
};
|
|
7989
8002
|
var getIsHydrationTarget = (target) => target === "react" || target === "reactNative";
|
|
8003
|
+
var isAngularSDK = TARGET === "angular";
|
|
7990
8004
|
var isHydrationTarget = getIsHydrationTarget(TARGET);
|
|
7991
8005
|
var getInitVariantsFnsScriptString = () => `
|
|
7992
8006
|
window.${UPDATE_COOKIES_AND_STYLES_SCRIPT_NAME} = ${UPDATE_COOKIES_AND_STYLES_SCRIPT}
|
|
@@ -7994,7 +8008,7 @@ var getInitVariantsFnsScriptString = () => `
|
|
|
7994
8008
|
`;
|
|
7995
8009
|
var getUpdateCookieAndStylesScript = (variants, contentId) => `
|
|
7996
8010
|
window.${UPDATE_COOKIES_AND_STYLES_SCRIPT_NAME}(
|
|
7997
|
-
"${contentId}",${JSON.stringify(variants)}, ${isHydrationTarget}
|
|
8011
|
+
"${contentId}",${JSON.stringify(variants)}, ${isHydrationTarget}, ${isAngularSDK}
|
|
7998
8012
|
)`;
|
|
7999
8013
|
var getUpdateVariantVisibilityScript = ({
|
|
8000
8014
|
contentId,
|
|
@@ -8007,8 +8021,8 @@ var getUpdateVariantVisibilityScript = ({
|
|
|
8007
8021
|
import {
|
|
8008
8022
|
Show as Show14,
|
|
8009
8023
|
onMount as onMount7,
|
|
8010
|
-
on as
|
|
8011
|
-
createEffect as
|
|
8024
|
+
on as on4,
|
|
8025
|
+
createEffect as createEffect4,
|
|
8012
8026
|
createMemo as createMemo16,
|
|
8013
8027
|
createSignal as createSignal16
|
|
8014
8028
|
} from "solid-js";
|
|
@@ -8020,7 +8034,7 @@ function getPreviewContent(_searchParams) {
|
|
|
8020
8034
|
}
|
|
8021
8035
|
|
|
8022
8036
|
// src/constants/sdk-version.ts
|
|
8023
|
-
var SDK_VERSION = "4.0.
|
|
8037
|
+
var SDK_VERSION = "4.0.3";
|
|
8024
8038
|
|
|
8025
8039
|
// src/helpers/sdk-headers.ts
|
|
8026
8040
|
var getSdkHeaders = () => ({
|
|
@@ -9112,15 +9126,15 @@ function EnableEditor(props) {
|
|
|
9112
9126
|
mergeNewContent(props.content);
|
|
9113
9127
|
}
|
|
9114
9128
|
}
|
|
9115
|
-
|
|
9129
|
+
createEffect4(on4(() => [onUpdateFn_0_props_content()], onUpdateFn_0));
|
|
9116
9130
|
const onUpdateFn_1_props_builderContextSignal_rootState = createMemo16(
|
|
9117
9131
|
() => props.builderContextSignal.rootState
|
|
9118
9132
|
);
|
|
9119
9133
|
function onUpdateFn_1() {
|
|
9120
9134
|
emitStateUpdate();
|
|
9121
9135
|
}
|
|
9122
|
-
|
|
9123
|
-
|
|
9136
|
+
createEffect4(
|
|
9137
|
+
on4(
|
|
9124
9138
|
() => [onUpdateFn_1_props_builderContextSignal_rootState()],
|
|
9125
9139
|
onUpdateFn_1
|
|
9126
9140
|
)
|
|
@@ -9131,7 +9145,7 @@ function EnableEditor(props) {
|
|
|
9131
9145
|
mergeNewRootState(props.data);
|
|
9132
9146
|
}
|
|
9133
9147
|
}
|
|
9134
|
-
|
|
9148
|
+
createEffect4(on4(() => [onUpdateFn_2_props_data()], onUpdateFn_2));
|
|
9135
9149
|
const onUpdateFn_3_props_locale = createMemo16(() => props.locale);
|
|
9136
9150
|
function onUpdateFn_3() {
|
|
9137
9151
|
if (props.locale) {
|
|
@@ -9140,7 +9154,7 @@ function EnableEditor(props) {
|
|
|
9140
9154
|
});
|
|
9141
9155
|
}
|
|
9142
9156
|
}
|
|
9143
|
-
|
|
9157
|
+
createEffect4(on4(() => [onUpdateFn_3_props_locale()], onUpdateFn_3));
|
|
9144
9158
|
return <><builder_context_default.Provider value={props.builderContextSignal}><Show14
|
|
9145
9159
|
when={props.builderContextSignal.content || needsElementRefDivForEditing()}
|
|
9146
9160
|
><Dynamic5
|
|
@@ -9518,7 +9532,7 @@ function Symbol2(props) {
|
|
|
9518
9532
|
function onUpdateFn_0() {
|
|
9519
9533
|
setContent();
|
|
9520
9534
|
}
|
|
9521
|
-
|
|
9535
|
+
createEffect5(on5(() => [onUpdateFn_0_props_symbol()], onUpdateFn_0));
|
|
9522
9536
|
return <><div class={className()} {...{}} {...props.attributes} {...{}}><Content_variants_default
|
|
9523
9537
|
nonce={props.builderContext.nonce}
|
|
9524
9538
|
isNestedRender={true}
|
package/lib/edge/index.js
CHANGED
|
@@ -7171,9 +7171,8 @@ var _tmpl$13 = /* @__PURE__ */ template(`<div>`);
|
|
|
7171
7171
|
function CustomCode(props) {
|
|
7172
7172
|
const [scriptsInserted, setScriptsInserted] = createSignal([]);
|
|
7173
7173
|
const [scriptsRun, setScriptsRun] = createSignal([]);
|
|
7174
|
-
|
|
7175
|
-
|
|
7176
|
-
if (!elementRef?.getElementsByTagName || typeof window === "undefined") {
|
|
7174
|
+
function runScripts() {
|
|
7175
|
+
if (!elementRef || !elementRef?.getElementsByTagName || typeof window === "undefined") {
|
|
7177
7176
|
return;
|
|
7178
7177
|
}
|
|
7179
7178
|
const scripts = elementRef.getElementsByTagName("script");
|
|
@@ -7196,10 +7195,22 @@ function CustomCode(props) {
|
|
|
7196
7195
|
scriptsRun().push(script.innerText);
|
|
7197
7196
|
new Function(script.innerText)();
|
|
7198
7197
|
} catch (error) {
|
|
7198
|
+
logger.warn("[BUILDER.IO] `CustomCode`: Error running script:", error);
|
|
7199
7199
|
}
|
|
7200
7200
|
}
|
|
7201
7201
|
}
|
|
7202
|
+
}
|
|
7203
|
+
let elementRef;
|
|
7204
|
+
onMount(() => {
|
|
7205
|
+
runScripts();
|
|
7202
7206
|
});
|
|
7207
|
+
const onUpdateFn_0_props_code = createMemo(() => props.code);
|
|
7208
|
+
function onUpdateFn_0() {
|
|
7209
|
+
if (isEditing()) {
|
|
7210
|
+
runScripts();
|
|
7211
|
+
}
|
|
7212
|
+
}
|
|
7213
|
+
createEffect(on(() => [onUpdateFn_0_props_code()], onUpdateFn_0));
|
|
7203
7214
|
return (() => {
|
|
7204
7215
|
const _el$ = _tmpl$13();
|
|
7205
7216
|
const _ref$ = elementRef;
|
|
@@ -7263,6 +7274,7 @@ function Embed(props) {
|
|
|
7263
7274
|
scriptsRun().push(script.innerText);
|
|
7264
7275
|
new Function(script.innerText)();
|
|
7265
7276
|
} catch (error) {
|
|
7277
|
+
logger.warn("[BUILDER.IO] `Embed`: Error running script:", error);
|
|
7266
7278
|
}
|
|
7267
7279
|
}
|
|
7268
7280
|
}
|
|
@@ -8446,7 +8458,7 @@ function serializeIncludingFunctions(info) {
|
|
|
8446
8458
|
}
|
|
8447
8459
|
|
|
8448
8460
|
// src/components/content-variants/inlined-fns.ts
|
|
8449
|
-
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
|
|
8461
|
+
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}";
|
|
8450
8462
|
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}";
|
|
8451
8463
|
|
|
8452
8464
|
// src/components/content-variants/helpers.ts
|
|
@@ -8475,6 +8487,7 @@ var checkShouldRenderVariants2 = ({
|
|
|
8475
8487
|
return true;
|
|
8476
8488
|
};
|
|
8477
8489
|
var getIsHydrationTarget = (target) => target === "react" || target === "reactNative";
|
|
8490
|
+
var isAngularSDK = TARGET === "angular";
|
|
8478
8491
|
var isHydrationTarget = getIsHydrationTarget(TARGET);
|
|
8479
8492
|
var getInitVariantsFnsScriptString = () => `
|
|
8480
8493
|
window.${UPDATE_COOKIES_AND_STYLES_SCRIPT_NAME} = ${UPDATE_COOKIES_AND_STYLES_SCRIPT}
|
|
@@ -8482,7 +8495,7 @@ var getInitVariantsFnsScriptString = () => `
|
|
|
8482
8495
|
`;
|
|
8483
8496
|
var getUpdateCookieAndStylesScript = (variants, contentId) => `
|
|
8484
8497
|
window.${UPDATE_COOKIES_AND_STYLES_SCRIPT_NAME}(
|
|
8485
|
-
"${contentId}",${JSON.stringify(variants)}, ${isHydrationTarget}
|
|
8498
|
+
"${contentId}",${JSON.stringify(variants)}, ${isHydrationTarget}, ${isAngularSDK}
|
|
8486
8499
|
)`;
|
|
8487
8500
|
var getUpdateVariantVisibilityScript = ({
|
|
8488
8501
|
contentId,
|
|
@@ -8497,7 +8510,7 @@ function getPreviewContent(_searchParams) {
|
|
|
8497
8510
|
}
|
|
8498
8511
|
|
|
8499
8512
|
// src/constants/sdk-version.ts
|
|
8500
|
-
var SDK_VERSION = "4.0.
|
|
8513
|
+
var SDK_VERSION = "4.0.3";
|
|
8501
8514
|
|
|
8502
8515
|
// src/helpers/sdk-headers.ts
|
|
8503
8516
|
var getSdkHeaders = () => ({
|
package/lib/edge/index.jsx
CHANGED
|
@@ -5091,7 +5091,7 @@ function SectionComponent(props) {
|
|
|
5091
5091
|
var section_default = SectionComponent;
|
|
5092
5092
|
|
|
5093
5093
|
// src/blocks/symbol/symbol.tsx
|
|
5094
|
-
import { onMount as onMount9, on as
|
|
5094
|
+
import { onMount as onMount9, on as on5, createEffect as createEffect5, createMemo as createMemo20, createSignal as createSignal20 } from "solid-js";
|
|
5095
5095
|
|
|
5096
5096
|
// src/components/content-variants/content-variants.tsx
|
|
5097
5097
|
import { Show as Show16, For as For9, onMount as onMount8, createSignal as createSignal19, createMemo as createMemo19 } from "solid-js";
|
|
@@ -6799,13 +6799,12 @@ var componentInfo12 = {
|
|
|
6799
6799
|
};
|
|
6800
6800
|
|
|
6801
6801
|
// src/blocks/custom-code/custom-code.tsx
|
|
6802
|
-
import { onMount as onMount5, createSignal as createSignal12 } from "solid-js";
|
|
6802
|
+
import { onMount as onMount5, on as on2, createEffect as createEffect2, createMemo as createMemo12, createSignal as createSignal12 } from "solid-js";
|
|
6803
6803
|
function CustomCode(props) {
|
|
6804
6804
|
const [scriptsInserted, setScriptsInserted] = createSignal12([]);
|
|
6805
6805
|
const [scriptsRun, setScriptsRun] = createSignal12([]);
|
|
6806
|
-
|
|
6807
|
-
|
|
6808
|
-
if (!elementRef?.getElementsByTagName || typeof window === "undefined") {
|
|
6806
|
+
function runScripts() {
|
|
6807
|
+
if (!elementRef || !elementRef?.getElementsByTagName || typeof window === "undefined") {
|
|
6809
6808
|
return;
|
|
6810
6809
|
}
|
|
6811
6810
|
const scripts = elementRef.getElementsByTagName("script");
|
|
@@ -6832,10 +6831,25 @@ function CustomCode(props) {
|
|
|
6832
6831
|
scriptsRun().push(script.innerText);
|
|
6833
6832
|
new Function(script.innerText)();
|
|
6834
6833
|
} catch (error) {
|
|
6834
|
+
logger.warn(
|
|
6835
|
+
"[BUILDER.IO] `CustomCode`: Error running script:",
|
|
6836
|
+
error
|
|
6837
|
+
);
|
|
6835
6838
|
}
|
|
6836
6839
|
}
|
|
6837
6840
|
}
|
|
6841
|
+
}
|
|
6842
|
+
let elementRef;
|
|
6843
|
+
onMount5(() => {
|
|
6844
|
+
runScripts();
|
|
6838
6845
|
});
|
|
6846
|
+
const onUpdateFn_0_props_code = createMemo12(() => props.code);
|
|
6847
|
+
function onUpdateFn_0() {
|
|
6848
|
+
if (isEditing()) {
|
|
6849
|
+
runScripts();
|
|
6850
|
+
}
|
|
6851
|
+
}
|
|
6852
|
+
createEffect2(on2(() => [onUpdateFn_0_props_code()], onUpdateFn_0));
|
|
6839
6853
|
return <><div
|
|
6840
6854
|
class={"builder-custom-code" + (props.replaceNodes ? " replace-nodes" : "")}
|
|
6841
6855
|
ref={elementRef}
|
|
@@ -6863,7 +6877,7 @@ var componentInfo13 = {
|
|
|
6863
6877
|
};
|
|
6864
6878
|
|
|
6865
6879
|
// src/blocks/embed/embed.tsx
|
|
6866
|
-
import { on as
|
|
6880
|
+
import { on as on3, createEffect as createEffect3, createMemo as createMemo13, createSignal as createSignal13 } from "solid-js";
|
|
6867
6881
|
|
|
6868
6882
|
// src/blocks/embed/helpers.ts
|
|
6869
6883
|
var SCRIPT_MIME_TYPES = ["text/javascript", "application/javascript", "application/ecmascript"];
|
|
@@ -6891,6 +6905,7 @@ function Embed(props) {
|
|
|
6891
6905
|
scriptsRun().push(script.innerText);
|
|
6892
6906
|
new Function(script.innerText)();
|
|
6893
6907
|
} catch (error) {
|
|
6908
|
+
logger.warn("[BUILDER.IO] `Embed`: Error running script:", error);
|
|
6894
6909
|
}
|
|
6895
6910
|
}
|
|
6896
6911
|
}
|
|
@@ -6904,8 +6919,8 @@ function Embed(props) {
|
|
|
6904
6919
|
findAndRunScripts();
|
|
6905
6920
|
}
|
|
6906
6921
|
}
|
|
6907
|
-
|
|
6908
|
-
|
|
6922
|
+
createEffect3(
|
|
6923
|
+
on3(() => [onUpdateFn_0_elem(), onUpdateFn_0_ranInitFn__()], onUpdateFn_0)
|
|
6909
6924
|
);
|
|
6910
6925
|
return <><div class="builder-embed" ref={elem} innerHTML={props.content} /></>;
|
|
6911
6926
|
}
|
|
@@ -7946,7 +7961,7 @@ function serializeIncludingFunctions(info) {
|
|
|
7946
7961
|
}
|
|
7947
7962
|
|
|
7948
7963
|
// src/components/content-variants/inlined-fns.ts
|
|
7949
|
-
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
|
|
7964
|
+
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}";
|
|
7950
7965
|
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}";
|
|
7951
7966
|
|
|
7952
7967
|
// src/components/content-variants/helpers.ts
|
|
@@ -7975,6 +7990,7 @@ var checkShouldRenderVariants2 = ({
|
|
|
7975
7990
|
return true;
|
|
7976
7991
|
};
|
|
7977
7992
|
var getIsHydrationTarget = (target) => target === "react" || target === "reactNative";
|
|
7993
|
+
var isAngularSDK = TARGET === "angular";
|
|
7978
7994
|
var isHydrationTarget = getIsHydrationTarget(TARGET);
|
|
7979
7995
|
var getInitVariantsFnsScriptString = () => `
|
|
7980
7996
|
window.${UPDATE_COOKIES_AND_STYLES_SCRIPT_NAME} = ${UPDATE_COOKIES_AND_STYLES_SCRIPT}
|
|
@@ -7982,7 +7998,7 @@ var getInitVariantsFnsScriptString = () => `
|
|
|
7982
7998
|
`;
|
|
7983
7999
|
var getUpdateCookieAndStylesScript = (variants, contentId) => `
|
|
7984
8000
|
window.${UPDATE_COOKIES_AND_STYLES_SCRIPT_NAME}(
|
|
7985
|
-
"${contentId}",${JSON.stringify(variants)}, ${isHydrationTarget}
|
|
8001
|
+
"${contentId}",${JSON.stringify(variants)}, ${isHydrationTarget}, ${isAngularSDK}
|
|
7986
8002
|
)`;
|
|
7987
8003
|
var getUpdateVariantVisibilityScript = ({
|
|
7988
8004
|
contentId,
|
|
@@ -7995,8 +8011,8 @@ var getUpdateVariantVisibilityScript = ({
|
|
|
7995
8011
|
import {
|
|
7996
8012
|
Show as Show14,
|
|
7997
8013
|
onMount as onMount7,
|
|
7998
|
-
on as
|
|
7999
|
-
createEffect as
|
|
8014
|
+
on as on4,
|
|
8015
|
+
createEffect as createEffect4,
|
|
8000
8016
|
createMemo as createMemo16,
|
|
8001
8017
|
createSignal as createSignal16
|
|
8002
8018
|
} from "solid-js";
|
|
@@ -8008,7 +8024,7 @@ function getPreviewContent(_searchParams) {
|
|
|
8008
8024
|
}
|
|
8009
8025
|
|
|
8010
8026
|
// src/constants/sdk-version.ts
|
|
8011
|
-
var SDK_VERSION = "4.0.
|
|
8027
|
+
var SDK_VERSION = "4.0.3";
|
|
8012
8028
|
|
|
8013
8029
|
// src/helpers/sdk-headers.ts
|
|
8014
8030
|
var getSdkHeaders = () => ({
|
|
@@ -9093,15 +9109,15 @@ function EnableEditor(props) {
|
|
|
9093
9109
|
mergeNewContent(props.content);
|
|
9094
9110
|
}
|
|
9095
9111
|
}
|
|
9096
|
-
|
|
9112
|
+
createEffect4(on4(() => [onUpdateFn_0_props_content()], onUpdateFn_0));
|
|
9097
9113
|
const onUpdateFn_1_props_builderContextSignal_rootState = createMemo16(
|
|
9098
9114
|
() => props.builderContextSignal.rootState
|
|
9099
9115
|
);
|
|
9100
9116
|
function onUpdateFn_1() {
|
|
9101
9117
|
emitStateUpdate();
|
|
9102
9118
|
}
|
|
9103
|
-
|
|
9104
|
-
|
|
9119
|
+
createEffect4(
|
|
9120
|
+
on4(
|
|
9105
9121
|
() => [onUpdateFn_1_props_builderContextSignal_rootState()],
|
|
9106
9122
|
onUpdateFn_1
|
|
9107
9123
|
)
|
|
@@ -9112,7 +9128,7 @@ function EnableEditor(props) {
|
|
|
9112
9128
|
mergeNewRootState(props.data);
|
|
9113
9129
|
}
|
|
9114
9130
|
}
|
|
9115
|
-
|
|
9131
|
+
createEffect4(on4(() => [onUpdateFn_2_props_data()], onUpdateFn_2));
|
|
9116
9132
|
const onUpdateFn_3_props_locale = createMemo16(() => props.locale);
|
|
9117
9133
|
function onUpdateFn_3() {
|
|
9118
9134
|
if (props.locale) {
|
|
@@ -9121,7 +9137,7 @@ function EnableEditor(props) {
|
|
|
9121
9137
|
});
|
|
9122
9138
|
}
|
|
9123
9139
|
}
|
|
9124
|
-
|
|
9140
|
+
createEffect4(on4(() => [onUpdateFn_3_props_locale()], onUpdateFn_3));
|
|
9125
9141
|
return <><builder_context_default.Provider value={props.builderContextSignal}><Show14
|
|
9126
9142
|
when={props.builderContextSignal.content || needsElementRefDivForEditing()}
|
|
9127
9143
|
><Dynamic5
|
|
@@ -9499,7 +9515,7 @@ function Symbol2(props) {
|
|
|
9499
9515
|
function onUpdateFn_0() {
|
|
9500
9516
|
setContent();
|
|
9501
9517
|
}
|
|
9502
|
-
|
|
9518
|
+
createEffect5(on5(() => [onUpdateFn_0_props_symbol()], onUpdateFn_0));
|
|
9503
9519
|
return <><div class={className()} {...{}} {...props.attributes} {...{}}><Content_variants_default
|
|
9504
9520
|
nonce={props.builderContext.nonce}
|
|
9505
9521
|
isNestedRender={true}
|
package/lib/node/dev.js
CHANGED
|
@@ -4170,9 +4170,8 @@ var _tmpl$13 = /* @__PURE__ */ template(`<div>`);
|
|
|
4170
4170
|
function CustomCode(props) {
|
|
4171
4171
|
const [scriptsInserted, setScriptsInserted] = createSignal([]);
|
|
4172
4172
|
const [scriptsRun, setScriptsRun] = createSignal([]);
|
|
4173
|
-
|
|
4174
|
-
|
|
4175
|
-
if (!elementRef?.getElementsByTagName || typeof window === "undefined") {
|
|
4173
|
+
function runScripts() {
|
|
4174
|
+
if (!elementRef || !elementRef?.getElementsByTagName || typeof window === "undefined") {
|
|
4176
4175
|
return;
|
|
4177
4176
|
}
|
|
4178
4177
|
const scripts = elementRef.getElementsByTagName("script");
|
|
@@ -4195,11 +4194,22 @@ function CustomCode(props) {
|
|
|
4195
4194
|
scriptsRun().push(script.innerText);
|
|
4196
4195
|
new Function(script.innerText)();
|
|
4197
4196
|
} catch (error2) {
|
|
4198
|
-
|
|
4197
|
+
logger.warn("[BUILDER.IO] `CustomCode`: Error running script:", error2);
|
|
4199
4198
|
}
|
|
4200
4199
|
}
|
|
4201
4200
|
}
|
|
4201
|
+
}
|
|
4202
|
+
let elementRef;
|
|
4203
|
+
onMount(() => {
|
|
4204
|
+
runScripts();
|
|
4202
4205
|
});
|
|
4206
|
+
const onUpdateFn_0_props_code = createMemo(() => props.code);
|
|
4207
|
+
function onUpdateFn_0() {
|
|
4208
|
+
if (isEditing()) {
|
|
4209
|
+
runScripts();
|
|
4210
|
+
}
|
|
4211
|
+
}
|
|
4212
|
+
createEffect(on(() => [onUpdateFn_0_props_code()], onUpdateFn_0));
|
|
4203
4213
|
return (() => {
|
|
4204
4214
|
const _el$ = _tmpl$13();
|
|
4205
4215
|
const _ref$ = elementRef;
|
|
@@ -4263,7 +4273,7 @@ function Embed(props) {
|
|
|
4263
4273
|
scriptsRun().push(script.innerText);
|
|
4264
4274
|
new Function(script.innerText)();
|
|
4265
4275
|
} catch (error2) {
|
|
4266
|
-
|
|
4276
|
+
logger.warn("[BUILDER.IO] `Embed`: Error running script:", error2);
|
|
4267
4277
|
}
|
|
4268
4278
|
}
|
|
4269
4279
|
}
|
|
@@ -5448,7 +5458,7 @@ function serializeIncludingFunctions(info) {
|
|
|
5448
5458
|
}
|
|
5449
5459
|
|
|
5450
5460
|
// src/components/content-variants/inlined-fns.ts
|
|
5451
|
-
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
|
|
5461
|
+
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}";
|
|
5452
5462
|
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}";
|
|
5453
5463
|
|
|
5454
5464
|
// src/components/content-variants/helpers.ts
|
|
@@ -5477,6 +5487,7 @@ var checkShouldRenderVariants2 = ({
|
|
|
5477
5487
|
return true;
|
|
5478
5488
|
};
|
|
5479
5489
|
var getIsHydrationTarget = (target) => target === "react" || target === "reactNative";
|
|
5490
|
+
var isAngularSDK = TARGET === "angular";
|
|
5480
5491
|
var isHydrationTarget = getIsHydrationTarget(TARGET);
|
|
5481
5492
|
var getInitVariantsFnsScriptString = () => `
|
|
5482
5493
|
window.${UPDATE_COOKIES_AND_STYLES_SCRIPT_NAME} = ${UPDATE_COOKIES_AND_STYLES_SCRIPT}
|
|
@@ -5484,7 +5495,7 @@ var getInitVariantsFnsScriptString = () => `
|
|
|
5484
5495
|
`;
|
|
5485
5496
|
var getUpdateCookieAndStylesScript = (variants, contentId) => `
|
|
5486
5497
|
window.${UPDATE_COOKIES_AND_STYLES_SCRIPT_NAME}(
|
|
5487
|
-
"${contentId}",${JSON.stringify(variants)}, ${isHydrationTarget}
|
|
5498
|
+
"${contentId}",${JSON.stringify(variants)}, ${isHydrationTarget}, ${isAngularSDK}
|
|
5488
5499
|
)`;
|
|
5489
5500
|
var getUpdateVariantVisibilityScript = ({
|
|
5490
5501
|
contentId,
|
|
@@ -5499,7 +5510,7 @@ function getPreviewContent(_searchParams) {
|
|
|
5499
5510
|
}
|
|
5500
5511
|
|
|
5501
5512
|
// src/constants/sdk-version.ts
|
|
5502
|
-
var SDK_VERSION = "4.0.
|
|
5513
|
+
var SDK_VERSION = "4.0.3";
|
|
5503
5514
|
|
|
5504
5515
|
// src/helpers/sdk-headers.ts
|
|
5505
5516
|
var getSdkHeaders = () => ({
|