@builder.io/sdk-solid 4.0.7 → 4.0.9
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 +14 -2
- package/lib/browser/dev.js +369 -283
- package/lib/browser/dev.jsx +325 -282
- package/lib/browser/index.js +369 -283
- package/lib/browser/index.jsx +325 -282
- package/lib/edge/dev.js +369 -283
- package/lib/edge/dev.jsx +325 -282
- package/lib/edge/index.js +369 -283
- package/lib/edge/index.jsx +325 -282
- package/lib/node/dev.js +369 -283
- package/lib/node/dev.jsx +325 -282
- package/lib/node/index.js +369 -283
- package/lib/node/index.jsx +325 -282
- package/package.json +1 -1
package/lib/browser/index.jsx
CHANGED
|
@@ -1195,15 +1195,15 @@ var Block_wrapper_default = BlockWrapper;
|
|
|
1195
1195
|
import {
|
|
1196
1196
|
Show as Show4,
|
|
1197
1197
|
For,
|
|
1198
|
-
on,
|
|
1199
|
-
createEffect,
|
|
1198
|
+
on as on2,
|
|
1199
|
+
createEffect as createEffect2,
|
|
1200
1200
|
createMemo as createMemo3,
|
|
1201
1201
|
createSignal as createSignal3
|
|
1202
1202
|
} from "solid-js";
|
|
1203
1203
|
import { Dynamic as Dynamic3 } from "solid-js/web";
|
|
1204
1204
|
|
|
1205
1205
|
// src/components/block/components/interactive-element.tsx
|
|
1206
|
-
import { Show as Show3, createMemo as createMemo2 } from "solid-js";
|
|
1206
|
+
import { Show as Show3, on, createEffect, createMemo as createMemo2, createSignal as createSignal2 } from "solid-js";
|
|
1207
1207
|
import { Dynamic as Dynamic2 } from "solid-js/web";
|
|
1208
1208
|
|
|
1209
1209
|
// src/components/awaiter.tsx
|
|
@@ -1217,6 +1217,7 @@ var Awaiter_default = Awaiter;
|
|
|
1217
1217
|
|
|
1218
1218
|
// src/components/block/components/interactive-element.tsx
|
|
1219
1219
|
function InteractiveElement(props) {
|
|
1220
|
+
const [forceRenderCount, setForceRenderCount] = createSignal2(0);
|
|
1220
1221
|
const attributes = createMemo2(() => {
|
|
1221
1222
|
return props.includeBlockProps ? {
|
|
1222
1223
|
...getBlockProperties({
|
|
@@ -1235,6 +1236,21 @@ function InteractiveElement(props) {
|
|
|
1235
1236
|
const targetWrapperProps = createMemo2(() => {
|
|
1236
1237
|
return props.wrapperProps;
|
|
1237
1238
|
});
|
|
1239
|
+
const onUpdateFn_0_props_wrapperProps = createMemo2(() => props.wrapperProps);
|
|
1240
|
+
const onUpdateFn_0_props_block__component__options = createMemo2(
|
|
1241
|
+
() => props.block?.component?.options
|
|
1242
|
+
);
|
|
1243
|
+
function onUpdateFn_0() {
|
|
1244
|
+
}
|
|
1245
|
+
createEffect(
|
|
1246
|
+
on(
|
|
1247
|
+
() => [
|
|
1248
|
+
onUpdateFn_0_props_wrapperProps(),
|
|
1249
|
+
onUpdateFn_0_props_block__component__options()
|
|
1250
|
+
],
|
|
1251
|
+
onUpdateFn_0
|
|
1252
|
+
)
|
|
1253
|
+
);
|
|
1238
1254
|
return <><Show3
|
|
1239
1255
|
fallback={<Dynamic2
|
|
1240
1256
|
{...targetWrapperProps()}
|
|
@@ -1298,8 +1314,8 @@ function ComponentRef(props) {
|
|
|
1298
1314
|
);
|
|
1299
1315
|
function onUpdateFn_0() {
|
|
1300
1316
|
}
|
|
1301
|
-
|
|
1302
|
-
|
|
1317
|
+
createEffect2(
|
|
1318
|
+
on2(
|
|
1303
1319
|
() => [
|
|
1304
1320
|
onUpdateFn_0_props_componentOptions(),
|
|
1305
1321
|
onUpdateFn_0_props_blockChildren()
|
|
@@ -1333,7 +1349,7 @@ function ComponentRef(props) {
|
|
|
1333
1349
|
var Component_ref_default = ComponentRef;
|
|
1334
1350
|
|
|
1335
1351
|
// src/components/block/components/repeated-block.tsx
|
|
1336
|
-
import { on as
|
|
1352
|
+
import { on as on3, createEffect as createEffect3, createMemo as createMemo4, createSignal as createSignal4 } from "solid-js";
|
|
1337
1353
|
function RepeatedBlock(props) {
|
|
1338
1354
|
const [store, setStore] = createSignal4(props.repeatContext);
|
|
1339
1355
|
const onUpdateFn_0_props_repeatContext = createMemo4(
|
|
@@ -1342,7 +1358,7 @@ function RepeatedBlock(props) {
|
|
|
1342
1358
|
function onUpdateFn_0() {
|
|
1343
1359
|
setStore(props.repeatContext);
|
|
1344
1360
|
}
|
|
1345
|
-
|
|
1361
|
+
createEffect3(on3(() => [onUpdateFn_0_props_repeatContext()], onUpdateFn_0));
|
|
1346
1362
|
return <><builder_context_default.Provider value={store()}><Block_default
|
|
1347
1363
|
block={props.block}
|
|
1348
1364
|
context={store()}
|
|
@@ -1511,7 +1527,7 @@ function Block(props) {
|
|
|
1511
1527
|
var Block_default = Block;
|
|
1512
1528
|
|
|
1513
1529
|
// src/components/blocks/blocks-wrapper.tsx
|
|
1514
|
-
import { onMount as onMount3, on as
|
|
1530
|
+
import { onMount as onMount3, on as on5, createEffect as createEffect5, createMemo as createMemo6, createSignal as createSignal6 } from "solid-js";
|
|
1515
1531
|
import { Dynamic as Dynamic4 } from "solid-js/web";
|
|
1516
1532
|
function BlocksWrapper(props) {
|
|
1517
1533
|
const [shouldUpdate, setShouldUpdate] = createSignal6(false);
|
|
@@ -1564,10 +1580,10 @@ function BlocksWrapper(props) {
|
|
|
1564
1580
|
const onUpdateFn_0_props_blocks = createMemo6(() => props.blocks);
|
|
1565
1581
|
function onUpdateFn_0() {
|
|
1566
1582
|
}
|
|
1567
|
-
|
|
1583
|
+
createEffect5(on5(() => [onUpdateFn_0_props_blocks()], onUpdateFn_0));
|
|
1568
1584
|
return <>
|
|
1569
1585
|
<Dynamic4
|
|
1570
|
-
class={className() + " dynamic-
|
|
1586
|
+
class={className() + " dynamic-450facf4"}
|
|
1571
1587
|
ref={blocksWrapperRef}
|
|
1572
1588
|
builder-path={dataPath()}
|
|
1573
1589
|
builder-parent-id={props.parent}
|
|
@@ -1579,7 +1595,7 @@ function BlocksWrapper(props) {
|
|
|
1579
1595
|
{...props.BlocksWrapperProps}
|
|
1580
1596
|
component={props.BlocksWrapper}
|
|
1581
1597
|
>{props.children}</Dynamic4>
|
|
1582
|
-
<style>{`.dynamic-
|
|
1598
|
+
<style>{`.dynamic-450facf4 {
|
|
1583
1599
|
display: flex;
|
|
1584
1600
|
flex-direction: column;
|
|
1585
1601
|
align-items: stretch;
|
|
@@ -1597,19 +1613,22 @@ function Blocks(props) {
|
|
|
1597
1613
|
parent={props.parent}
|
|
1598
1614
|
path={props.path}
|
|
1599
1615
|
styleProp={props.styleProp}
|
|
1616
|
+
BlocksWrapperProps={props.BlocksWrapperProps || props.context?.BlocksWrapperProps || builderContext?.BlocksWrapperProps}
|
|
1600
1617
|
classNameProp={props.className}
|
|
1601
1618
|
BlocksWrapper={props.context?.BlocksWrapper || builderContext?.BlocksWrapper}
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
1619
|
+
>
|
|
1620
|
+
{props.children}
|
|
1621
|
+
<Show6 when={props.blocks}><For3 each={props.blocks}>{(block, _index) => {
|
|
1622
|
+
const index = _index();
|
|
1623
|
+
return <Block_default
|
|
1624
|
+
key={block.id}
|
|
1625
|
+
block={block}
|
|
1626
|
+
linkComponent={props.linkComponent}
|
|
1627
|
+
context={props.context || builderContext}
|
|
1628
|
+
registeredComponents={props.registeredComponents || componentsContext?.registeredComponents}
|
|
1629
|
+
/>;
|
|
1630
|
+
}}</For3></Show6>
|
|
1631
|
+
</Blocks_wrapper_default></>;
|
|
1613
1632
|
}
|
|
1614
1633
|
var Blocks_default = Blocks;
|
|
1615
1634
|
|
|
@@ -1955,11 +1974,171 @@ function SectionComponent(props) {
|
|
|
1955
1974
|
var section_default = SectionComponent;
|
|
1956
1975
|
|
|
1957
1976
|
// src/blocks/symbol/symbol.tsx
|
|
1958
|
-
import { onMount as onMount10, on as
|
|
1977
|
+
import { onMount as onMount10, on as on9, createEffect as createEffect9, createMemo as createMemo20, createSignal as createSignal20 } from "solid-js";
|
|
1959
1978
|
|
|
1960
1979
|
// src/components/content-variants/content-variants.tsx
|
|
1961
1980
|
import { Show as Show16, For as For9, onMount as onMount9, createSignal as createSignal19, createMemo as createMemo19 } from "solid-js";
|
|
1962
1981
|
|
|
1982
|
+
// src/blocks/personalization-container/helpers/inlined-fns.ts
|
|
1983
|
+
function filterWithCustomTargeting(userAttributes, query, startDate, endDate) {
|
|
1984
|
+
function isString(val) {
|
|
1985
|
+
return typeof val === "string";
|
|
1986
|
+
}
|
|
1987
|
+
function isNumber(val) {
|
|
1988
|
+
return typeof val === "number";
|
|
1989
|
+
}
|
|
1990
|
+
function objectMatchesQuery(userattr, query2) {
|
|
1991
|
+
const result = (() => {
|
|
1992
|
+
const property = query2.property;
|
|
1993
|
+
const operator = query2.operator;
|
|
1994
|
+
let testValue = query2.value;
|
|
1995
|
+
if (query2 && query2.property === "urlPath" && query2.value && typeof query2.value === "string" && query2.value !== "/" && query2.value.endsWith("/")) {
|
|
1996
|
+
testValue = query2.value.slice(0, -1);
|
|
1997
|
+
}
|
|
1998
|
+
if (!(property && operator)) {
|
|
1999
|
+
return true;
|
|
2000
|
+
}
|
|
2001
|
+
if (Array.isArray(testValue)) {
|
|
2002
|
+
if (operator === "isNot") {
|
|
2003
|
+
return testValue.every((val) => objectMatchesQuery(userattr, {
|
|
2004
|
+
property,
|
|
2005
|
+
operator,
|
|
2006
|
+
value: val
|
|
2007
|
+
}));
|
|
2008
|
+
}
|
|
2009
|
+
return !!testValue.find((val) => objectMatchesQuery(userattr, {
|
|
2010
|
+
property,
|
|
2011
|
+
operator,
|
|
2012
|
+
value: val
|
|
2013
|
+
}));
|
|
2014
|
+
}
|
|
2015
|
+
const value = userattr[property];
|
|
2016
|
+
if (Array.isArray(value)) {
|
|
2017
|
+
return value.includes(testValue);
|
|
2018
|
+
}
|
|
2019
|
+
switch (operator) {
|
|
2020
|
+
case "is":
|
|
2021
|
+
return value === testValue;
|
|
2022
|
+
case "isNot":
|
|
2023
|
+
return value !== testValue;
|
|
2024
|
+
case "contains":
|
|
2025
|
+
return (isString(value) || Array.isArray(value)) && value.includes(String(testValue));
|
|
2026
|
+
case "startsWith":
|
|
2027
|
+
return isString(value) && value.startsWith(String(testValue));
|
|
2028
|
+
case "endsWith":
|
|
2029
|
+
return isString(value) && value.endsWith(String(testValue));
|
|
2030
|
+
case "greaterThan":
|
|
2031
|
+
return isNumber(value) && isNumber(testValue) && value > testValue;
|
|
2032
|
+
case "lessThan":
|
|
2033
|
+
return isNumber(value) && isNumber(testValue) && value < testValue;
|
|
2034
|
+
case "greaterThanOrEqualTo":
|
|
2035
|
+
return isNumber(value) && isNumber(testValue) && value >= testValue;
|
|
2036
|
+
case "lessThanOrEqualTo":
|
|
2037
|
+
return isNumber(value) && isNumber(testValue) && value <= testValue;
|
|
2038
|
+
default:
|
|
2039
|
+
return false;
|
|
2040
|
+
}
|
|
2041
|
+
})();
|
|
2042
|
+
return result;
|
|
2043
|
+
}
|
|
2044
|
+
const item = {
|
|
2045
|
+
query,
|
|
2046
|
+
startDate,
|
|
2047
|
+
endDate
|
|
2048
|
+
};
|
|
2049
|
+
const now = userAttributes.date && new Date(userAttributes.date) || /* @__PURE__ */ new Date();
|
|
2050
|
+
if (item.startDate && new Date(item.startDate) > now) {
|
|
2051
|
+
return false;
|
|
2052
|
+
} else if (item.endDate && new Date(item.endDate) < now) {
|
|
2053
|
+
return false;
|
|
2054
|
+
}
|
|
2055
|
+
if (!item.query || !item.query.length) {
|
|
2056
|
+
return true;
|
|
2057
|
+
}
|
|
2058
|
+
return item.query.every((filter) => {
|
|
2059
|
+
return objectMatchesQuery(userAttributes, filter);
|
|
2060
|
+
});
|
|
2061
|
+
}
|
|
2062
|
+
var PERSONALIZATION_SCRIPT = "function getPersonalizedVariant(variants, blockId, isHydrationTarget, locale) {\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 attributes = JSON.parse(getCookie('builder.userAttributes') || '{}');\n if (locale) {\n attributes.locale = locale;\n }\n const winningVariantIndex = variants?.findIndex(function (variant) {\n return window.filterWithCustomTargeting(attributes, variant.query, variant.startDate, variant.endDate);\n });\n const parentDiv = document.currentScript?.parentElement;\n const variantId = parentDiv?.getAttribute('data-variant-id');\n const isDefaultVariant = variantId === `${blockId}-default`;\n const isWinningVariant = winningVariantIndex !== -1 && variantId === `${blockId}-${winningVariantIndex}` || winningVariantIndex === -1 && isDefaultVariant;\n if (isWinningVariant && !isDefaultVariant) {\n parentDiv?.removeAttribute('hidden');\n parentDiv?.removeAttribute('aria-hidden');\n } else if (!isWinningVariant && isDefaultVariant) {\n parentDiv?.setAttribute('hidden', 'true');\n parentDiv?.setAttribute('aria-hidden', 'true');\n }\n if (isHydrationTarget) {\n if (!isWinningVariant) {\n const itsStyleEl = parentDiv?.previousElementSibling;\n if (itsStyleEl) {\n itsStyleEl.remove();\n }\n parentDiv?.remove();\n }\n const thisScript = document.currentScript;\n if (thisScript) {\n thisScript.remove();\n }\n }\n}";
|
|
2063
|
+
var FILTER_WITH_CUSTOM_TARGETING_SCRIPT = "function filterWithCustomTargeting(userAttributes, query, startDate, endDate) {\n function isString(val) {\n return typeof val === 'string';\n }\n function isNumber(val) {\n return typeof val === 'number';\n }\n function objectMatchesQuery(userattr, query) {\n const result = (() => {\n const property = query.property;\n const operator = query.operator;\n let testValue = query.value;\n if (query && query.property === 'urlPath' && query.value && typeof query.value === 'string' && query.value !== '/' && query.value.endsWith('/')) {\n testValue = query.value.slice(0, -1);\n }\n if (!(property && operator)) {\n return true;\n }\n if (Array.isArray(testValue)) {\n if (operator === 'isNot') {\n return testValue.every(val => objectMatchesQuery(userattr, {\n property,\n operator,\n value: val\n }));\n }\n return !!testValue.find(val => objectMatchesQuery(userattr, {\n property,\n operator,\n value: val\n }));\n }\n const value = userattr[property];\n if (Array.isArray(value)) {\n return value.includes(testValue);\n }\n switch (operator) {\n case 'is':\n return value === testValue;\n case 'isNot':\n return value !== testValue;\n case 'contains':\n return (isString(value) || Array.isArray(value)) && value.includes(String(testValue));\n case 'startsWith':\n return isString(value) && value.startsWith(String(testValue));\n case 'endsWith':\n return isString(value) && value.endsWith(String(testValue));\n case 'greaterThan':\n return isNumber(value) && isNumber(testValue) && value > testValue;\n case 'lessThan':\n return isNumber(value) && isNumber(testValue) && value < testValue;\n case 'greaterThanOrEqualTo':\n return isNumber(value) && isNumber(testValue) && value >= testValue;\n case 'lessThanOrEqualTo':\n return isNumber(value) && isNumber(testValue) && value <= testValue;\n default:\n return false;\n }\n })();\n return result;\n }\n const item = {\n query,\n startDate,\n endDate\n };\n const now = userAttributes.date && new Date(userAttributes.date) || new Date();\n if (item.startDate && new Date(item.startDate) > now) {\n return false;\n } else if (item.endDate && new Date(item.endDate) < now) {\n return false;\n }\n if (!item.query || !item.query.length) {\n return true;\n }\n return item.query.every(filter => {\n return objectMatchesQuery(userAttributes, filter);\n });\n}";
|
|
2064
|
+
var UPDATE_VISIBILITY_STYLES_SCRIPT = "function updateVisibilityStylesScript(variants, blockId, isHydrationTarget, locale) {\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 visibilityStylesEl = document.currentScript?.previousElementSibling;\n if (!visibilityStylesEl) {\n return;\n }\n if (isHydrationTarget) {\n visibilityStylesEl.remove();\n const currentScript = document.currentScript;\n if (currentScript) {\n currentScript.remove();\n }\n } else {\n const attributes = JSON.parse(getCookie('builder.userAttributes') || '{}');\n if (locale) {\n attributes.locale = locale;\n }\n const winningVariantIndex = variants?.findIndex(function (variant) {\n return window.filterWithCustomTargeting(attributes, variant.query, variant.startDate, variant.endDate);\n });\n if (winningVariantIndex !== -1) {\n let newStyleStr = variants?.map((_, index) => {\n if (index === winningVariantIndex) return '';\n return `div[data-variant-id=\"${blockId}-${index}\"] { display: none !important; } `;\n }).join('') || '';\n newStyleStr += `div[data-variant-id=\"${blockId}-default\"] { display: none !important; } `;\n visibilityStylesEl.innerHTML = newStyleStr;\n }\n }\n}";
|
|
2065
|
+
|
|
2066
|
+
// src/blocks/personalization-container/helpers.ts
|
|
2067
|
+
var DEFAULT_INDEX = "default";
|
|
2068
|
+
var FILTER_WITH_CUSTOM_TARGETING_SCRIPT_FN_NAME = "filterWithCustomTargeting";
|
|
2069
|
+
var BUILDER_IO_PERSONALIZATION_SCRIPT_FN_NAME = "builderIoPersonalization";
|
|
2070
|
+
var UPDATE_VARIANT_VISIBILITY_SCRIPT_FN_NAME = "updateVisibilityStylesScript";
|
|
2071
|
+
var SDKS_SUPPORTING_PERSONALIZATION = ["react", "vue", "svelte"];
|
|
2072
|
+
var SDKS_REQUIRING_RESET_APPROACH = ["vue", "svelte"];
|
|
2073
|
+
function checkShouldRenderVariants(variants, canTrack) {
|
|
2074
|
+
const hasVariants = variants && variants.length > 0;
|
|
2075
|
+
if (TARGET === "reactNative")
|
|
2076
|
+
return false;
|
|
2077
|
+
if (!hasVariants)
|
|
2078
|
+
return false;
|
|
2079
|
+
if (!canTrack)
|
|
2080
|
+
return false;
|
|
2081
|
+
if (SDKS_REQUIRING_RESET_APPROACH.includes(TARGET))
|
|
2082
|
+
return true;
|
|
2083
|
+
if (isBrowser())
|
|
2084
|
+
return false;
|
|
2085
|
+
return true;
|
|
2086
|
+
}
|
|
2087
|
+
function getBlocksToRender({
|
|
2088
|
+
variants,
|
|
2089
|
+
previewingIndex,
|
|
2090
|
+
isHydrated,
|
|
2091
|
+
filteredVariants,
|
|
2092
|
+
fallbackBlocks
|
|
2093
|
+
}) {
|
|
2094
|
+
const fallback = {
|
|
2095
|
+
blocks: fallbackBlocks ?? [],
|
|
2096
|
+
path: "this.children",
|
|
2097
|
+
index: DEFAULT_INDEX
|
|
2098
|
+
};
|
|
2099
|
+
if (isHydrated && isEditing()) {
|
|
2100
|
+
if (typeof previewingIndex === "number" && previewingIndex < (variants?.length ?? 0)) {
|
|
2101
|
+
const variant = variants?.[previewingIndex];
|
|
2102
|
+
if (variant) {
|
|
2103
|
+
return {
|
|
2104
|
+
blocks: variant.blocks,
|
|
2105
|
+
path: `variants.${previewingIndex}.blocks`,
|
|
2106
|
+
index: previewingIndex
|
|
2107
|
+
};
|
|
2108
|
+
}
|
|
2109
|
+
}
|
|
2110
|
+
return fallback;
|
|
2111
|
+
}
|
|
2112
|
+
if (isBrowser()) {
|
|
2113
|
+
const winningVariant = filteredVariants?.[0];
|
|
2114
|
+
if (winningVariant && variants) {
|
|
2115
|
+
const variantIndex = variants.indexOf(winningVariant);
|
|
2116
|
+
if (variantIndex !== -1) {
|
|
2117
|
+
return {
|
|
2118
|
+
blocks: winningVariant.blocks,
|
|
2119
|
+
path: `variants.${variantIndex}.blocks`,
|
|
2120
|
+
index: variantIndex
|
|
2121
|
+
};
|
|
2122
|
+
}
|
|
2123
|
+
}
|
|
2124
|
+
}
|
|
2125
|
+
return fallback;
|
|
2126
|
+
}
|
|
2127
|
+
var getInitPersonalizationVariantsFnsScriptString = () => {
|
|
2128
|
+
return `
|
|
2129
|
+
window.${FILTER_WITH_CUSTOM_TARGETING_SCRIPT_FN_NAME} = ${FILTER_WITH_CUSTOM_TARGETING_SCRIPT}
|
|
2130
|
+
window.${BUILDER_IO_PERSONALIZATION_SCRIPT_FN_NAME} = ${PERSONALIZATION_SCRIPT}
|
|
2131
|
+
window.${UPDATE_VARIANT_VISIBILITY_SCRIPT_FN_NAME} = ${UPDATE_VISIBILITY_STYLES_SCRIPT}
|
|
2132
|
+
`;
|
|
2133
|
+
};
|
|
2134
|
+
var isHydrationTarget = TARGET === "react";
|
|
2135
|
+
var getPersonalizationScript = (variants, blockId, locale) => {
|
|
2136
|
+
return `window.${BUILDER_IO_PERSONALIZATION_SCRIPT_FN_NAME}(${JSON.stringify(variants)}, "${blockId}", ${isHydrationTarget}${locale ? `, "${locale}"` : ""})`;
|
|
2137
|
+
};
|
|
2138
|
+
var getUpdateVisibilityStylesScript = (variants, blockId, locale) => {
|
|
2139
|
+
return `window.${UPDATE_VARIANT_VISIBILITY_SCRIPT_FN_NAME}(${JSON.stringify(variants)}, "${blockId}", ${isHydrationTarget}${locale ? `, "${locale}"` : ""})`;
|
|
2140
|
+
};
|
|
2141
|
+
|
|
1963
2142
|
// src/helpers/url.ts
|
|
1964
2143
|
var getTopLevelDomain = (host) => {
|
|
1965
2144
|
if (host === "localhost" || host === "127.0.0.1") {
|
|
@@ -2905,7 +3084,8 @@ var componentInfo6 = {
|
|
|
2905
3084
|
name: "PersonalizationContainer",
|
|
2906
3085
|
shouldReceiveBuilderProps: {
|
|
2907
3086
|
builderBlock: true,
|
|
2908
|
-
builderContext: true
|
|
3087
|
+
builderContext: true,
|
|
3088
|
+
builderComponents: true
|
|
2909
3089
|
},
|
|
2910
3090
|
noWrap: true,
|
|
2911
3091
|
image: "https://cdn.builder.io/api/v1/image/assets%2FYJIGb4i01jvw0SRdL5Bt%2F37229ed30d8c41dfb10b8cca1992053a",
|
|
@@ -2961,199 +3141,6 @@ function isPreviewing(_search) {
|
|
|
2961
3141
|
return Boolean(normalizedSearch.indexOf("builder.preview=") !== -1);
|
|
2962
3142
|
}
|
|
2963
3143
|
|
|
2964
|
-
// src/blocks/personalization-container/helpers/inlined-fns.ts
|
|
2965
|
-
function filterWithCustomTargeting(userAttributes, query, startDate, endDate) {
|
|
2966
|
-
function isString(val) {
|
|
2967
|
-
return typeof val === "string";
|
|
2968
|
-
}
|
|
2969
|
-
function isNumber(val) {
|
|
2970
|
-
return typeof val === "number";
|
|
2971
|
-
}
|
|
2972
|
-
function objectMatchesQuery(userattr, query2) {
|
|
2973
|
-
const result = (() => {
|
|
2974
|
-
const property = query2.property;
|
|
2975
|
-
const operator = query2.operator;
|
|
2976
|
-
let testValue = query2.value;
|
|
2977
|
-
if (query2 && query2.property === "urlPath" && query2.value && typeof query2.value === "string" && query2.value !== "/" && query2.value.endsWith("/")) {
|
|
2978
|
-
testValue = query2.value.slice(0, -1);
|
|
2979
|
-
}
|
|
2980
|
-
if (!(property && operator)) {
|
|
2981
|
-
return true;
|
|
2982
|
-
}
|
|
2983
|
-
if (Array.isArray(testValue)) {
|
|
2984
|
-
if (operator === "isNot") {
|
|
2985
|
-
return testValue.every((val) => objectMatchesQuery(userattr, {
|
|
2986
|
-
property,
|
|
2987
|
-
operator,
|
|
2988
|
-
value: val
|
|
2989
|
-
}));
|
|
2990
|
-
}
|
|
2991
|
-
return !!testValue.find((val) => objectMatchesQuery(userattr, {
|
|
2992
|
-
property,
|
|
2993
|
-
operator,
|
|
2994
|
-
value: val
|
|
2995
|
-
}));
|
|
2996
|
-
}
|
|
2997
|
-
const value = userattr[property];
|
|
2998
|
-
if (Array.isArray(value)) {
|
|
2999
|
-
return value.includes(testValue);
|
|
3000
|
-
}
|
|
3001
|
-
switch (operator) {
|
|
3002
|
-
case "is":
|
|
3003
|
-
return value === testValue;
|
|
3004
|
-
case "isNot":
|
|
3005
|
-
return value !== testValue;
|
|
3006
|
-
case "contains":
|
|
3007
|
-
return (isString(value) || Array.isArray(value)) && value.includes(String(testValue));
|
|
3008
|
-
case "startsWith":
|
|
3009
|
-
return isString(value) && value.startsWith(String(testValue));
|
|
3010
|
-
case "endsWith":
|
|
3011
|
-
return isString(value) && value.endsWith(String(testValue));
|
|
3012
|
-
case "greaterThan":
|
|
3013
|
-
return isNumber(value) && isNumber(testValue) && value > testValue;
|
|
3014
|
-
case "lessThan":
|
|
3015
|
-
return isNumber(value) && isNumber(testValue) && value < testValue;
|
|
3016
|
-
case "greaterThanOrEqualTo":
|
|
3017
|
-
return isNumber(value) && isNumber(testValue) && value >= testValue;
|
|
3018
|
-
case "lessThanOrEqualTo":
|
|
3019
|
-
return isNumber(value) && isNumber(testValue) && value <= testValue;
|
|
3020
|
-
default:
|
|
3021
|
-
return false;
|
|
3022
|
-
}
|
|
3023
|
-
})();
|
|
3024
|
-
return result;
|
|
3025
|
-
}
|
|
3026
|
-
const item = {
|
|
3027
|
-
query,
|
|
3028
|
-
startDate,
|
|
3029
|
-
endDate
|
|
3030
|
-
};
|
|
3031
|
-
const now = userAttributes.date && new Date(userAttributes.date) || /* @__PURE__ */ new Date();
|
|
3032
|
-
if (item.startDate && new Date(item.startDate) > now) {
|
|
3033
|
-
return false;
|
|
3034
|
-
} else if (item.endDate && new Date(item.endDate) < now) {
|
|
3035
|
-
return false;
|
|
3036
|
-
}
|
|
3037
|
-
if (!item.query || !item.query.length) {
|
|
3038
|
-
return true;
|
|
3039
|
-
}
|
|
3040
|
-
return item.query.every((filter) => {
|
|
3041
|
-
return objectMatchesQuery(userAttributes, filter);
|
|
3042
|
-
});
|
|
3043
|
-
}
|
|
3044
|
-
var PERSONALIZATION_SCRIPT = `function getPersonalizedVariant(variants, blockId, locale) {
|
|
3045
|
-
if (!navigator.cookieEnabled) {
|
|
3046
|
-
return;
|
|
3047
|
-
}
|
|
3048
|
-
function getCookie(name) {
|
|
3049
|
-
const nameEQ = name + '=';
|
|
3050
|
-
const ca = document.cookie.split(';');
|
|
3051
|
-
for (let i = 0; i < ca.length; i++) {
|
|
3052
|
-
let c = ca[i];
|
|
3053
|
-
while (c.charAt(0) == ' ') c = c.substring(1, c.length);
|
|
3054
|
-
if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length);
|
|
3055
|
-
}
|
|
3056
|
-
return null;
|
|
3057
|
-
}
|
|
3058
|
-
function removeVariants() {
|
|
3059
|
-
variants?.forEach(function (_, index) {
|
|
3060
|
-
document.querySelector('template[data-variant-id="' + blockId + '-' + index + '"]')?.remove();
|
|
3061
|
-
});
|
|
3062
|
-
document.querySelector('script[data-id="variants-script-' + blockId + '"]')?.remove();
|
|
3063
|
-
document.querySelector('style[data-id="variants-styles-' + blockId + '"]')?.remove();
|
|
3064
|
-
}
|
|
3065
|
-
const attributes = JSON.parse(getCookie('builder.userAttributes') || '{}');
|
|
3066
|
-
if (locale) {
|
|
3067
|
-
attributes.locale = locale;
|
|
3068
|
-
}
|
|
3069
|
-
const winningVariantIndex = variants?.findIndex(function (variant) {
|
|
3070
|
-
return filterWithCustomTargeting(attributes, variant.query, variant.startDate, variant.endDate);
|
|
3071
|
-
});
|
|
3072
|
-
const isDebug = location.href.includes('builder.debug=true');
|
|
3073
|
-
if (isDebug) {
|
|
3074
|
-
console.debug('PersonalizationContainer', {
|
|
3075
|
-
attributes,
|
|
3076
|
-
variants,
|
|
3077
|
-
winningVariantIndex
|
|
3078
|
-
});
|
|
3079
|
-
}
|
|
3080
|
-
if (winningVariantIndex !== -1) {
|
|
3081
|
-
const winningVariant = document.querySelector('template[data-variant-id="' + blockId + '-' + winningVariantIndex + '"]');
|
|
3082
|
-
if (winningVariant) {
|
|
3083
|
-
const parentNode = winningVariant.parentNode;
|
|
3084
|
-
if (parentNode) {
|
|
3085
|
-
const newParent = parentNode.cloneNode(false);
|
|
3086
|
-
newParent.appendChild(winningVariant.content.firstChild);
|
|
3087
|
-
newParent.appendChild(winningVariant.content.lastChild);
|
|
3088
|
-
parentNode.parentNode?.replaceChild(newParent, parentNode);
|
|
3089
|
-
}
|
|
3090
|
-
if (isDebug) {
|
|
3091
|
-
console.debug('PersonalizationContainer', 'Winning variant Replaced:', winningVariant);
|
|
3092
|
-
}
|
|
3093
|
-
}
|
|
3094
|
-
} else if (variants && variants.length > 0) {
|
|
3095
|
-
removeVariants();
|
|
3096
|
-
}
|
|
3097
|
-
}`;
|
|
3098
|
-
var FILTER_WITH_CUSTOM_TARGETING_SCRIPT = "function filterWithCustomTargeting(userAttributes, query, startDate, endDate) {\n function isString(val) {\n return typeof val === 'string';\n }\n function isNumber(val) {\n return typeof val === 'number';\n }\n function objectMatchesQuery(userattr, query) {\n const result = (() => {\n const property = query.property;\n const operator = query.operator;\n let testValue = query.value;\n if (query && query.property === 'urlPath' && query.value && typeof query.value === 'string' && query.value !== '/' && query.value.endsWith('/')) {\n testValue = query.value.slice(0, -1);\n }\n if (!(property && operator)) {\n return true;\n }\n if (Array.isArray(testValue)) {\n if (operator === 'isNot') {\n return testValue.every(val => objectMatchesQuery(userattr, {\n property,\n operator,\n value: val\n }));\n }\n return !!testValue.find(val => objectMatchesQuery(userattr, {\n property,\n operator,\n value: val\n }));\n }\n const value = userattr[property];\n if (Array.isArray(value)) {\n return value.includes(testValue);\n }\n switch (operator) {\n case 'is':\n return value === testValue;\n case 'isNot':\n return value !== testValue;\n case 'contains':\n return (isString(value) || Array.isArray(value)) && value.includes(String(testValue));\n case 'startsWith':\n return isString(value) && value.startsWith(String(testValue));\n case 'endsWith':\n return isString(value) && value.endsWith(String(testValue));\n case 'greaterThan':\n return isNumber(value) && isNumber(testValue) && value > testValue;\n case 'lessThan':\n return isNumber(value) && isNumber(testValue) && value < testValue;\n case 'greaterThanOrEqualTo':\n return isNumber(value) && isNumber(testValue) && value >= testValue;\n case 'lessThanOrEqualTo':\n return isNumber(value) && isNumber(testValue) && value <= testValue;\n default:\n return false;\n }\n })();\n return result;\n }\n const item = {\n query,\n startDate,\n endDate\n };\n const now = userAttributes.date && new Date(userAttributes.date) || new Date();\n if (item.startDate && new Date(item.startDate) > now) {\n return false;\n } else if (item.endDate && new Date(item.endDate) < now) {\n return false;\n }\n if (!item.query || !item.query.length) {\n return true;\n }\n return item.query.every(filter => {\n return objectMatchesQuery(userAttributes, filter);\n });\n}";
|
|
3099
|
-
|
|
3100
|
-
// src/blocks/personalization-container/helpers.ts
|
|
3101
|
-
function checkShouldRenderVariants(variants, canTrack) {
|
|
3102
|
-
const hasVariants = variants && variants.length > 0;
|
|
3103
|
-
if (TARGET === "reactNative")
|
|
3104
|
-
return false;
|
|
3105
|
-
if (!hasVariants)
|
|
3106
|
-
return false;
|
|
3107
|
-
if (!canTrack)
|
|
3108
|
-
return false;
|
|
3109
|
-
if (TARGET === "vue" || TARGET === "svelte")
|
|
3110
|
-
return true;
|
|
3111
|
-
if (isBrowser())
|
|
3112
|
-
return false;
|
|
3113
|
-
return true;
|
|
3114
|
-
}
|
|
3115
|
-
function getBlocksToRender({
|
|
3116
|
-
variants,
|
|
3117
|
-
previewingIndex,
|
|
3118
|
-
isHydrated,
|
|
3119
|
-
filteredVariants,
|
|
3120
|
-
fallbackBlocks
|
|
3121
|
-
}) {
|
|
3122
|
-
const fallback = {
|
|
3123
|
-
blocks: fallbackBlocks ?? [],
|
|
3124
|
-
path: "this.children"
|
|
3125
|
-
};
|
|
3126
|
-
if (isHydrated && isEditing()) {
|
|
3127
|
-
if (typeof previewingIndex === "number" && previewingIndex < (variants?.length ?? 0)) {
|
|
3128
|
-
const variant = variants[previewingIndex];
|
|
3129
|
-
return {
|
|
3130
|
-
blocks: variant.blocks,
|
|
3131
|
-
path: `component.options.variants.${previewingIndex}.blocks`
|
|
3132
|
-
};
|
|
3133
|
-
}
|
|
3134
|
-
return fallback;
|
|
3135
|
-
}
|
|
3136
|
-
if (isBrowser()) {
|
|
3137
|
-
const winningVariant = filteredVariants?.[0];
|
|
3138
|
-
if (winningVariant) {
|
|
3139
|
-
return {
|
|
3140
|
-
blocks: winningVariant.blocks,
|
|
3141
|
-
path: `component.options.variants.${variants?.indexOf(winningVariant)}.blocks`
|
|
3142
|
-
};
|
|
3143
|
-
}
|
|
3144
|
-
}
|
|
3145
|
-
return fallback;
|
|
3146
|
-
}
|
|
3147
|
-
var getPersonalizationScript = (variants, blockId, locale) => {
|
|
3148
|
-
return `
|
|
3149
|
-
(function() {
|
|
3150
|
-
${FILTER_WITH_CUSTOM_TARGETING_SCRIPT}
|
|
3151
|
-
${PERSONALIZATION_SCRIPT}
|
|
3152
|
-
getPersonalizedVariant(${JSON.stringify(variants)}, "${blockId}"${locale ? `, "${locale}"` : ""})
|
|
3153
|
-
})();
|
|
3154
|
-
`;
|
|
3155
|
-
};
|
|
3156
|
-
|
|
3157
3144
|
// src/blocks/personalization-container/personalization-container.tsx
|
|
3158
3145
|
function PersonalizationContainer(props) {
|
|
3159
3146
|
const [userAttributes, setUserAttributes] = createSignal10(
|
|
@@ -3166,6 +3153,13 @@ function PersonalizationContainer(props) {
|
|
|
3166
3153
|
props.builderContext?.rootState?.locale
|
|
3167
3154
|
)
|
|
3168
3155
|
);
|
|
3156
|
+
const [updateVisibilityStylesScript, setUpdateVisibilityStylesScript] = createSignal10(
|
|
3157
|
+
getUpdateVisibilityStylesScript(
|
|
3158
|
+
props.variants,
|
|
3159
|
+
props.builderBlock?.id || "none",
|
|
3160
|
+
props.builderContext?.rootState?.locale
|
|
3161
|
+
)
|
|
3162
|
+
);
|
|
3169
3163
|
const [unsubscribers, setUnsubscribers] = createSignal10([]);
|
|
3170
3164
|
const [shouldRenderVariants, setShouldRenderVariants] = createSignal10(
|
|
3171
3165
|
checkShouldRenderVariants(
|
|
@@ -3173,7 +3167,14 @@ function PersonalizationContainer(props) {
|
|
|
3173
3167
|
getDefaultCanTrack(props.builderContext?.canTrack)
|
|
3174
3168
|
)
|
|
3175
3169
|
);
|
|
3176
|
-
const [
|
|
3170
|
+
const [shouldResetVariants, setShouldResetVariants] = createSignal10(false);
|
|
3171
|
+
const attrs = createMemo10(() => {
|
|
3172
|
+
return {
|
|
3173
|
+
...props.attributes,
|
|
3174
|
+
...{},
|
|
3175
|
+
[getClassPropName()]: `builder-personalization-container ${props.attributes[getClassPropName()] || ""}`
|
|
3176
|
+
};
|
|
3177
|
+
});
|
|
3177
3178
|
const filteredVariants = createMemo10(() => {
|
|
3178
3179
|
return (props.variants || []).filter((variant) => {
|
|
3179
3180
|
return filterWithCustomTargeting(
|
|
@@ -3193,22 +3194,22 @@ function PersonalizationContainer(props) {
|
|
|
3193
3194
|
return getBlocksToRender({
|
|
3194
3195
|
variants: props.variants,
|
|
3195
3196
|
fallbackBlocks: props.builderBlock?.children,
|
|
3196
|
-
isHydrated:
|
|
3197
|
+
isHydrated: shouldResetVariants(),
|
|
3197
3198
|
filteredVariants: filteredVariants(),
|
|
3198
3199
|
previewingIndex: props.previewingIndex
|
|
3199
3200
|
});
|
|
3200
3201
|
});
|
|
3201
3202
|
const hideVariantsStyleString = createMemo10(() => {
|
|
3202
3203
|
return (props.variants || []).map(
|
|
3203
|
-
(_, index) => `[data-variant-id="${props.builderBlock?.id}-${index}"] { display: none; } `
|
|
3204
|
+
(_, index) => `div[data-variant-id="${props.builderBlock?.id}-${index}"] { display: none !important; } `
|
|
3204
3205
|
).join("");
|
|
3205
3206
|
});
|
|
3206
3207
|
let rootRef;
|
|
3207
3208
|
onMount5(() => {
|
|
3208
|
-
|
|
3209
|
+
setShouldResetVariants(true);
|
|
3209
3210
|
const unsub = userAttributesService.subscribeOnUserAttributesChange(
|
|
3210
|
-
(
|
|
3211
|
-
setUserAttributes(
|
|
3211
|
+
(attrs2) => {
|
|
3212
|
+
setUserAttributes(attrs2);
|
|
3212
3213
|
}
|
|
3213
3214
|
);
|
|
3214
3215
|
if (!(isEditing() || isPreviewing())) {
|
|
@@ -3217,7 +3218,7 @@ function PersonalizationContainer(props) {
|
|
|
3217
3218
|
rootRef.dispatchEvent(
|
|
3218
3219
|
new CustomEvent("builder.variantLoaded", {
|
|
3219
3220
|
detail: {
|
|
3220
|
-
variant: variant ||
|
|
3221
|
+
variant: variant || DEFAULT_INDEX,
|
|
3221
3222
|
content: props.builderContext?.content
|
|
3222
3223
|
},
|
|
3223
3224
|
bubbles: true
|
|
@@ -3229,7 +3230,7 @@ function PersonalizationContainer(props) {
|
|
|
3229
3230
|
rootRef.dispatchEvent(
|
|
3230
3231
|
new CustomEvent("builder.variantDisplayed", {
|
|
3231
3232
|
detail: {
|
|
3232
|
-
variant: variant ||
|
|
3233
|
+
variant: variant || DEFAULT_INDEX,
|
|
3233
3234
|
content: props.builderContext?.content
|
|
3234
3235
|
},
|
|
3235
3236
|
bubbles: true
|
|
@@ -3243,39 +3244,72 @@ function PersonalizationContainer(props) {
|
|
|
3243
3244
|
}
|
|
3244
3245
|
unsubscribers().push(unsub);
|
|
3245
3246
|
});
|
|
3246
|
-
return <><div
|
|
3247
|
-
|
|
3248
|
-
|
|
3249
|
-
|
|
3250
|
-
>
|
|
3251
|
-
<Show10 when={shouldRenderVariants()}>
|
|
3252
|
-
<For6 each={props.variants}>{(variant, _index) => {
|
|
3253
|
-
const index = _index();
|
|
3254
|
-
return <template
|
|
3255
|
-
key={index}
|
|
3256
|
-
data-variant-id={`${props.builderBlock?.id}-${index}`}
|
|
3257
|
-
><Blocks_default
|
|
3258
|
-
blocks={variant.blocks}
|
|
3259
|
-
parent={props.builderBlock?.id}
|
|
3260
|
-
path={`component.options.variants.${index}.blocks`}
|
|
3261
|
-
/></template>;
|
|
3262
|
-
}}</For6>
|
|
3263
|
-
<Inlined_styles_default
|
|
3264
|
-
nonce={props.builderContext?.nonce || ""}
|
|
3265
|
-
styles={hideVariantsStyleString()}
|
|
3266
|
-
id={`variants-styles-${props.builderBlock?.id}`}
|
|
3267
|
-
/>
|
|
3268
|
-
<Inlined_script_default
|
|
3269
|
-
nonce={props.builderContext?.nonce || ""}
|
|
3270
|
-
scriptStr={scriptStr()}
|
|
3271
|
-
id={`variants-script-${props.builderBlock?.id}`}
|
|
3272
|
-
/>
|
|
3273
|
-
</Show10>
|
|
3274
|
-
<Blocks_default
|
|
3247
|
+
return <><div ref={rootRef} {...attrs()}>
|
|
3248
|
+
<Show10
|
|
3249
|
+
when={shouldResetVariants() && SDKS_REQUIRING_RESET_APPROACH.includes(TARGET)}
|
|
3250
|
+
><Blocks_default
|
|
3275
3251
|
blocks={blocksToRender().blocks}
|
|
3276
3252
|
parent={props.builderBlock?.id}
|
|
3277
3253
|
path={blocksToRender().path}
|
|
3278
|
-
|
|
3254
|
+
context={props.builderContext}
|
|
3255
|
+
registeredComponents={props.builderComponents}
|
|
3256
|
+
BlocksWrapperProps={{
|
|
3257
|
+
...props.builderContext?.BlocksWrapperProps,
|
|
3258
|
+
"data-variant-id": `${props.builderBlock?.id}-${blocksToRender().index}`
|
|
3259
|
+
}}
|
|
3260
|
+
/></Show10>
|
|
3261
|
+
<Show10
|
|
3262
|
+
when={!shouldResetVariants() && SDKS_REQUIRING_RESET_APPROACH.includes(TARGET) || !SDKS_REQUIRING_RESET_APPROACH.includes(TARGET)}
|
|
3263
|
+
>
|
|
3264
|
+
<Show10 when={shouldRenderVariants()}>
|
|
3265
|
+
<Inlined_styles_default
|
|
3266
|
+
nonce={props.builderContext?.nonce || ""}
|
|
3267
|
+
styles={hideVariantsStyleString()}
|
|
3268
|
+
id={`variants-styles-${props.builderBlock?.id}`}
|
|
3269
|
+
/>
|
|
3270
|
+
<Inlined_script_default
|
|
3271
|
+
nonce={props.builderContext?.nonce || ""}
|
|
3272
|
+
scriptStr={updateVisibilityStylesScript()}
|
|
3273
|
+
id={`variants-visibility-script-${props.builderBlock?.id}`}
|
|
3274
|
+
/>
|
|
3275
|
+
<For6 each={props.variants}>{(variant, _index) => {
|
|
3276
|
+
const index = _index();
|
|
3277
|
+
return <Blocks_default
|
|
3278
|
+
key={`${props.builderBlock?.id}-${index}`}
|
|
3279
|
+
BlocksWrapperProps={{
|
|
3280
|
+
...props.builderContext?.BlocksWrapperProps,
|
|
3281
|
+
"aria-hidden": true,
|
|
3282
|
+
hidden: true,
|
|
3283
|
+
"data-variant-id": `${props.builderBlock?.id}-${index}`
|
|
3284
|
+
}}
|
|
3285
|
+
blocks={variant.blocks}
|
|
3286
|
+
parent={props.builderBlock?.id}
|
|
3287
|
+
path={`component.options.variants.${index}.blocks`}
|
|
3288
|
+
context={props.builderContext}
|
|
3289
|
+
registeredComponents={props.builderComponents}
|
|
3290
|
+
><Inlined_script_default
|
|
3291
|
+
nonce={props.builderContext?.nonce || ""}
|
|
3292
|
+
scriptStr={scriptStr()}
|
|
3293
|
+
id={`variants-script-${props.builderBlock?.id}-${index}`}
|
|
3294
|
+
/></Blocks_default>;
|
|
3295
|
+
}}</For6>
|
|
3296
|
+
</Show10>
|
|
3297
|
+
<Blocks_default
|
|
3298
|
+
blocks={blocksToRender().blocks}
|
|
3299
|
+
parent={props.builderBlock?.id}
|
|
3300
|
+
path={blocksToRender().path}
|
|
3301
|
+
context={props.builderContext}
|
|
3302
|
+
registeredComponents={props.builderComponents}
|
|
3303
|
+
BlocksWrapperProps={{
|
|
3304
|
+
...props.builderContext?.BlocksWrapperProps,
|
|
3305
|
+
"data-variant-id": `${props.builderBlock?.id}-${blocksToRender().index}`
|
|
3306
|
+
}}
|
|
3307
|
+
><Show10 when={shouldRenderVariants()}><Inlined_script_default
|
|
3308
|
+
nonce={props.builderContext?.nonce || ""}
|
|
3309
|
+
scriptStr={scriptStr()}
|
|
3310
|
+
id={`variants-script-${props.builderBlock?.id}-${DEFAULT_INDEX}`}
|
|
3311
|
+
/></Show10></Blocks_default>
|
|
3312
|
+
</Show10>
|
|
3279
3313
|
</div></>;
|
|
3280
3314
|
}
|
|
3281
3315
|
var personalization_container_default = PersonalizationContainer;
|
|
@@ -3667,7 +3701,7 @@ var componentInfo12 = {
|
|
|
3667
3701
|
};
|
|
3668
3702
|
|
|
3669
3703
|
// src/blocks/custom-code/custom-code.tsx
|
|
3670
|
-
import { onMount as onMount6, on as
|
|
3704
|
+
import { onMount as onMount6, on as on6, createEffect as createEffect6, createMemo as createMemo12, createSignal as createSignal12 } from "solid-js";
|
|
3671
3705
|
function CustomCode(props) {
|
|
3672
3706
|
const [scriptsInserted, setScriptsInserted] = createSignal12([]);
|
|
3673
3707
|
const [scriptsRun, setScriptsRun] = createSignal12([]);
|
|
@@ -3717,7 +3751,7 @@ function CustomCode(props) {
|
|
|
3717
3751
|
runScripts();
|
|
3718
3752
|
}
|
|
3719
3753
|
}
|
|
3720
|
-
|
|
3754
|
+
createEffect6(on6(() => [onUpdateFn_0_props_code()], onUpdateFn_0));
|
|
3721
3755
|
return <><div
|
|
3722
3756
|
class={"builder-custom-code" + (props.replaceNodes ? " replace-nodes" : "")}
|
|
3723
3757
|
ref={elementRef}
|
|
@@ -3745,7 +3779,7 @@ var componentInfo13 = {
|
|
|
3745
3779
|
};
|
|
3746
3780
|
|
|
3747
3781
|
// src/blocks/embed/embed.tsx
|
|
3748
|
-
import { on as
|
|
3782
|
+
import { on as on7, createEffect as createEffect7, createMemo as createMemo13, createSignal as createSignal13 } from "solid-js";
|
|
3749
3783
|
|
|
3750
3784
|
// src/blocks/embed/helpers.ts
|
|
3751
3785
|
var SCRIPT_MIME_TYPES = ["text/javascript", "application/javascript", "application/ecmascript"];
|
|
@@ -3787,8 +3821,8 @@ function Embed(props) {
|
|
|
3787
3821
|
findAndRunScripts();
|
|
3788
3822
|
}
|
|
3789
3823
|
}
|
|
3790
|
-
|
|
3791
|
-
|
|
3824
|
+
createEffect7(
|
|
3825
|
+
on7(() => [onUpdateFn_0_elem(), onUpdateFn_0_ranInitFn__()], onUpdateFn_0)
|
|
3792
3826
|
);
|
|
3793
3827
|
return <><div class="builder-embed" ref={elem} innerHTML={props.content} /></>;
|
|
3794
3828
|
}
|
|
@@ -4797,7 +4831,7 @@ var getDefaultRegisteredComponents = () => [{
|
|
|
4797
4831
|
}, {
|
|
4798
4832
|
component: text_default,
|
|
4799
4833
|
...componentInfo11
|
|
4800
|
-
}, ...TARGET
|
|
4834
|
+
}, ...SDKS_SUPPORTING_PERSONALIZATION.includes(TARGET) ? [{
|
|
4801
4835
|
component: personalization_container_default,
|
|
4802
4836
|
...componentInfo6
|
|
4803
4837
|
}] : [], ...TARGET === "rsc" ? [] : [{
|
|
@@ -4834,7 +4868,7 @@ var UPDATE_VARIANT_VISIBILITY_SCRIPT = "function updateVariantVisibility(variant
|
|
|
4834
4868
|
|
|
4835
4869
|
// src/components/content-variants/helpers.ts
|
|
4836
4870
|
var UPDATE_COOKIES_AND_STYLES_SCRIPT_NAME = "builderIoAbTest";
|
|
4837
|
-
var
|
|
4871
|
+
var UPDATE_VARIANT_VISIBILITY_SCRIPT_FN_NAME2 = "builderIoRenderContent";
|
|
4838
4872
|
var getVariants = (content) => Object.values(content?.variations || {}).map((variant) => ({
|
|
4839
4873
|
...variant,
|
|
4840
4874
|
testVariationId: variant.id,
|
|
@@ -4859,28 +4893,28 @@ var checkShouldRenderVariants2 = ({
|
|
|
4859
4893
|
};
|
|
4860
4894
|
var getIsHydrationTarget = (target) => target === "react" || target === "reactNative";
|
|
4861
4895
|
var isAngularSDK = TARGET === "angular";
|
|
4862
|
-
var
|
|
4896
|
+
var isHydrationTarget2 = getIsHydrationTarget(TARGET);
|
|
4863
4897
|
var getInitVariantsFnsScriptString = () => `
|
|
4864
4898
|
window.${UPDATE_COOKIES_AND_STYLES_SCRIPT_NAME} = ${UPDATE_COOKIES_AND_STYLES_SCRIPT}
|
|
4865
|
-
window.${
|
|
4899
|
+
window.${UPDATE_VARIANT_VISIBILITY_SCRIPT_FN_NAME2} = ${UPDATE_VARIANT_VISIBILITY_SCRIPT}
|
|
4866
4900
|
`;
|
|
4867
4901
|
var getUpdateCookieAndStylesScript = (variants, contentId) => `
|
|
4868
4902
|
window.${UPDATE_COOKIES_AND_STYLES_SCRIPT_NAME}(
|
|
4869
|
-
"${contentId}",${JSON.stringify(variants)}, ${
|
|
4903
|
+
"${contentId}",${JSON.stringify(variants)}, ${isHydrationTarget2}, ${isAngularSDK}
|
|
4870
4904
|
)`;
|
|
4871
4905
|
var getUpdateVariantVisibilityScript = ({
|
|
4872
4906
|
contentId,
|
|
4873
4907
|
variationId
|
|
4874
|
-
}) => `window.${
|
|
4875
|
-
"${variationId}", "${contentId}", ${
|
|
4908
|
+
}) => `window.${UPDATE_VARIANT_VISIBILITY_SCRIPT_FN_NAME2}(
|
|
4909
|
+
"${variationId}", "${contentId}", ${isHydrationTarget2}
|
|
4876
4910
|
)`;
|
|
4877
4911
|
|
|
4878
4912
|
// src/components/content/components/enable-editor.tsx
|
|
4879
4913
|
import {
|
|
4880
4914
|
Show as Show14,
|
|
4881
4915
|
onMount as onMount8,
|
|
4882
|
-
on as
|
|
4883
|
-
createEffect as
|
|
4916
|
+
on as on8,
|
|
4917
|
+
createEffect as createEffect8,
|
|
4884
4918
|
createMemo as createMemo16,
|
|
4885
4919
|
createSignal as createSignal16
|
|
4886
4920
|
} from "solid-js";
|
|
@@ -4892,7 +4926,7 @@ function getPreviewContent(_searchParams) {
|
|
|
4892
4926
|
}
|
|
4893
4927
|
|
|
4894
4928
|
// src/constants/sdk-version.ts
|
|
4895
|
-
var SDK_VERSION = "4.0.
|
|
4929
|
+
var SDK_VERSION = "4.0.9";
|
|
4896
4930
|
|
|
4897
4931
|
// src/helpers/sdk-headers.ts
|
|
4898
4932
|
var getSdkHeaders = () => ({
|
|
@@ -5977,15 +6011,15 @@ function EnableEditor(props) {
|
|
|
5977
6011
|
mergeNewContent(props.content);
|
|
5978
6012
|
}
|
|
5979
6013
|
}
|
|
5980
|
-
|
|
6014
|
+
createEffect8(on8(() => [onUpdateFn_0_props_content()], onUpdateFn_0));
|
|
5981
6015
|
const onUpdateFn_1_props_builderContextSignal_rootState = createMemo16(
|
|
5982
6016
|
() => props.builderContextSignal.rootState
|
|
5983
6017
|
);
|
|
5984
6018
|
function onUpdateFn_1() {
|
|
5985
6019
|
emitStateUpdate();
|
|
5986
6020
|
}
|
|
5987
|
-
|
|
5988
|
-
|
|
6021
|
+
createEffect8(
|
|
6022
|
+
on8(
|
|
5989
6023
|
() => [onUpdateFn_1_props_builderContextSignal_rootState()],
|
|
5990
6024
|
onUpdateFn_1
|
|
5991
6025
|
)
|
|
@@ -5996,7 +6030,7 @@ function EnableEditor(props) {
|
|
|
5996
6030
|
mergeNewRootState(props.data);
|
|
5997
6031
|
}
|
|
5998
6032
|
}
|
|
5999
|
-
|
|
6033
|
+
createEffect8(on8(() => [onUpdateFn_2_props_data()], onUpdateFn_2));
|
|
6000
6034
|
const onUpdateFn_3_props_locale = createMemo16(() => props.locale);
|
|
6001
6035
|
function onUpdateFn_3() {
|
|
6002
6036
|
if (props.locale) {
|
|
@@ -6005,7 +6039,7 @@ function EnableEditor(props) {
|
|
|
6005
6039
|
});
|
|
6006
6040
|
}
|
|
6007
6041
|
}
|
|
6008
|
-
|
|
6042
|
+
createEffect8(on8(() => [onUpdateFn_3_props_locale()], onUpdateFn_3));
|
|
6009
6043
|
return <><builder_context_default.Provider value={props.builderContextSignal}><Show14
|
|
6010
6044
|
when={props.builderContextSignal.content || needsElementRefDivForEditing()}
|
|
6011
6045
|
><Dynamic5
|
|
@@ -6251,11 +6285,18 @@ function ContentVariants(props) {
|
|
|
6251
6285
|
setShouldRenderVariants(false);
|
|
6252
6286
|
});
|
|
6253
6287
|
return <><>
|
|
6254
|
-
<Show16 when={!props.isNestedRender && TARGET !== "reactNative"}
|
|
6255
|
-
|
|
6256
|
-
|
|
6257
|
-
|
|
6258
|
-
|
|
6288
|
+
<Show16 when={!props.isNestedRender && TARGET !== "reactNative"}>
|
|
6289
|
+
<Inlined_script_default
|
|
6290
|
+
id="builderio-init-variants-fns"
|
|
6291
|
+
scriptStr={getInitVariantsFnsScriptString()}
|
|
6292
|
+
nonce={props.nonce || ""}
|
|
6293
|
+
/>
|
|
6294
|
+
<Show16 when={SDKS_SUPPORTING_PERSONALIZATION.includes(TARGET)}><Inlined_script_default
|
|
6295
|
+
id="builderio-init-personalization-variants-fns"
|
|
6296
|
+
nonce={props.nonce || ""}
|
|
6297
|
+
scriptStr={getInitPersonalizationVariantsFnsScriptString()}
|
|
6298
|
+
/></Show16>
|
|
6299
|
+
</Show16>
|
|
6259
6300
|
<Show16 when={shouldRenderVariants()}>
|
|
6260
6301
|
<Inlined_styles_default
|
|
6261
6302
|
id="builderio-variants"
|
|
@@ -6351,6 +6392,7 @@ var fetchSymbolContent = async ({
|
|
|
6351
6392
|
// src/blocks/symbol/symbol.tsx
|
|
6352
6393
|
function Symbol(props) {
|
|
6353
6394
|
const [contentToUse, setContentToUse] = createSignal20(props.symbol?.content);
|
|
6395
|
+
const [symbolEntry, setSymbolEntry] = createSignal20(props.symbol?.entry);
|
|
6354
6396
|
const blocksWrapper = createMemo20(() => {
|
|
6355
6397
|
return "div";
|
|
6356
6398
|
});
|
|
@@ -6366,7 +6408,7 @@ function Symbol(props) {
|
|
|
6366
6408
|
].filter(Boolean).join(" ");
|
|
6367
6409
|
});
|
|
6368
6410
|
function setContent() {
|
|
6369
|
-
if (contentToUse())
|
|
6411
|
+
if (contentToUse() && symbolEntry() === props.symbol?.entry)
|
|
6370
6412
|
return;
|
|
6371
6413
|
fetchSymbolContent({
|
|
6372
6414
|
symbol: props.symbol,
|
|
@@ -6374,6 +6416,7 @@ function Symbol(props) {
|
|
|
6374
6416
|
}).then((newContent) => {
|
|
6375
6417
|
if (newContent) {
|
|
6376
6418
|
setContentToUse(newContent);
|
|
6419
|
+
setSymbolEntry(props.symbol?.entry);
|
|
6377
6420
|
}
|
|
6378
6421
|
});
|
|
6379
6422
|
}
|
|
@@ -6383,7 +6426,7 @@ function Symbol(props) {
|
|
|
6383
6426
|
function onUpdateFn_0() {
|
|
6384
6427
|
setContent();
|
|
6385
6428
|
}
|
|
6386
|
-
|
|
6429
|
+
createEffect9(on9(() => [onUpdateFn_0_props_symbol()], onUpdateFn_0));
|
|
6387
6430
|
return <><div class={className()} {...{}} {...props.attributes} {...{}}><Content_variants_default
|
|
6388
6431
|
nonce={props.builderContext.nonce}
|
|
6389
6432
|
isNestedRender={true}
|