@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/node/dev.jsx
CHANGED
|
@@ -1373,15 +1373,15 @@ var Block_wrapper_default = BlockWrapper;
|
|
|
1373
1373
|
import {
|
|
1374
1374
|
Show as Show4,
|
|
1375
1375
|
For,
|
|
1376
|
-
on,
|
|
1377
|
-
createEffect,
|
|
1376
|
+
on as on2,
|
|
1377
|
+
createEffect as createEffect2,
|
|
1378
1378
|
createMemo as createMemo3,
|
|
1379
1379
|
createSignal as createSignal3
|
|
1380
1380
|
} from "solid-js";
|
|
1381
1381
|
import { Dynamic as Dynamic3 } from "solid-js/web";
|
|
1382
1382
|
|
|
1383
1383
|
// src/components/block/components/interactive-element.tsx
|
|
1384
|
-
import { Show as Show3, createMemo as createMemo2 } from "solid-js";
|
|
1384
|
+
import { Show as Show3, on, createEffect, createMemo as createMemo2, createSignal as createSignal2 } from "solid-js";
|
|
1385
1385
|
import { Dynamic as Dynamic2 } from "solid-js/web";
|
|
1386
1386
|
|
|
1387
1387
|
// src/components/awaiter.tsx
|
|
@@ -1395,6 +1395,7 @@ var Awaiter_default = Awaiter;
|
|
|
1395
1395
|
|
|
1396
1396
|
// src/components/block/components/interactive-element.tsx
|
|
1397
1397
|
function InteractiveElement(props) {
|
|
1398
|
+
const [forceRenderCount, setForceRenderCount] = createSignal2(0);
|
|
1398
1399
|
const attributes = createMemo2(() => {
|
|
1399
1400
|
return props.includeBlockProps ? {
|
|
1400
1401
|
...getBlockProperties({
|
|
@@ -1413,6 +1414,21 @@ function InteractiveElement(props) {
|
|
|
1413
1414
|
const targetWrapperProps = createMemo2(() => {
|
|
1414
1415
|
return props.wrapperProps;
|
|
1415
1416
|
});
|
|
1417
|
+
const onUpdateFn_0_props_wrapperProps = createMemo2(() => props.wrapperProps);
|
|
1418
|
+
const onUpdateFn_0_props_block__component__options = createMemo2(
|
|
1419
|
+
() => props.block?.component?.options
|
|
1420
|
+
);
|
|
1421
|
+
function onUpdateFn_0() {
|
|
1422
|
+
}
|
|
1423
|
+
createEffect(
|
|
1424
|
+
on(
|
|
1425
|
+
() => [
|
|
1426
|
+
onUpdateFn_0_props_wrapperProps(),
|
|
1427
|
+
onUpdateFn_0_props_block__component__options()
|
|
1428
|
+
],
|
|
1429
|
+
onUpdateFn_0
|
|
1430
|
+
)
|
|
1431
|
+
);
|
|
1416
1432
|
return <><Show3
|
|
1417
1433
|
fallback={<Dynamic2
|
|
1418
1434
|
{...targetWrapperProps()}
|
|
@@ -1476,8 +1492,8 @@ function ComponentRef(props) {
|
|
|
1476
1492
|
);
|
|
1477
1493
|
function onUpdateFn_0() {
|
|
1478
1494
|
}
|
|
1479
|
-
|
|
1480
|
-
|
|
1495
|
+
createEffect2(
|
|
1496
|
+
on2(
|
|
1481
1497
|
() => [
|
|
1482
1498
|
onUpdateFn_0_props_componentOptions(),
|
|
1483
1499
|
onUpdateFn_0_props_blockChildren()
|
|
@@ -1511,7 +1527,7 @@ function ComponentRef(props) {
|
|
|
1511
1527
|
var Component_ref_default = ComponentRef;
|
|
1512
1528
|
|
|
1513
1529
|
// src/components/block/components/repeated-block.tsx
|
|
1514
|
-
import { on as
|
|
1530
|
+
import { on as on3, createEffect as createEffect3, createMemo as createMemo4, createSignal as createSignal4 } from "solid-js";
|
|
1515
1531
|
function RepeatedBlock(props) {
|
|
1516
1532
|
const [store, setStore] = createSignal4(props.repeatContext);
|
|
1517
1533
|
const onUpdateFn_0_props_repeatContext = createMemo4(
|
|
@@ -1520,7 +1536,7 @@ function RepeatedBlock(props) {
|
|
|
1520
1536
|
function onUpdateFn_0() {
|
|
1521
1537
|
setStore(props.repeatContext);
|
|
1522
1538
|
}
|
|
1523
|
-
|
|
1539
|
+
createEffect3(on3(() => [onUpdateFn_0_props_repeatContext()], onUpdateFn_0));
|
|
1524
1540
|
return <><builder_context_default.Provider value={store()}><Block_default
|
|
1525
1541
|
block={props.block}
|
|
1526
1542
|
context={store()}
|
|
@@ -1689,7 +1705,7 @@ function Block(props) {
|
|
|
1689
1705
|
var Block_default = Block;
|
|
1690
1706
|
|
|
1691
1707
|
// src/components/blocks/blocks-wrapper.tsx
|
|
1692
|
-
import { onMount as onMount3, on as
|
|
1708
|
+
import { onMount as onMount3, on as on5, createEffect as createEffect5, createMemo as createMemo6, createSignal as createSignal6 } from "solid-js";
|
|
1693
1709
|
import { Dynamic as Dynamic4 } from "solid-js/web";
|
|
1694
1710
|
function BlocksWrapper(props) {
|
|
1695
1711
|
const [shouldUpdate, setShouldUpdate] = createSignal6(false);
|
|
@@ -1742,10 +1758,10 @@ function BlocksWrapper(props) {
|
|
|
1742
1758
|
const onUpdateFn_0_props_blocks = createMemo6(() => props.blocks);
|
|
1743
1759
|
function onUpdateFn_0() {
|
|
1744
1760
|
}
|
|
1745
|
-
|
|
1761
|
+
createEffect5(on5(() => [onUpdateFn_0_props_blocks()], onUpdateFn_0));
|
|
1746
1762
|
return <>
|
|
1747
1763
|
<Dynamic4
|
|
1748
|
-
class={className() + " dynamic-
|
|
1764
|
+
class={className() + " dynamic-450facf4"}
|
|
1749
1765
|
ref={blocksWrapperRef}
|
|
1750
1766
|
builder-path={dataPath()}
|
|
1751
1767
|
builder-parent-id={props.parent}
|
|
@@ -1757,7 +1773,7 @@ function BlocksWrapper(props) {
|
|
|
1757
1773
|
{...props.BlocksWrapperProps}
|
|
1758
1774
|
component={props.BlocksWrapper}
|
|
1759
1775
|
>{props.children}</Dynamic4>
|
|
1760
|
-
<style>{`.dynamic-
|
|
1776
|
+
<style>{`.dynamic-450facf4 {
|
|
1761
1777
|
display: flex;
|
|
1762
1778
|
flex-direction: column;
|
|
1763
1779
|
align-items: stretch;
|
|
@@ -1775,19 +1791,22 @@ function Blocks(props) {
|
|
|
1775
1791
|
parent={props.parent}
|
|
1776
1792
|
path={props.path}
|
|
1777
1793
|
styleProp={props.styleProp}
|
|
1794
|
+
BlocksWrapperProps={props.BlocksWrapperProps || props.context?.BlocksWrapperProps || builderContext?.BlocksWrapperProps}
|
|
1778
1795
|
classNameProp={props.className}
|
|
1779
1796
|
BlocksWrapper={props.context?.BlocksWrapper || builderContext?.BlocksWrapper}
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
|
|
1797
|
+
>
|
|
1798
|
+
{props.children}
|
|
1799
|
+
<Show6 when={props.blocks}><For3 each={props.blocks}>{(block, _index) => {
|
|
1800
|
+
const index = _index();
|
|
1801
|
+
return <Block_default
|
|
1802
|
+
key={block.id}
|
|
1803
|
+
block={block}
|
|
1804
|
+
linkComponent={props.linkComponent}
|
|
1805
|
+
context={props.context || builderContext}
|
|
1806
|
+
registeredComponents={props.registeredComponents || componentsContext?.registeredComponents}
|
|
1807
|
+
/>;
|
|
1808
|
+
}}</For3></Show6>
|
|
1809
|
+
</Blocks_wrapper_default></>;
|
|
1791
1810
|
}
|
|
1792
1811
|
var Blocks_default = Blocks;
|
|
1793
1812
|
|
|
@@ -2134,11 +2153,171 @@ function SectionComponent(props) {
|
|
|
2134
2153
|
var section_default = SectionComponent;
|
|
2135
2154
|
|
|
2136
2155
|
// src/blocks/symbol/symbol.tsx
|
|
2137
|
-
import { onMount as onMount10, on as
|
|
2156
|
+
import { onMount as onMount10, on as on9, createEffect as createEffect9, createMemo as createMemo20, createSignal as createSignal20 } from "solid-js";
|
|
2138
2157
|
|
|
2139
2158
|
// src/components/content-variants/content-variants.tsx
|
|
2140
2159
|
import { Show as Show16, For as For9, onMount as onMount9, createSignal as createSignal19, createMemo as createMemo19 } from "solid-js";
|
|
2141
2160
|
|
|
2161
|
+
// src/blocks/personalization-container/helpers/inlined-fns.ts
|
|
2162
|
+
function filterWithCustomTargeting(userAttributes, query, startDate, endDate) {
|
|
2163
|
+
function isString(val) {
|
|
2164
|
+
return typeof val === "string";
|
|
2165
|
+
}
|
|
2166
|
+
function isNumber(val) {
|
|
2167
|
+
return typeof val === "number";
|
|
2168
|
+
}
|
|
2169
|
+
function objectMatchesQuery(userattr, query2) {
|
|
2170
|
+
const result = (() => {
|
|
2171
|
+
const property = query2.property;
|
|
2172
|
+
const operator = query2.operator;
|
|
2173
|
+
let testValue = query2.value;
|
|
2174
|
+
if (query2 && query2.property === "urlPath" && query2.value && typeof query2.value === "string" && query2.value !== "/" && query2.value.endsWith("/")) {
|
|
2175
|
+
testValue = query2.value.slice(0, -1);
|
|
2176
|
+
}
|
|
2177
|
+
if (!(property && operator)) {
|
|
2178
|
+
return true;
|
|
2179
|
+
}
|
|
2180
|
+
if (Array.isArray(testValue)) {
|
|
2181
|
+
if (operator === "isNot") {
|
|
2182
|
+
return testValue.every((val) => objectMatchesQuery(userattr, {
|
|
2183
|
+
property,
|
|
2184
|
+
operator,
|
|
2185
|
+
value: val
|
|
2186
|
+
}));
|
|
2187
|
+
}
|
|
2188
|
+
return !!testValue.find((val) => objectMatchesQuery(userattr, {
|
|
2189
|
+
property,
|
|
2190
|
+
operator,
|
|
2191
|
+
value: val
|
|
2192
|
+
}));
|
|
2193
|
+
}
|
|
2194
|
+
const value = userattr[property];
|
|
2195
|
+
if (Array.isArray(value)) {
|
|
2196
|
+
return value.includes(testValue);
|
|
2197
|
+
}
|
|
2198
|
+
switch (operator) {
|
|
2199
|
+
case "is":
|
|
2200
|
+
return value === testValue;
|
|
2201
|
+
case "isNot":
|
|
2202
|
+
return value !== testValue;
|
|
2203
|
+
case "contains":
|
|
2204
|
+
return (isString(value) || Array.isArray(value)) && value.includes(String(testValue));
|
|
2205
|
+
case "startsWith":
|
|
2206
|
+
return isString(value) && value.startsWith(String(testValue));
|
|
2207
|
+
case "endsWith":
|
|
2208
|
+
return isString(value) && value.endsWith(String(testValue));
|
|
2209
|
+
case "greaterThan":
|
|
2210
|
+
return isNumber(value) && isNumber(testValue) && value > testValue;
|
|
2211
|
+
case "lessThan":
|
|
2212
|
+
return isNumber(value) && isNumber(testValue) && value < testValue;
|
|
2213
|
+
case "greaterThanOrEqualTo":
|
|
2214
|
+
return isNumber(value) && isNumber(testValue) && value >= testValue;
|
|
2215
|
+
case "lessThanOrEqualTo":
|
|
2216
|
+
return isNumber(value) && isNumber(testValue) && value <= testValue;
|
|
2217
|
+
default:
|
|
2218
|
+
return false;
|
|
2219
|
+
}
|
|
2220
|
+
})();
|
|
2221
|
+
return result;
|
|
2222
|
+
}
|
|
2223
|
+
const item = {
|
|
2224
|
+
query,
|
|
2225
|
+
startDate,
|
|
2226
|
+
endDate
|
|
2227
|
+
};
|
|
2228
|
+
const now = userAttributes.date && new Date(userAttributes.date) || /* @__PURE__ */ new Date();
|
|
2229
|
+
if (item.startDate && new Date(item.startDate) > now) {
|
|
2230
|
+
return false;
|
|
2231
|
+
} else if (item.endDate && new Date(item.endDate) < now) {
|
|
2232
|
+
return false;
|
|
2233
|
+
}
|
|
2234
|
+
if (!item.query || !item.query.length) {
|
|
2235
|
+
return true;
|
|
2236
|
+
}
|
|
2237
|
+
return item.query.every((filter) => {
|
|
2238
|
+
return objectMatchesQuery(userAttributes, filter);
|
|
2239
|
+
});
|
|
2240
|
+
}
|
|
2241
|
+
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}";
|
|
2242
|
+
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}";
|
|
2243
|
+
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}";
|
|
2244
|
+
|
|
2245
|
+
// src/blocks/personalization-container/helpers.ts
|
|
2246
|
+
var DEFAULT_INDEX = "default";
|
|
2247
|
+
var FILTER_WITH_CUSTOM_TARGETING_SCRIPT_FN_NAME = "filterWithCustomTargeting";
|
|
2248
|
+
var BUILDER_IO_PERSONALIZATION_SCRIPT_FN_NAME = "builderIoPersonalization";
|
|
2249
|
+
var UPDATE_VARIANT_VISIBILITY_SCRIPT_FN_NAME = "updateVisibilityStylesScript";
|
|
2250
|
+
var SDKS_SUPPORTING_PERSONALIZATION = ["react", "vue", "svelte"];
|
|
2251
|
+
var SDKS_REQUIRING_RESET_APPROACH = ["vue", "svelte"];
|
|
2252
|
+
function checkShouldRenderVariants(variants, canTrack) {
|
|
2253
|
+
const hasVariants = variants && variants.length > 0;
|
|
2254
|
+
if (TARGET === "reactNative")
|
|
2255
|
+
return false;
|
|
2256
|
+
if (!hasVariants)
|
|
2257
|
+
return false;
|
|
2258
|
+
if (!canTrack)
|
|
2259
|
+
return false;
|
|
2260
|
+
if (SDKS_REQUIRING_RESET_APPROACH.includes(TARGET))
|
|
2261
|
+
return true;
|
|
2262
|
+
if (isBrowser())
|
|
2263
|
+
return false;
|
|
2264
|
+
return true;
|
|
2265
|
+
}
|
|
2266
|
+
function getBlocksToRender({
|
|
2267
|
+
variants,
|
|
2268
|
+
previewingIndex,
|
|
2269
|
+
isHydrated,
|
|
2270
|
+
filteredVariants,
|
|
2271
|
+
fallbackBlocks
|
|
2272
|
+
}) {
|
|
2273
|
+
const fallback = {
|
|
2274
|
+
blocks: fallbackBlocks ?? [],
|
|
2275
|
+
path: "this.children",
|
|
2276
|
+
index: DEFAULT_INDEX
|
|
2277
|
+
};
|
|
2278
|
+
if (isHydrated && isEditing()) {
|
|
2279
|
+
if (typeof previewingIndex === "number" && previewingIndex < (variants?.length ?? 0)) {
|
|
2280
|
+
const variant = variants?.[previewingIndex];
|
|
2281
|
+
if (variant) {
|
|
2282
|
+
return {
|
|
2283
|
+
blocks: variant.blocks,
|
|
2284
|
+
path: `variants.${previewingIndex}.blocks`,
|
|
2285
|
+
index: previewingIndex
|
|
2286
|
+
};
|
|
2287
|
+
}
|
|
2288
|
+
}
|
|
2289
|
+
return fallback;
|
|
2290
|
+
}
|
|
2291
|
+
if (isBrowser()) {
|
|
2292
|
+
const winningVariant = filteredVariants?.[0];
|
|
2293
|
+
if (winningVariant && variants) {
|
|
2294
|
+
const variantIndex = variants.indexOf(winningVariant);
|
|
2295
|
+
if (variantIndex !== -1) {
|
|
2296
|
+
return {
|
|
2297
|
+
blocks: winningVariant.blocks,
|
|
2298
|
+
path: `variants.${variantIndex}.blocks`,
|
|
2299
|
+
index: variantIndex
|
|
2300
|
+
};
|
|
2301
|
+
}
|
|
2302
|
+
}
|
|
2303
|
+
}
|
|
2304
|
+
return fallback;
|
|
2305
|
+
}
|
|
2306
|
+
var getInitPersonalizationVariantsFnsScriptString = () => {
|
|
2307
|
+
return `
|
|
2308
|
+
window.${FILTER_WITH_CUSTOM_TARGETING_SCRIPT_FN_NAME} = ${FILTER_WITH_CUSTOM_TARGETING_SCRIPT}
|
|
2309
|
+
window.${BUILDER_IO_PERSONALIZATION_SCRIPT_FN_NAME} = ${PERSONALIZATION_SCRIPT}
|
|
2310
|
+
window.${UPDATE_VARIANT_VISIBILITY_SCRIPT_FN_NAME} = ${UPDATE_VISIBILITY_STYLES_SCRIPT}
|
|
2311
|
+
`;
|
|
2312
|
+
};
|
|
2313
|
+
var isHydrationTarget = TARGET === "react";
|
|
2314
|
+
var getPersonalizationScript = (variants, blockId, locale) => {
|
|
2315
|
+
return `window.${BUILDER_IO_PERSONALIZATION_SCRIPT_FN_NAME}(${JSON.stringify(variants)}, "${blockId}", ${isHydrationTarget}${locale ? `, "${locale}"` : ""})`;
|
|
2316
|
+
};
|
|
2317
|
+
var getUpdateVisibilityStylesScript = (variants, blockId, locale) => {
|
|
2318
|
+
return `window.${UPDATE_VARIANT_VISIBILITY_SCRIPT_FN_NAME}(${JSON.stringify(variants)}, "${blockId}", ${isHydrationTarget}${locale ? `, "${locale}"` : ""})`;
|
|
2319
|
+
};
|
|
2320
|
+
|
|
2142
2321
|
// src/helpers/url.ts
|
|
2143
2322
|
var getTopLevelDomain = (host) => {
|
|
2144
2323
|
if (host === "localhost" || host === "127.0.0.1") {
|
|
@@ -3085,7 +3264,8 @@ var componentInfo6 = {
|
|
|
3085
3264
|
name: "PersonalizationContainer",
|
|
3086
3265
|
shouldReceiveBuilderProps: {
|
|
3087
3266
|
builderBlock: true,
|
|
3088
|
-
builderContext: true
|
|
3267
|
+
builderContext: true,
|
|
3268
|
+
builderComponents: true
|
|
3089
3269
|
},
|
|
3090
3270
|
noWrap: true,
|
|
3091
3271
|
image: "https://cdn.builder.io/api/v1/image/assets%2FYJIGb4i01jvw0SRdL5Bt%2F37229ed30d8c41dfb10b8cca1992053a",
|
|
@@ -3141,199 +3321,6 @@ function isPreviewing(_search) {
|
|
|
3141
3321
|
return Boolean(normalizedSearch.indexOf("builder.preview=") !== -1);
|
|
3142
3322
|
}
|
|
3143
3323
|
|
|
3144
|
-
// src/blocks/personalization-container/helpers/inlined-fns.ts
|
|
3145
|
-
function filterWithCustomTargeting(userAttributes, query, startDate, endDate) {
|
|
3146
|
-
function isString(val) {
|
|
3147
|
-
return typeof val === "string";
|
|
3148
|
-
}
|
|
3149
|
-
function isNumber(val) {
|
|
3150
|
-
return typeof val === "number";
|
|
3151
|
-
}
|
|
3152
|
-
function objectMatchesQuery(userattr, query2) {
|
|
3153
|
-
const result = (() => {
|
|
3154
|
-
const property = query2.property;
|
|
3155
|
-
const operator = query2.operator;
|
|
3156
|
-
let testValue = query2.value;
|
|
3157
|
-
if (query2 && query2.property === "urlPath" && query2.value && typeof query2.value === "string" && query2.value !== "/" && query2.value.endsWith("/")) {
|
|
3158
|
-
testValue = query2.value.slice(0, -1);
|
|
3159
|
-
}
|
|
3160
|
-
if (!(property && operator)) {
|
|
3161
|
-
return true;
|
|
3162
|
-
}
|
|
3163
|
-
if (Array.isArray(testValue)) {
|
|
3164
|
-
if (operator === "isNot") {
|
|
3165
|
-
return testValue.every((val) => objectMatchesQuery(userattr, {
|
|
3166
|
-
property,
|
|
3167
|
-
operator,
|
|
3168
|
-
value: val
|
|
3169
|
-
}));
|
|
3170
|
-
}
|
|
3171
|
-
return !!testValue.find((val) => objectMatchesQuery(userattr, {
|
|
3172
|
-
property,
|
|
3173
|
-
operator,
|
|
3174
|
-
value: val
|
|
3175
|
-
}));
|
|
3176
|
-
}
|
|
3177
|
-
const value = userattr[property];
|
|
3178
|
-
if (Array.isArray(value)) {
|
|
3179
|
-
return value.includes(testValue);
|
|
3180
|
-
}
|
|
3181
|
-
switch (operator) {
|
|
3182
|
-
case "is":
|
|
3183
|
-
return value === testValue;
|
|
3184
|
-
case "isNot":
|
|
3185
|
-
return value !== testValue;
|
|
3186
|
-
case "contains":
|
|
3187
|
-
return (isString(value) || Array.isArray(value)) && value.includes(String(testValue));
|
|
3188
|
-
case "startsWith":
|
|
3189
|
-
return isString(value) && value.startsWith(String(testValue));
|
|
3190
|
-
case "endsWith":
|
|
3191
|
-
return isString(value) && value.endsWith(String(testValue));
|
|
3192
|
-
case "greaterThan":
|
|
3193
|
-
return isNumber(value) && isNumber(testValue) && value > testValue;
|
|
3194
|
-
case "lessThan":
|
|
3195
|
-
return isNumber(value) && isNumber(testValue) && value < testValue;
|
|
3196
|
-
case "greaterThanOrEqualTo":
|
|
3197
|
-
return isNumber(value) && isNumber(testValue) && value >= testValue;
|
|
3198
|
-
case "lessThanOrEqualTo":
|
|
3199
|
-
return isNumber(value) && isNumber(testValue) && value <= testValue;
|
|
3200
|
-
default:
|
|
3201
|
-
return false;
|
|
3202
|
-
}
|
|
3203
|
-
})();
|
|
3204
|
-
return result;
|
|
3205
|
-
}
|
|
3206
|
-
const item = {
|
|
3207
|
-
query,
|
|
3208
|
-
startDate,
|
|
3209
|
-
endDate
|
|
3210
|
-
};
|
|
3211
|
-
const now = userAttributes.date && new Date(userAttributes.date) || /* @__PURE__ */ new Date();
|
|
3212
|
-
if (item.startDate && new Date(item.startDate) > now) {
|
|
3213
|
-
return false;
|
|
3214
|
-
} else if (item.endDate && new Date(item.endDate) < now) {
|
|
3215
|
-
return false;
|
|
3216
|
-
}
|
|
3217
|
-
if (!item.query || !item.query.length) {
|
|
3218
|
-
return true;
|
|
3219
|
-
}
|
|
3220
|
-
return item.query.every((filter) => {
|
|
3221
|
-
return objectMatchesQuery(userAttributes, filter);
|
|
3222
|
-
});
|
|
3223
|
-
}
|
|
3224
|
-
var PERSONALIZATION_SCRIPT = `function getPersonalizedVariant(variants, blockId, locale) {
|
|
3225
|
-
if (!navigator.cookieEnabled) {
|
|
3226
|
-
return;
|
|
3227
|
-
}
|
|
3228
|
-
function getCookie(name) {
|
|
3229
|
-
const nameEQ = name + '=';
|
|
3230
|
-
const ca = document.cookie.split(';');
|
|
3231
|
-
for (let i = 0; i < ca.length; i++) {
|
|
3232
|
-
let c = ca[i];
|
|
3233
|
-
while (c.charAt(0) == ' ') c = c.substring(1, c.length);
|
|
3234
|
-
if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length);
|
|
3235
|
-
}
|
|
3236
|
-
return null;
|
|
3237
|
-
}
|
|
3238
|
-
function removeVariants() {
|
|
3239
|
-
variants?.forEach(function (_, index) {
|
|
3240
|
-
document.querySelector('template[data-variant-id="' + blockId + '-' + index + '"]')?.remove();
|
|
3241
|
-
});
|
|
3242
|
-
document.querySelector('script[data-id="variants-script-' + blockId + '"]')?.remove();
|
|
3243
|
-
document.querySelector('style[data-id="variants-styles-' + blockId + '"]')?.remove();
|
|
3244
|
-
}
|
|
3245
|
-
const attributes = JSON.parse(getCookie('builder.userAttributes') || '{}');
|
|
3246
|
-
if (locale) {
|
|
3247
|
-
attributes.locale = locale;
|
|
3248
|
-
}
|
|
3249
|
-
const winningVariantIndex = variants?.findIndex(function (variant) {
|
|
3250
|
-
return filterWithCustomTargeting(attributes, variant.query, variant.startDate, variant.endDate);
|
|
3251
|
-
});
|
|
3252
|
-
const isDebug = location.href.includes('builder.debug=true');
|
|
3253
|
-
if (isDebug) {
|
|
3254
|
-
console.debug('PersonalizationContainer', {
|
|
3255
|
-
attributes,
|
|
3256
|
-
variants,
|
|
3257
|
-
winningVariantIndex
|
|
3258
|
-
});
|
|
3259
|
-
}
|
|
3260
|
-
if (winningVariantIndex !== -1) {
|
|
3261
|
-
const winningVariant = document.querySelector('template[data-variant-id="' + blockId + '-' + winningVariantIndex + '"]');
|
|
3262
|
-
if (winningVariant) {
|
|
3263
|
-
const parentNode = winningVariant.parentNode;
|
|
3264
|
-
if (parentNode) {
|
|
3265
|
-
const newParent = parentNode.cloneNode(false);
|
|
3266
|
-
newParent.appendChild(winningVariant.content.firstChild);
|
|
3267
|
-
newParent.appendChild(winningVariant.content.lastChild);
|
|
3268
|
-
parentNode.parentNode?.replaceChild(newParent, parentNode);
|
|
3269
|
-
}
|
|
3270
|
-
if (isDebug) {
|
|
3271
|
-
console.debug('PersonalizationContainer', 'Winning variant Replaced:', winningVariant);
|
|
3272
|
-
}
|
|
3273
|
-
}
|
|
3274
|
-
} else if (variants && variants.length > 0) {
|
|
3275
|
-
removeVariants();
|
|
3276
|
-
}
|
|
3277
|
-
}`;
|
|
3278
|
-
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}";
|
|
3279
|
-
|
|
3280
|
-
// src/blocks/personalization-container/helpers.ts
|
|
3281
|
-
function checkShouldRenderVariants(variants, canTrack) {
|
|
3282
|
-
const hasVariants = variants && variants.length > 0;
|
|
3283
|
-
if (TARGET === "reactNative")
|
|
3284
|
-
return false;
|
|
3285
|
-
if (!hasVariants)
|
|
3286
|
-
return false;
|
|
3287
|
-
if (!canTrack)
|
|
3288
|
-
return false;
|
|
3289
|
-
if (TARGET === "vue" || TARGET === "svelte")
|
|
3290
|
-
return true;
|
|
3291
|
-
if (isBrowser())
|
|
3292
|
-
return false;
|
|
3293
|
-
return true;
|
|
3294
|
-
}
|
|
3295
|
-
function getBlocksToRender({
|
|
3296
|
-
variants,
|
|
3297
|
-
previewingIndex,
|
|
3298
|
-
isHydrated,
|
|
3299
|
-
filteredVariants,
|
|
3300
|
-
fallbackBlocks
|
|
3301
|
-
}) {
|
|
3302
|
-
const fallback = {
|
|
3303
|
-
blocks: fallbackBlocks ?? [],
|
|
3304
|
-
path: "this.children"
|
|
3305
|
-
};
|
|
3306
|
-
if (isHydrated && isEditing()) {
|
|
3307
|
-
if (typeof previewingIndex === "number" && previewingIndex < (variants?.length ?? 0)) {
|
|
3308
|
-
const variant = variants[previewingIndex];
|
|
3309
|
-
return {
|
|
3310
|
-
blocks: variant.blocks,
|
|
3311
|
-
path: `component.options.variants.${previewingIndex}.blocks`
|
|
3312
|
-
};
|
|
3313
|
-
}
|
|
3314
|
-
return fallback;
|
|
3315
|
-
}
|
|
3316
|
-
if (isBrowser()) {
|
|
3317
|
-
const winningVariant = filteredVariants?.[0];
|
|
3318
|
-
if (winningVariant) {
|
|
3319
|
-
return {
|
|
3320
|
-
blocks: winningVariant.blocks,
|
|
3321
|
-
path: `component.options.variants.${variants?.indexOf(winningVariant)}.blocks`
|
|
3322
|
-
};
|
|
3323
|
-
}
|
|
3324
|
-
}
|
|
3325
|
-
return fallback;
|
|
3326
|
-
}
|
|
3327
|
-
var getPersonalizationScript = (variants, blockId, locale) => {
|
|
3328
|
-
return `
|
|
3329
|
-
(function() {
|
|
3330
|
-
${FILTER_WITH_CUSTOM_TARGETING_SCRIPT}
|
|
3331
|
-
${PERSONALIZATION_SCRIPT}
|
|
3332
|
-
getPersonalizedVariant(${JSON.stringify(variants)}, "${blockId}"${locale ? `, "${locale}"` : ""})
|
|
3333
|
-
})();
|
|
3334
|
-
`;
|
|
3335
|
-
};
|
|
3336
|
-
|
|
3337
3324
|
// src/blocks/personalization-container/personalization-container.tsx
|
|
3338
3325
|
function PersonalizationContainer(props) {
|
|
3339
3326
|
const [userAttributes, setUserAttributes] = createSignal10(
|
|
@@ -3346,6 +3333,13 @@ function PersonalizationContainer(props) {
|
|
|
3346
3333
|
props.builderContext?.rootState?.locale
|
|
3347
3334
|
)
|
|
3348
3335
|
);
|
|
3336
|
+
const [updateVisibilityStylesScript, setUpdateVisibilityStylesScript] = createSignal10(
|
|
3337
|
+
getUpdateVisibilityStylesScript(
|
|
3338
|
+
props.variants,
|
|
3339
|
+
props.builderBlock?.id || "none",
|
|
3340
|
+
props.builderContext?.rootState?.locale
|
|
3341
|
+
)
|
|
3342
|
+
);
|
|
3349
3343
|
const [unsubscribers, setUnsubscribers] = createSignal10([]);
|
|
3350
3344
|
const [shouldRenderVariants, setShouldRenderVariants] = createSignal10(
|
|
3351
3345
|
checkShouldRenderVariants(
|
|
@@ -3353,7 +3347,14 @@ function PersonalizationContainer(props) {
|
|
|
3353
3347
|
getDefaultCanTrack(props.builderContext?.canTrack)
|
|
3354
3348
|
)
|
|
3355
3349
|
);
|
|
3356
|
-
const [
|
|
3350
|
+
const [shouldResetVariants, setShouldResetVariants] = createSignal10(false);
|
|
3351
|
+
const attrs = createMemo10(() => {
|
|
3352
|
+
return {
|
|
3353
|
+
...props.attributes,
|
|
3354
|
+
...{},
|
|
3355
|
+
[getClassPropName()]: `builder-personalization-container ${props.attributes[getClassPropName()] || ""}`
|
|
3356
|
+
};
|
|
3357
|
+
});
|
|
3357
3358
|
const filteredVariants = createMemo10(() => {
|
|
3358
3359
|
return (props.variants || []).filter((variant) => {
|
|
3359
3360
|
return filterWithCustomTargeting(
|
|
@@ -3373,22 +3374,22 @@ function PersonalizationContainer(props) {
|
|
|
3373
3374
|
return getBlocksToRender({
|
|
3374
3375
|
variants: props.variants,
|
|
3375
3376
|
fallbackBlocks: props.builderBlock?.children,
|
|
3376
|
-
isHydrated:
|
|
3377
|
+
isHydrated: shouldResetVariants(),
|
|
3377
3378
|
filteredVariants: filteredVariants(),
|
|
3378
3379
|
previewingIndex: props.previewingIndex
|
|
3379
3380
|
});
|
|
3380
3381
|
});
|
|
3381
3382
|
const hideVariantsStyleString = createMemo10(() => {
|
|
3382
3383
|
return (props.variants || []).map(
|
|
3383
|
-
(_, index) => `[data-variant-id="${props.builderBlock?.id}-${index}"] { display: none; } `
|
|
3384
|
+
(_, index) => `div[data-variant-id="${props.builderBlock?.id}-${index}"] { display: none !important; } `
|
|
3384
3385
|
).join("");
|
|
3385
3386
|
});
|
|
3386
3387
|
let rootRef;
|
|
3387
3388
|
onMount5(() => {
|
|
3388
|
-
|
|
3389
|
+
setShouldResetVariants(true);
|
|
3389
3390
|
const unsub = userAttributesService.subscribeOnUserAttributesChange(
|
|
3390
|
-
(
|
|
3391
|
-
setUserAttributes(
|
|
3391
|
+
(attrs2) => {
|
|
3392
|
+
setUserAttributes(attrs2);
|
|
3392
3393
|
}
|
|
3393
3394
|
);
|
|
3394
3395
|
if (!(isEditing() || isPreviewing())) {
|
|
@@ -3397,7 +3398,7 @@ function PersonalizationContainer(props) {
|
|
|
3397
3398
|
rootRef.dispatchEvent(
|
|
3398
3399
|
new CustomEvent("builder.variantLoaded", {
|
|
3399
3400
|
detail: {
|
|
3400
|
-
variant: variant ||
|
|
3401
|
+
variant: variant || DEFAULT_INDEX,
|
|
3401
3402
|
content: props.builderContext?.content
|
|
3402
3403
|
},
|
|
3403
3404
|
bubbles: true
|
|
@@ -3409,7 +3410,7 @@ function PersonalizationContainer(props) {
|
|
|
3409
3410
|
rootRef.dispatchEvent(
|
|
3410
3411
|
new CustomEvent("builder.variantDisplayed", {
|
|
3411
3412
|
detail: {
|
|
3412
|
-
variant: variant ||
|
|
3413
|
+
variant: variant || DEFAULT_INDEX,
|
|
3413
3414
|
content: props.builderContext?.content
|
|
3414
3415
|
},
|
|
3415
3416
|
bubbles: true
|
|
@@ -3423,39 +3424,72 @@ function PersonalizationContainer(props) {
|
|
|
3423
3424
|
}
|
|
3424
3425
|
unsubscribers().push(unsub);
|
|
3425
3426
|
});
|
|
3426
|
-
return <><div
|
|
3427
|
-
|
|
3428
|
-
|
|
3429
|
-
|
|
3430
|
-
>
|
|
3431
|
-
<Show10 when={shouldRenderVariants()}>
|
|
3432
|
-
<For6 each={props.variants}>{(variant, _index) => {
|
|
3433
|
-
const index = _index();
|
|
3434
|
-
return <template
|
|
3435
|
-
key={index}
|
|
3436
|
-
data-variant-id={`${props.builderBlock?.id}-${index}`}
|
|
3437
|
-
><Blocks_default
|
|
3438
|
-
blocks={variant.blocks}
|
|
3439
|
-
parent={props.builderBlock?.id}
|
|
3440
|
-
path={`component.options.variants.${index}.blocks`}
|
|
3441
|
-
/></template>;
|
|
3442
|
-
}}</For6>
|
|
3443
|
-
<Inlined_styles_default
|
|
3444
|
-
nonce={props.builderContext?.nonce || ""}
|
|
3445
|
-
styles={hideVariantsStyleString()}
|
|
3446
|
-
id={`variants-styles-${props.builderBlock?.id}`}
|
|
3447
|
-
/>
|
|
3448
|
-
<Inlined_script_default
|
|
3449
|
-
nonce={props.builderContext?.nonce || ""}
|
|
3450
|
-
scriptStr={scriptStr()}
|
|
3451
|
-
id={`variants-script-${props.builderBlock?.id}`}
|
|
3452
|
-
/>
|
|
3453
|
-
</Show10>
|
|
3454
|
-
<Blocks_default
|
|
3427
|
+
return <><div ref={rootRef} {...attrs()}>
|
|
3428
|
+
<Show10
|
|
3429
|
+
when={shouldResetVariants() && SDKS_REQUIRING_RESET_APPROACH.includes(TARGET)}
|
|
3430
|
+
><Blocks_default
|
|
3455
3431
|
blocks={blocksToRender().blocks}
|
|
3456
3432
|
parent={props.builderBlock?.id}
|
|
3457
3433
|
path={blocksToRender().path}
|
|
3458
|
-
|
|
3434
|
+
context={props.builderContext}
|
|
3435
|
+
registeredComponents={props.builderComponents}
|
|
3436
|
+
BlocksWrapperProps={{
|
|
3437
|
+
...props.builderContext?.BlocksWrapperProps,
|
|
3438
|
+
"data-variant-id": `${props.builderBlock?.id}-${blocksToRender().index}`
|
|
3439
|
+
}}
|
|
3440
|
+
/></Show10>
|
|
3441
|
+
<Show10
|
|
3442
|
+
when={!shouldResetVariants() && SDKS_REQUIRING_RESET_APPROACH.includes(TARGET) || !SDKS_REQUIRING_RESET_APPROACH.includes(TARGET)}
|
|
3443
|
+
>
|
|
3444
|
+
<Show10 when={shouldRenderVariants()}>
|
|
3445
|
+
<Inlined_styles_default
|
|
3446
|
+
nonce={props.builderContext?.nonce || ""}
|
|
3447
|
+
styles={hideVariantsStyleString()}
|
|
3448
|
+
id={`variants-styles-${props.builderBlock?.id}`}
|
|
3449
|
+
/>
|
|
3450
|
+
<Inlined_script_default
|
|
3451
|
+
nonce={props.builderContext?.nonce || ""}
|
|
3452
|
+
scriptStr={updateVisibilityStylesScript()}
|
|
3453
|
+
id={`variants-visibility-script-${props.builderBlock?.id}`}
|
|
3454
|
+
/>
|
|
3455
|
+
<For6 each={props.variants}>{(variant, _index) => {
|
|
3456
|
+
const index = _index();
|
|
3457
|
+
return <Blocks_default
|
|
3458
|
+
key={`${props.builderBlock?.id}-${index}`}
|
|
3459
|
+
BlocksWrapperProps={{
|
|
3460
|
+
...props.builderContext?.BlocksWrapperProps,
|
|
3461
|
+
"aria-hidden": true,
|
|
3462
|
+
hidden: true,
|
|
3463
|
+
"data-variant-id": `${props.builderBlock?.id}-${index}`
|
|
3464
|
+
}}
|
|
3465
|
+
blocks={variant.blocks}
|
|
3466
|
+
parent={props.builderBlock?.id}
|
|
3467
|
+
path={`component.options.variants.${index}.blocks`}
|
|
3468
|
+
context={props.builderContext}
|
|
3469
|
+
registeredComponents={props.builderComponents}
|
|
3470
|
+
><Inlined_script_default
|
|
3471
|
+
nonce={props.builderContext?.nonce || ""}
|
|
3472
|
+
scriptStr={scriptStr()}
|
|
3473
|
+
id={`variants-script-${props.builderBlock?.id}-${index}`}
|
|
3474
|
+
/></Blocks_default>;
|
|
3475
|
+
}}</For6>
|
|
3476
|
+
</Show10>
|
|
3477
|
+
<Blocks_default
|
|
3478
|
+
blocks={blocksToRender().blocks}
|
|
3479
|
+
parent={props.builderBlock?.id}
|
|
3480
|
+
path={blocksToRender().path}
|
|
3481
|
+
context={props.builderContext}
|
|
3482
|
+
registeredComponents={props.builderComponents}
|
|
3483
|
+
BlocksWrapperProps={{
|
|
3484
|
+
...props.builderContext?.BlocksWrapperProps,
|
|
3485
|
+
"data-variant-id": `${props.builderBlock?.id}-${blocksToRender().index}`
|
|
3486
|
+
}}
|
|
3487
|
+
><Show10 when={shouldRenderVariants()}><Inlined_script_default
|
|
3488
|
+
nonce={props.builderContext?.nonce || ""}
|
|
3489
|
+
scriptStr={scriptStr()}
|
|
3490
|
+
id={`variants-script-${props.builderBlock?.id}-${DEFAULT_INDEX}`}
|
|
3491
|
+
/></Show10></Blocks_default>
|
|
3492
|
+
</Show10>
|
|
3459
3493
|
</div></>;
|
|
3460
3494
|
}
|
|
3461
3495
|
var personalization_container_default = PersonalizationContainer;
|
|
@@ -3847,7 +3881,7 @@ var componentInfo12 = {
|
|
|
3847
3881
|
};
|
|
3848
3882
|
|
|
3849
3883
|
// src/blocks/custom-code/custom-code.tsx
|
|
3850
|
-
import { onMount as onMount6, on as
|
|
3884
|
+
import { onMount as onMount6, on as on6, createEffect as createEffect6, createMemo as createMemo12, createSignal as createSignal12 } from "solid-js";
|
|
3851
3885
|
function CustomCode(props) {
|
|
3852
3886
|
const [scriptsInserted, setScriptsInserted] = createSignal12([]);
|
|
3853
3887
|
const [scriptsRun, setScriptsRun] = createSignal12([]);
|
|
@@ -3897,7 +3931,7 @@ function CustomCode(props) {
|
|
|
3897
3931
|
runScripts();
|
|
3898
3932
|
}
|
|
3899
3933
|
}
|
|
3900
|
-
|
|
3934
|
+
createEffect6(on6(() => [onUpdateFn_0_props_code()], onUpdateFn_0));
|
|
3901
3935
|
return <><div
|
|
3902
3936
|
class={"builder-custom-code" + (props.replaceNodes ? " replace-nodes" : "")}
|
|
3903
3937
|
ref={elementRef}
|
|
@@ -3925,7 +3959,7 @@ var componentInfo13 = {
|
|
|
3925
3959
|
};
|
|
3926
3960
|
|
|
3927
3961
|
// src/blocks/embed/embed.tsx
|
|
3928
|
-
import { on as
|
|
3962
|
+
import { on as on7, createEffect as createEffect7, createMemo as createMemo13, createSignal as createSignal13 } from "solid-js";
|
|
3929
3963
|
|
|
3930
3964
|
// src/blocks/embed/helpers.ts
|
|
3931
3965
|
var SCRIPT_MIME_TYPES = ["text/javascript", "application/javascript", "application/ecmascript"];
|
|
@@ -3967,8 +4001,8 @@ function Embed(props) {
|
|
|
3967
4001
|
findAndRunScripts();
|
|
3968
4002
|
}
|
|
3969
4003
|
}
|
|
3970
|
-
|
|
3971
|
-
|
|
4004
|
+
createEffect7(
|
|
4005
|
+
on7(() => [onUpdateFn_0_elem(), onUpdateFn_0_ranInitFn__()], onUpdateFn_0)
|
|
3972
4006
|
);
|
|
3973
4007
|
return <><div class="builder-embed" ref={elem} innerHTML={props.content} /></>;
|
|
3974
4008
|
}
|
|
@@ -4978,7 +5012,7 @@ var getDefaultRegisteredComponents = () => [{
|
|
|
4978
5012
|
}, {
|
|
4979
5013
|
component: text_default,
|
|
4980
5014
|
...componentInfo11
|
|
4981
|
-
}, ...TARGET
|
|
5015
|
+
}, ...SDKS_SUPPORTING_PERSONALIZATION.includes(TARGET) ? [{
|
|
4982
5016
|
component: personalization_container_default,
|
|
4983
5017
|
...componentInfo6
|
|
4984
5018
|
}] : [], ...TARGET === "rsc" ? [] : [{
|
|
@@ -5015,7 +5049,7 @@ var UPDATE_VARIANT_VISIBILITY_SCRIPT = "function updateVariantVisibility(variant
|
|
|
5015
5049
|
|
|
5016
5050
|
// src/components/content-variants/helpers.ts
|
|
5017
5051
|
var UPDATE_COOKIES_AND_STYLES_SCRIPT_NAME = "builderIoAbTest";
|
|
5018
|
-
var
|
|
5052
|
+
var UPDATE_VARIANT_VISIBILITY_SCRIPT_FN_NAME2 = "builderIoRenderContent";
|
|
5019
5053
|
var getVariants = (content) => Object.values(content?.variations || {}).map((variant) => ({
|
|
5020
5054
|
...variant,
|
|
5021
5055
|
testVariationId: variant.id,
|
|
@@ -5040,28 +5074,28 @@ var checkShouldRenderVariants2 = ({
|
|
|
5040
5074
|
};
|
|
5041
5075
|
var getIsHydrationTarget = (target) => target === "react" || target === "reactNative";
|
|
5042
5076
|
var isAngularSDK = TARGET === "angular";
|
|
5043
|
-
var
|
|
5077
|
+
var isHydrationTarget2 = getIsHydrationTarget(TARGET);
|
|
5044
5078
|
var getInitVariantsFnsScriptString = () => `
|
|
5045
5079
|
window.${UPDATE_COOKIES_AND_STYLES_SCRIPT_NAME} = ${UPDATE_COOKIES_AND_STYLES_SCRIPT}
|
|
5046
|
-
window.${
|
|
5080
|
+
window.${UPDATE_VARIANT_VISIBILITY_SCRIPT_FN_NAME2} = ${UPDATE_VARIANT_VISIBILITY_SCRIPT}
|
|
5047
5081
|
`;
|
|
5048
5082
|
var getUpdateCookieAndStylesScript = (variants, contentId) => `
|
|
5049
5083
|
window.${UPDATE_COOKIES_AND_STYLES_SCRIPT_NAME}(
|
|
5050
|
-
"${contentId}",${JSON.stringify(variants)}, ${
|
|
5084
|
+
"${contentId}",${JSON.stringify(variants)}, ${isHydrationTarget2}, ${isAngularSDK}
|
|
5051
5085
|
)`;
|
|
5052
5086
|
var getUpdateVariantVisibilityScript = ({
|
|
5053
5087
|
contentId,
|
|
5054
5088
|
variationId
|
|
5055
|
-
}) => `window.${
|
|
5056
|
-
"${variationId}", "${contentId}", ${
|
|
5089
|
+
}) => `window.${UPDATE_VARIANT_VISIBILITY_SCRIPT_FN_NAME2}(
|
|
5090
|
+
"${variationId}", "${contentId}", ${isHydrationTarget2}
|
|
5057
5091
|
)`;
|
|
5058
5092
|
|
|
5059
5093
|
// src/components/content/components/enable-editor.tsx
|
|
5060
5094
|
import {
|
|
5061
5095
|
Show as Show14,
|
|
5062
5096
|
onMount as onMount8,
|
|
5063
|
-
on as
|
|
5064
|
-
createEffect as
|
|
5097
|
+
on as on8,
|
|
5098
|
+
createEffect as createEffect8,
|
|
5065
5099
|
createMemo as createMemo16,
|
|
5066
5100
|
createSignal as createSignal16
|
|
5067
5101
|
} from "solid-js";
|
|
@@ -5073,7 +5107,7 @@ function getPreviewContent(_searchParams) {
|
|
|
5073
5107
|
}
|
|
5074
5108
|
|
|
5075
5109
|
// src/constants/sdk-version.ts
|
|
5076
|
-
var SDK_VERSION = "4.0.
|
|
5110
|
+
var SDK_VERSION = "4.0.9";
|
|
5077
5111
|
|
|
5078
5112
|
// src/helpers/sdk-headers.ts
|
|
5079
5113
|
var getSdkHeaders = () => ({
|
|
@@ -6165,15 +6199,15 @@ function EnableEditor(props) {
|
|
|
6165
6199
|
mergeNewContent(props.content);
|
|
6166
6200
|
}
|
|
6167
6201
|
}
|
|
6168
|
-
|
|
6202
|
+
createEffect8(on8(() => [onUpdateFn_0_props_content()], onUpdateFn_0));
|
|
6169
6203
|
const onUpdateFn_1_props_builderContextSignal_rootState = createMemo16(
|
|
6170
6204
|
() => props.builderContextSignal.rootState
|
|
6171
6205
|
);
|
|
6172
6206
|
function onUpdateFn_1() {
|
|
6173
6207
|
emitStateUpdate();
|
|
6174
6208
|
}
|
|
6175
|
-
|
|
6176
|
-
|
|
6209
|
+
createEffect8(
|
|
6210
|
+
on8(
|
|
6177
6211
|
() => [onUpdateFn_1_props_builderContextSignal_rootState()],
|
|
6178
6212
|
onUpdateFn_1
|
|
6179
6213
|
)
|
|
@@ -6184,7 +6218,7 @@ function EnableEditor(props) {
|
|
|
6184
6218
|
mergeNewRootState(props.data);
|
|
6185
6219
|
}
|
|
6186
6220
|
}
|
|
6187
|
-
|
|
6221
|
+
createEffect8(on8(() => [onUpdateFn_2_props_data()], onUpdateFn_2));
|
|
6188
6222
|
const onUpdateFn_3_props_locale = createMemo16(() => props.locale);
|
|
6189
6223
|
function onUpdateFn_3() {
|
|
6190
6224
|
if (props.locale) {
|
|
@@ -6193,7 +6227,7 @@ function EnableEditor(props) {
|
|
|
6193
6227
|
});
|
|
6194
6228
|
}
|
|
6195
6229
|
}
|
|
6196
|
-
|
|
6230
|
+
createEffect8(on8(() => [onUpdateFn_3_props_locale()], onUpdateFn_3));
|
|
6197
6231
|
return <><builder_context_default.Provider value={props.builderContextSignal}><Show14
|
|
6198
6232
|
when={props.builderContextSignal.content || needsElementRefDivForEditing()}
|
|
6199
6233
|
><Dynamic5
|
|
@@ -6439,11 +6473,18 @@ function ContentVariants(props) {
|
|
|
6439
6473
|
setShouldRenderVariants(false);
|
|
6440
6474
|
});
|
|
6441
6475
|
return <><>
|
|
6442
|
-
<Show16 when={!props.isNestedRender && TARGET !== "reactNative"}
|
|
6443
|
-
|
|
6444
|
-
|
|
6445
|
-
|
|
6446
|
-
|
|
6476
|
+
<Show16 when={!props.isNestedRender && TARGET !== "reactNative"}>
|
|
6477
|
+
<Inlined_script_default
|
|
6478
|
+
id="builderio-init-variants-fns"
|
|
6479
|
+
scriptStr={getInitVariantsFnsScriptString()}
|
|
6480
|
+
nonce={props.nonce || ""}
|
|
6481
|
+
/>
|
|
6482
|
+
<Show16 when={SDKS_SUPPORTING_PERSONALIZATION.includes(TARGET)}><Inlined_script_default
|
|
6483
|
+
id="builderio-init-personalization-variants-fns"
|
|
6484
|
+
nonce={props.nonce || ""}
|
|
6485
|
+
scriptStr={getInitPersonalizationVariantsFnsScriptString()}
|
|
6486
|
+
/></Show16>
|
|
6487
|
+
</Show16>
|
|
6447
6488
|
<Show16 when={shouldRenderVariants()}>
|
|
6448
6489
|
<Inlined_styles_default
|
|
6449
6490
|
id="builderio-variants"
|
|
@@ -6539,6 +6580,7 @@ var fetchSymbolContent = async ({
|
|
|
6539
6580
|
// src/blocks/symbol/symbol.tsx
|
|
6540
6581
|
function Symbol(props) {
|
|
6541
6582
|
const [contentToUse, setContentToUse] = createSignal20(props.symbol?.content);
|
|
6583
|
+
const [symbolEntry, setSymbolEntry] = createSignal20(props.symbol?.entry);
|
|
6542
6584
|
const blocksWrapper = createMemo20(() => {
|
|
6543
6585
|
return "div";
|
|
6544
6586
|
});
|
|
@@ -6554,7 +6596,7 @@ function Symbol(props) {
|
|
|
6554
6596
|
].filter(Boolean).join(" ");
|
|
6555
6597
|
});
|
|
6556
6598
|
function setContent() {
|
|
6557
|
-
if (contentToUse())
|
|
6599
|
+
if (contentToUse() && symbolEntry() === props.symbol?.entry)
|
|
6558
6600
|
return;
|
|
6559
6601
|
fetchSymbolContent({
|
|
6560
6602
|
symbol: props.symbol,
|
|
@@ -6562,6 +6604,7 @@ function Symbol(props) {
|
|
|
6562
6604
|
}).then((newContent) => {
|
|
6563
6605
|
if (newContent) {
|
|
6564
6606
|
setContentToUse(newContent);
|
|
6607
|
+
setSymbolEntry(props.symbol?.entry);
|
|
6565
6608
|
}
|
|
6566
6609
|
});
|
|
6567
6610
|
}
|
|
@@ -6571,7 +6614,7 @@ function Symbol(props) {
|
|
|
6571
6614
|
function onUpdateFn_0() {
|
|
6572
6615
|
setContent();
|
|
6573
6616
|
}
|
|
6574
|
-
|
|
6617
|
+
createEffect9(on9(() => [onUpdateFn_0_props_symbol()], onUpdateFn_0));
|
|
6575
6618
|
return <><div class={className()} {...{}} {...props.attributes} {...{}}><Content_variants_default
|
|
6576
6619
|
nonce={props.builderContext.nonce}
|
|
6577
6620
|
isNestedRender={true}
|