@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.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { delegateEvents, createComponent, spread, mergeProps, insert, effect, setAttribute, className, style, template, use, Dynamic
|
|
1
|
+
import { delegateEvents, createComponent, memo, spread, mergeProps, insert, effect, setAttribute, className, style, template, use, Dynamic } from 'solid-js/web';
|
|
2
2
|
import { createContext, useContext, Show, For, createMemo, onMount, createSignal, createEffect, on } from 'solid-js';
|
|
3
3
|
import { createRequire } from 'node:module';
|
|
4
4
|
|
|
@@ -1387,6 +1387,7 @@ var awaiter_default = Awaiter;
|
|
|
1387
1387
|
|
|
1388
1388
|
// src/components/block/components/interactive-element.tsx
|
|
1389
1389
|
function InteractiveElement(props) {
|
|
1390
|
+
createSignal(0);
|
|
1390
1391
|
const attributes = createMemo(() => {
|
|
1391
1392
|
return props.includeBlockProps ? {
|
|
1392
1393
|
...getBlockProperties({
|
|
@@ -1405,6 +1406,11 @@ function InteractiveElement(props) {
|
|
|
1405
1406
|
const targetWrapperProps = createMemo(() => {
|
|
1406
1407
|
return props.wrapperProps;
|
|
1407
1408
|
});
|
|
1409
|
+
const onUpdateFn_0_props_wrapperProps = createMemo(() => props.wrapperProps);
|
|
1410
|
+
const onUpdateFn_0_props_block__component__options = createMemo(() => props.block?.component?.options);
|
|
1411
|
+
function onUpdateFn_0() {
|
|
1412
|
+
}
|
|
1413
|
+
createEffect(on(() => [onUpdateFn_0_props_wrapperProps(), onUpdateFn_0_props_block__component__options()], onUpdateFn_0));
|
|
1408
1414
|
return createComponent(Show, {
|
|
1409
1415
|
get fallback() {
|
|
1410
1416
|
return createComponent(Dynamic, mergeProps(targetWrapperProps, {
|
|
@@ -1831,7 +1837,7 @@ function Block(props) {
|
|
|
1831
1837
|
});
|
|
1832
1838
|
}
|
|
1833
1839
|
var block_default = Block;
|
|
1834
|
-
var _tmpl$2 = /* @__PURE__ */ template(`<style>.dynamic-
|
|
1840
|
+
var _tmpl$2 = /* @__PURE__ */ template(`<style>.dynamic-450facf4 {
|
|
1835
1841
|
display: flex;
|
|
1836
1842
|
flex-direction: column;
|
|
1837
1843
|
align-items: stretch;
|
|
@@ -1880,7 +1886,7 @@ function BlocksWrapper(props) {
|
|
|
1880
1886
|
createEffect(on(() => [onUpdateFn_0_props_blocks()], onUpdateFn_0));
|
|
1881
1887
|
return [createComponent(Dynamic, mergeProps({
|
|
1882
1888
|
get ["class"]() {
|
|
1883
|
-
return className() + " dynamic-
|
|
1889
|
+
return className() + " dynamic-450facf4";
|
|
1884
1890
|
},
|
|
1885
1891
|
ref(r$) {
|
|
1886
1892
|
const _ref$ = blocksWrapperRef;
|
|
@@ -1927,17 +1933,17 @@ function Blocks(props) {
|
|
|
1927
1933
|
get styleProp() {
|
|
1928
1934
|
return props.styleProp;
|
|
1929
1935
|
},
|
|
1936
|
+
get BlocksWrapperProps() {
|
|
1937
|
+
return props.BlocksWrapperProps || props.context?.BlocksWrapperProps || builderContext?.BlocksWrapperProps;
|
|
1938
|
+
},
|
|
1930
1939
|
get classNameProp() {
|
|
1931
1940
|
return props.className;
|
|
1932
1941
|
},
|
|
1933
1942
|
get BlocksWrapper() {
|
|
1934
1943
|
return props.context?.BlocksWrapper || builderContext?.BlocksWrapper;
|
|
1935
1944
|
},
|
|
1936
|
-
get BlocksWrapperProps() {
|
|
1937
|
-
return props.context?.BlocksWrapperProps || builderContext?.BlocksWrapperProps;
|
|
1938
|
-
},
|
|
1939
1945
|
get children() {
|
|
1940
|
-
return createComponent(Show, {
|
|
1946
|
+
return [memo(() => props.children), createComponent(Show, {
|
|
1941
1947
|
get when() {
|
|
1942
1948
|
return props.blocks;
|
|
1943
1949
|
},
|
|
@@ -1966,7 +1972,7 @@ function Blocks(props) {
|
|
|
1966
1972
|
}
|
|
1967
1973
|
});
|
|
1968
1974
|
}
|
|
1969
|
-
});
|
|
1975
|
+
})];
|
|
1970
1976
|
}
|
|
1971
1977
|
});
|
|
1972
1978
|
}
|
|
@@ -2391,6 +2397,166 @@ function SectionComponent(props) {
|
|
|
2391
2397
|
}
|
|
2392
2398
|
var section_default = SectionComponent;
|
|
2393
2399
|
|
|
2400
|
+
// src/blocks/personalization-container/helpers/inlined-fns.ts
|
|
2401
|
+
function filterWithCustomTargeting(userAttributes, query, startDate, endDate) {
|
|
2402
|
+
function isString(val) {
|
|
2403
|
+
return typeof val === "string";
|
|
2404
|
+
}
|
|
2405
|
+
function isNumber(val) {
|
|
2406
|
+
return typeof val === "number";
|
|
2407
|
+
}
|
|
2408
|
+
function objectMatchesQuery(userattr, query2) {
|
|
2409
|
+
const result = (() => {
|
|
2410
|
+
const property = query2.property;
|
|
2411
|
+
const operator = query2.operator;
|
|
2412
|
+
let testValue = query2.value;
|
|
2413
|
+
if (query2 && query2.property === "urlPath" && query2.value && typeof query2.value === "string" && query2.value !== "/" && query2.value.endsWith("/")) {
|
|
2414
|
+
testValue = query2.value.slice(0, -1);
|
|
2415
|
+
}
|
|
2416
|
+
if (!(property && operator)) {
|
|
2417
|
+
return true;
|
|
2418
|
+
}
|
|
2419
|
+
if (Array.isArray(testValue)) {
|
|
2420
|
+
if (operator === "isNot") {
|
|
2421
|
+
return testValue.every((val) => objectMatchesQuery(userattr, {
|
|
2422
|
+
property,
|
|
2423
|
+
operator,
|
|
2424
|
+
value: val
|
|
2425
|
+
}));
|
|
2426
|
+
}
|
|
2427
|
+
return !!testValue.find((val) => objectMatchesQuery(userattr, {
|
|
2428
|
+
property,
|
|
2429
|
+
operator,
|
|
2430
|
+
value: val
|
|
2431
|
+
}));
|
|
2432
|
+
}
|
|
2433
|
+
const value = userattr[property];
|
|
2434
|
+
if (Array.isArray(value)) {
|
|
2435
|
+
return value.includes(testValue);
|
|
2436
|
+
}
|
|
2437
|
+
switch (operator) {
|
|
2438
|
+
case "is":
|
|
2439
|
+
return value === testValue;
|
|
2440
|
+
case "isNot":
|
|
2441
|
+
return value !== testValue;
|
|
2442
|
+
case "contains":
|
|
2443
|
+
return (isString(value) || Array.isArray(value)) && value.includes(String(testValue));
|
|
2444
|
+
case "startsWith":
|
|
2445
|
+
return isString(value) && value.startsWith(String(testValue));
|
|
2446
|
+
case "endsWith":
|
|
2447
|
+
return isString(value) && value.endsWith(String(testValue));
|
|
2448
|
+
case "greaterThan":
|
|
2449
|
+
return isNumber(value) && isNumber(testValue) && value > testValue;
|
|
2450
|
+
case "lessThan":
|
|
2451
|
+
return isNumber(value) && isNumber(testValue) && value < testValue;
|
|
2452
|
+
case "greaterThanOrEqualTo":
|
|
2453
|
+
return isNumber(value) && isNumber(testValue) && value >= testValue;
|
|
2454
|
+
case "lessThanOrEqualTo":
|
|
2455
|
+
return isNumber(value) && isNumber(testValue) && value <= testValue;
|
|
2456
|
+
default:
|
|
2457
|
+
return false;
|
|
2458
|
+
}
|
|
2459
|
+
})();
|
|
2460
|
+
return result;
|
|
2461
|
+
}
|
|
2462
|
+
const item = {
|
|
2463
|
+
query,
|
|
2464
|
+
startDate,
|
|
2465
|
+
endDate
|
|
2466
|
+
};
|
|
2467
|
+
const now = userAttributes.date && new Date(userAttributes.date) || /* @__PURE__ */ new Date();
|
|
2468
|
+
if (item.startDate && new Date(item.startDate) > now) {
|
|
2469
|
+
return false;
|
|
2470
|
+
} else if (item.endDate && new Date(item.endDate) < now) {
|
|
2471
|
+
return false;
|
|
2472
|
+
}
|
|
2473
|
+
if (!item.query || !item.query.length) {
|
|
2474
|
+
return true;
|
|
2475
|
+
}
|
|
2476
|
+
return item.query.every((filter) => {
|
|
2477
|
+
return objectMatchesQuery(userAttributes, filter);
|
|
2478
|
+
});
|
|
2479
|
+
}
|
|
2480
|
+
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}";
|
|
2481
|
+
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}";
|
|
2482
|
+
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}";
|
|
2483
|
+
|
|
2484
|
+
// src/blocks/personalization-container/helpers.ts
|
|
2485
|
+
var DEFAULT_INDEX = "default";
|
|
2486
|
+
var FILTER_WITH_CUSTOM_TARGETING_SCRIPT_FN_NAME = "filterWithCustomTargeting";
|
|
2487
|
+
var BUILDER_IO_PERSONALIZATION_SCRIPT_FN_NAME = "builderIoPersonalization";
|
|
2488
|
+
var UPDATE_VARIANT_VISIBILITY_SCRIPT_FN_NAME = "updateVisibilityStylesScript";
|
|
2489
|
+
var SDKS_SUPPORTING_PERSONALIZATION = ["react", "vue", "svelte"];
|
|
2490
|
+
var SDKS_REQUIRING_RESET_APPROACH = ["vue", "svelte"];
|
|
2491
|
+
function checkShouldRenderVariants(variants, canTrack) {
|
|
2492
|
+
const hasVariants = variants && variants.length > 0;
|
|
2493
|
+
if (TARGET === "reactNative")
|
|
2494
|
+
return false;
|
|
2495
|
+
if (!hasVariants)
|
|
2496
|
+
return false;
|
|
2497
|
+
if (!canTrack)
|
|
2498
|
+
return false;
|
|
2499
|
+
if (SDKS_REQUIRING_RESET_APPROACH.includes(TARGET))
|
|
2500
|
+
return true;
|
|
2501
|
+
if (isBrowser())
|
|
2502
|
+
return false;
|
|
2503
|
+
return true;
|
|
2504
|
+
}
|
|
2505
|
+
function getBlocksToRender({
|
|
2506
|
+
variants,
|
|
2507
|
+
previewingIndex,
|
|
2508
|
+
isHydrated,
|
|
2509
|
+
filteredVariants,
|
|
2510
|
+
fallbackBlocks
|
|
2511
|
+
}) {
|
|
2512
|
+
const fallback = {
|
|
2513
|
+
blocks: fallbackBlocks ?? [],
|
|
2514
|
+
path: "this.children",
|
|
2515
|
+
index: DEFAULT_INDEX
|
|
2516
|
+
};
|
|
2517
|
+
if (isHydrated && isEditing()) {
|
|
2518
|
+
if (typeof previewingIndex === "number" && previewingIndex < (variants?.length ?? 0)) {
|
|
2519
|
+
const variant = variants?.[previewingIndex];
|
|
2520
|
+
if (variant) {
|
|
2521
|
+
return {
|
|
2522
|
+
blocks: variant.blocks,
|
|
2523
|
+
path: `variants.${previewingIndex}.blocks`,
|
|
2524
|
+
index: previewingIndex
|
|
2525
|
+
};
|
|
2526
|
+
}
|
|
2527
|
+
}
|
|
2528
|
+
return fallback;
|
|
2529
|
+
}
|
|
2530
|
+
if (isBrowser()) {
|
|
2531
|
+
const winningVariant = filteredVariants?.[0];
|
|
2532
|
+
if (winningVariant && variants) {
|
|
2533
|
+
const variantIndex = variants.indexOf(winningVariant);
|
|
2534
|
+
if (variantIndex !== -1) {
|
|
2535
|
+
return {
|
|
2536
|
+
blocks: winningVariant.blocks,
|
|
2537
|
+
path: `variants.${variantIndex}.blocks`,
|
|
2538
|
+
index: variantIndex
|
|
2539
|
+
};
|
|
2540
|
+
}
|
|
2541
|
+
}
|
|
2542
|
+
}
|
|
2543
|
+
return fallback;
|
|
2544
|
+
}
|
|
2545
|
+
var getInitPersonalizationVariantsFnsScriptString = () => {
|
|
2546
|
+
return `
|
|
2547
|
+
window.${FILTER_WITH_CUSTOM_TARGETING_SCRIPT_FN_NAME} = ${FILTER_WITH_CUSTOM_TARGETING_SCRIPT}
|
|
2548
|
+
window.${BUILDER_IO_PERSONALIZATION_SCRIPT_FN_NAME} = ${PERSONALIZATION_SCRIPT}
|
|
2549
|
+
window.${UPDATE_VARIANT_VISIBILITY_SCRIPT_FN_NAME} = ${UPDATE_VISIBILITY_STYLES_SCRIPT}
|
|
2550
|
+
`;
|
|
2551
|
+
};
|
|
2552
|
+
var isHydrationTarget = TARGET === "react";
|
|
2553
|
+
var getPersonalizationScript = (variants, blockId, locale) => {
|
|
2554
|
+
return `window.${BUILDER_IO_PERSONALIZATION_SCRIPT_FN_NAME}(${JSON.stringify(variants)}, "${blockId}", ${isHydrationTarget}${locale ? `, "${locale}"` : ""})`;
|
|
2555
|
+
};
|
|
2556
|
+
var getUpdateVisibilityStylesScript = (variants, blockId, locale) => {
|
|
2557
|
+
return `window.${UPDATE_VARIANT_VISIBILITY_SCRIPT_FN_NAME}(${JSON.stringify(variants)}, "${blockId}", ${isHydrationTarget}${locale ? `, "${locale}"` : ""})`;
|
|
2558
|
+
};
|
|
2559
|
+
|
|
2394
2560
|
// src/helpers/url.ts
|
|
2395
2561
|
var getTopLevelDomain = (host) => {
|
|
2396
2562
|
if (host === "localhost" || host === "127.0.0.1") {
|
|
@@ -3370,7 +3536,8 @@ var componentInfo6 = {
|
|
|
3370
3536
|
name: "PersonalizationContainer",
|
|
3371
3537
|
shouldReceiveBuilderProps: {
|
|
3372
3538
|
builderBlock: true,
|
|
3373
|
-
builderContext: true
|
|
3539
|
+
builderContext: true,
|
|
3540
|
+
builderComponents: true
|
|
3374
3541
|
},
|
|
3375
3542
|
noWrap: true,
|
|
3376
3543
|
image: "https://cdn.builder.io/api/v1/image/assets%2FYJIGb4i01jvw0SRdL5Bt%2F37229ed30d8c41dfb10b8cca1992053a",
|
|
@@ -3432,208 +3599,22 @@ function isPreviewing(_search) {
|
|
|
3432
3599
|
return Boolean(normalizedSearch.indexOf("builder.preview=") !== -1);
|
|
3433
3600
|
}
|
|
3434
3601
|
|
|
3435
|
-
// src/blocks/personalization-container/helpers/inlined-fns.ts
|
|
3436
|
-
function filterWithCustomTargeting(userAttributes, query, startDate, endDate) {
|
|
3437
|
-
function isString(val) {
|
|
3438
|
-
return typeof val === "string";
|
|
3439
|
-
}
|
|
3440
|
-
function isNumber(val) {
|
|
3441
|
-
return typeof val === "number";
|
|
3442
|
-
}
|
|
3443
|
-
function objectMatchesQuery(userattr, query2) {
|
|
3444
|
-
const result = (() => {
|
|
3445
|
-
const property = query2.property;
|
|
3446
|
-
const operator = query2.operator;
|
|
3447
|
-
let testValue = query2.value;
|
|
3448
|
-
if (query2 && query2.property === "urlPath" && query2.value && typeof query2.value === "string" && query2.value !== "/" && query2.value.endsWith("/")) {
|
|
3449
|
-
testValue = query2.value.slice(0, -1);
|
|
3450
|
-
}
|
|
3451
|
-
if (!(property && operator)) {
|
|
3452
|
-
return true;
|
|
3453
|
-
}
|
|
3454
|
-
if (Array.isArray(testValue)) {
|
|
3455
|
-
if (operator === "isNot") {
|
|
3456
|
-
return testValue.every((val) => objectMatchesQuery(userattr, {
|
|
3457
|
-
property,
|
|
3458
|
-
operator,
|
|
3459
|
-
value: val
|
|
3460
|
-
}));
|
|
3461
|
-
}
|
|
3462
|
-
return !!testValue.find((val) => objectMatchesQuery(userattr, {
|
|
3463
|
-
property,
|
|
3464
|
-
operator,
|
|
3465
|
-
value: val
|
|
3466
|
-
}));
|
|
3467
|
-
}
|
|
3468
|
-
const value = userattr[property];
|
|
3469
|
-
if (Array.isArray(value)) {
|
|
3470
|
-
return value.includes(testValue);
|
|
3471
|
-
}
|
|
3472
|
-
switch (operator) {
|
|
3473
|
-
case "is":
|
|
3474
|
-
return value === testValue;
|
|
3475
|
-
case "isNot":
|
|
3476
|
-
return value !== testValue;
|
|
3477
|
-
case "contains":
|
|
3478
|
-
return (isString(value) || Array.isArray(value)) && value.includes(String(testValue));
|
|
3479
|
-
case "startsWith":
|
|
3480
|
-
return isString(value) && value.startsWith(String(testValue));
|
|
3481
|
-
case "endsWith":
|
|
3482
|
-
return isString(value) && value.endsWith(String(testValue));
|
|
3483
|
-
case "greaterThan":
|
|
3484
|
-
return isNumber(value) && isNumber(testValue) && value > testValue;
|
|
3485
|
-
case "lessThan":
|
|
3486
|
-
return isNumber(value) && isNumber(testValue) && value < testValue;
|
|
3487
|
-
case "greaterThanOrEqualTo":
|
|
3488
|
-
return isNumber(value) && isNumber(testValue) && value >= testValue;
|
|
3489
|
-
case "lessThanOrEqualTo":
|
|
3490
|
-
return isNumber(value) && isNumber(testValue) && value <= testValue;
|
|
3491
|
-
default:
|
|
3492
|
-
return false;
|
|
3493
|
-
}
|
|
3494
|
-
})();
|
|
3495
|
-
return result;
|
|
3496
|
-
}
|
|
3497
|
-
const item = {
|
|
3498
|
-
query,
|
|
3499
|
-
startDate,
|
|
3500
|
-
endDate
|
|
3501
|
-
};
|
|
3502
|
-
const now = userAttributes.date && new Date(userAttributes.date) || /* @__PURE__ */ new Date();
|
|
3503
|
-
if (item.startDate && new Date(item.startDate) > now) {
|
|
3504
|
-
return false;
|
|
3505
|
-
} else if (item.endDate && new Date(item.endDate) < now) {
|
|
3506
|
-
return false;
|
|
3507
|
-
}
|
|
3508
|
-
if (!item.query || !item.query.length) {
|
|
3509
|
-
return true;
|
|
3510
|
-
}
|
|
3511
|
-
return item.query.every((filter) => {
|
|
3512
|
-
return objectMatchesQuery(userAttributes, filter);
|
|
3513
|
-
});
|
|
3514
|
-
}
|
|
3515
|
-
var PERSONALIZATION_SCRIPT = `function getPersonalizedVariant(variants, blockId, locale) {
|
|
3516
|
-
if (!navigator.cookieEnabled) {
|
|
3517
|
-
return;
|
|
3518
|
-
}
|
|
3519
|
-
function getCookie(name) {
|
|
3520
|
-
const nameEQ = name + '=';
|
|
3521
|
-
const ca = document.cookie.split(';');
|
|
3522
|
-
for (let i = 0; i < ca.length; i++) {
|
|
3523
|
-
let c = ca[i];
|
|
3524
|
-
while (c.charAt(0) == ' ') c = c.substring(1, c.length);
|
|
3525
|
-
if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length);
|
|
3526
|
-
}
|
|
3527
|
-
return null;
|
|
3528
|
-
}
|
|
3529
|
-
function removeVariants() {
|
|
3530
|
-
variants?.forEach(function (_, index) {
|
|
3531
|
-
document.querySelector('template[data-variant-id="' + blockId + '-' + index + '"]')?.remove();
|
|
3532
|
-
});
|
|
3533
|
-
document.querySelector('script[data-id="variants-script-' + blockId + '"]')?.remove();
|
|
3534
|
-
document.querySelector('style[data-id="variants-styles-' + blockId + '"]')?.remove();
|
|
3535
|
-
}
|
|
3536
|
-
const attributes = JSON.parse(getCookie('builder.userAttributes') || '{}');
|
|
3537
|
-
if (locale) {
|
|
3538
|
-
attributes.locale = locale;
|
|
3539
|
-
}
|
|
3540
|
-
const winningVariantIndex = variants?.findIndex(function (variant) {
|
|
3541
|
-
return filterWithCustomTargeting(attributes, variant.query, variant.startDate, variant.endDate);
|
|
3542
|
-
});
|
|
3543
|
-
const isDebug = location.href.includes('builder.debug=true');
|
|
3544
|
-
if (isDebug) {
|
|
3545
|
-
console.debug('PersonalizationContainer', {
|
|
3546
|
-
attributes,
|
|
3547
|
-
variants,
|
|
3548
|
-
winningVariantIndex
|
|
3549
|
-
});
|
|
3550
|
-
}
|
|
3551
|
-
if (winningVariantIndex !== -1) {
|
|
3552
|
-
const winningVariant = document.querySelector('template[data-variant-id="' + blockId + '-' + winningVariantIndex + '"]');
|
|
3553
|
-
if (winningVariant) {
|
|
3554
|
-
const parentNode = winningVariant.parentNode;
|
|
3555
|
-
if (parentNode) {
|
|
3556
|
-
const newParent = parentNode.cloneNode(false);
|
|
3557
|
-
newParent.appendChild(winningVariant.content.firstChild);
|
|
3558
|
-
newParent.appendChild(winningVariant.content.lastChild);
|
|
3559
|
-
parentNode.parentNode?.replaceChild(newParent, parentNode);
|
|
3560
|
-
}
|
|
3561
|
-
if (isDebug) {
|
|
3562
|
-
console.debug('PersonalizationContainer', 'Winning variant Replaced:', winningVariant);
|
|
3563
|
-
}
|
|
3564
|
-
}
|
|
3565
|
-
} else if (variants && variants.length > 0) {
|
|
3566
|
-
removeVariants();
|
|
3567
|
-
}
|
|
3568
|
-
}`;
|
|
3569
|
-
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}";
|
|
3570
|
-
|
|
3571
|
-
// src/blocks/personalization-container/helpers.ts
|
|
3572
|
-
function checkShouldRenderVariants(variants, canTrack) {
|
|
3573
|
-
const hasVariants = variants && variants.length > 0;
|
|
3574
|
-
if (TARGET === "reactNative")
|
|
3575
|
-
return false;
|
|
3576
|
-
if (!hasVariants)
|
|
3577
|
-
return false;
|
|
3578
|
-
if (!canTrack)
|
|
3579
|
-
return false;
|
|
3580
|
-
if (TARGET === "vue" || TARGET === "svelte")
|
|
3581
|
-
return true;
|
|
3582
|
-
if (isBrowser())
|
|
3583
|
-
return false;
|
|
3584
|
-
return true;
|
|
3585
|
-
}
|
|
3586
|
-
function getBlocksToRender({
|
|
3587
|
-
variants,
|
|
3588
|
-
previewingIndex,
|
|
3589
|
-
isHydrated,
|
|
3590
|
-
filteredVariants,
|
|
3591
|
-
fallbackBlocks
|
|
3592
|
-
}) {
|
|
3593
|
-
const fallback = {
|
|
3594
|
-
blocks: fallbackBlocks ?? [],
|
|
3595
|
-
path: "this.children"
|
|
3596
|
-
};
|
|
3597
|
-
if (isHydrated && isEditing()) {
|
|
3598
|
-
if (typeof previewingIndex === "number" && previewingIndex < (variants?.length ?? 0)) {
|
|
3599
|
-
const variant = variants[previewingIndex];
|
|
3600
|
-
return {
|
|
3601
|
-
blocks: variant.blocks,
|
|
3602
|
-
path: `component.options.variants.${previewingIndex}.blocks`
|
|
3603
|
-
};
|
|
3604
|
-
}
|
|
3605
|
-
return fallback;
|
|
3606
|
-
}
|
|
3607
|
-
if (isBrowser()) {
|
|
3608
|
-
const winningVariant = filteredVariants?.[0];
|
|
3609
|
-
if (winningVariant) {
|
|
3610
|
-
return {
|
|
3611
|
-
blocks: winningVariant.blocks,
|
|
3612
|
-
path: `component.options.variants.${variants?.indexOf(winningVariant)}.blocks`
|
|
3613
|
-
};
|
|
3614
|
-
}
|
|
3615
|
-
}
|
|
3616
|
-
return fallback;
|
|
3617
|
-
}
|
|
3618
|
-
var getPersonalizationScript = (variants, blockId, locale) => {
|
|
3619
|
-
return `
|
|
3620
|
-
(function() {
|
|
3621
|
-
${FILTER_WITH_CUSTOM_TARGETING_SCRIPT}
|
|
3622
|
-
${PERSONALIZATION_SCRIPT}
|
|
3623
|
-
getPersonalizedVariant(${JSON.stringify(variants)}, "${blockId}"${locale ? `, "${locale}"` : ""})
|
|
3624
|
-
})();
|
|
3625
|
-
`;
|
|
3626
|
-
};
|
|
3627
|
-
|
|
3628
3602
|
// src/blocks/personalization-container/personalization-container.tsx
|
|
3629
3603
|
var _tmpl$9 = /* @__PURE__ */ template(`<div>`);
|
|
3630
|
-
var _tmpl$25 = /* @__PURE__ */ template(`<template>`);
|
|
3631
3604
|
function PersonalizationContainer(props) {
|
|
3632
3605
|
const [userAttributes, setUserAttributes] = createSignal(userAttributesService.getUserAttributes());
|
|
3633
3606
|
const [scriptStr, setScriptStr] = createSignal(getPersonalizationScript(props.variants, props.builderBlock?.id || "none", props.builderContext?.rootState?.locale));
|
|
3607
|
+
const [updateVisibilityStylesScript, setUpdateVisibilityStylesScript] = createSignal(getUpdateVisibilityStylesScript(props.variants, props.builderBlock?.id || "none", props.builderContext?.rootState?.locale));
|
|
3634
3608
|
const [unsubscribers, setUnsubscribers] = createSignal([]);
|
|
3635
3609
|
const [shouldRenderVariants, setShouldRenderVariants] = createSignal(checkShouldRenderVariants(props.variants, getDefaultCanTrack(props.builderContext?.canTrack)));
|
|
3636
|
-
const [
|
|
3610
|
+
const [shouldResetVariants, setShouldResetVariants] = createSignal(false);
|
|
3611
|
+
const attrs = createMemo(() => {
|
|
3612
|
+
return {
|
|
3613
|
+
...props.attributes,
|
|
3614
|
+
...{},
|
|
3615
|
+
[getClassPropName()]: `builder-personalization-container ${props.attributes[getClassPropName()] || ""}`
|
|
3616
|
+
};
|
|
3617
|
+
});
|
|
3637
3618
|
const filteredVariants = createMemo(() => {
|
|
3638
3619
|
return (props.variants || []).filter((variant) => {
|
|
3639
3620
|
return filterWithCustomTargeting({
|
|
@@ -3648,26 +3629,26 @@ function PersonalizationContainer(props) {
|
|
|
3648
3629
|
return getBlocksToRender({
|
|
3649
3630
|
variants: props.variants,
|
|
3650
3631
|
fallbackBlocks: props.builderBlock?.children,
|
|
3651
|
-
isHydrated:
|
|
3632
|
+
isHydrated: shouldResetVariants(),
|
|
3652
3633
|
filteredVariants: filteredVariants(),
|
|
3653
3634
|
previewingIndex: props.previewingIndex
|
|
3654
3635
|
});
|
|
3655
3636
|
});
|
|
3656
3637
|
const hideVariantsStyleString = createMemo(() => {
|
|
3657
|
-
return (props.variants || []).map((_, index) => `[data-variant-id="${props.builderBlock?.id}-${index}"] { display: none; } `).join("");
|
|
3638
|
+
return (props.variants || []).map((_, index) => `div[data-variant-id="${props.builderBlock?.id}-${index}"] { display: none !important; } `).join("");
|
|
3658
3639
|
});
|
|
3659
3640
|
let rootRef;
|
|
3660
3641
|
onMount(() => {
|
|
3661
|
-
|
|
3662
|
-
const unsub = userAttributesService.subscribeOnUserAttributesChange((
|
|
3663
|
-
setUserAttributes(
|
|
3642
|
+
setShouldResetVariants(true);
|
|
3643
|
+
const unsub = userAttributesService.subscribeOnUserAttributesChange((attrs2) => {
|
|
3644
|
+
setUserAttributes(attrs2);
|
|
3664
3645
|
});
|
|
3665
3646
|
if (!(isEditing() || isPreviewing())) {
|
|
3666
3647
|
const variant = filteredVariants()[0];
|
|
3667
3648
|
if (rootRef) {
|
|
3668
3649
|
rootRef.dispatchEvent(new CustomEvent("builder.variantLoaded", {
|
|
3669
3650
|
detail: {
|
|
3670
|
-
variant: variant ||
|
|
3651
|
+
variant: variant || DEFAULT_INDEX,
|
|
3671
3652
|
content: props.builderContext?.content
|
|
3672
3653
|
},
|
|
3673
3654
|
bubbles: true
|
|
@@ -3677,7 +3658,7 @@ function PersonalizationContainer(props) {
|
|
|
3677
3658
|
if (entry.isIntersecting && rootRef) {
|
|
3678
3659
|
rootRef.dispatchEvent(new CustomEvent("builder.variantDisplayed", {
|
|
3679
3660
|
detail: {
|
|
3680
|
-
variant: variant ||
|
|
3661
|
+
variant: variant || DEFAULT_INDEX,
|
|
3681
3662
|
content: props.builderContext?.content
|
|
3682
3663
|
},
|
|
3683
3664
|
bubbles: true
|
|
@@ -3694,70 +3675,158 @@ function PersonalizationContainer(props) {
|
|
|
3694
3675
|
const _el$ = _tmpl$9();
|
|
3695
3676
|
const _ref$ = rootRef;
|
|
3696
3677
|
typeof _ref$ === "function" ? use(_ref$, _el$) : rootRef = _el$;
|
|
3697
|
-
spread(_el$, mergeProps(
|
|
3698
|
-
get ["class"]() {
|
|
3699
|
-
return `builder-personalization-container ${props.attributes?.className || ""}`;
|
|
3700
|
-
}
|
|
3701
|
-
}, () => props.attributes), false, true);
|
|
3678
|
+
spread(_el$, mergeProps(attrs), false, true);
|
|
3702
3679
|
insert(_el$, createComponent(Show, {
|
|
3703
3680
|
get when() {
|
|
3704
|
-
return
|
|
3681
|
+
return memo(() => !!shouldResetVariants())() && SDKS_REQUIRING_RESET_APPROACH.includes(TARGET);
|
|
3705
3682
|
},
|
|
3706
3683
|
get children() {
|
|
3707
|
-
return
|
|
3708
|
-
get
|
|
3709
|
-
return
|
|
3684
|
+
return createComponent(blocks_default, {
|
|
3685
|
+
get blocks() {
|
|
3686
|
+
return blocksToRender().blocks;
|
|
3710
3687
|
},
|
|
3711
|
-
|
|
3712
|
-
|
|
3713
|
-
return (() => {
|
|
3714
|
-
const _el$2 = _tmpl$25();
|
|
3715
|
-
setAttribute(_el$2, "key", index);
|
|
3716
|
-
insert(_el$2, createComponent(blocks_default, {
|
|
3717
|
-
get blocks() {
|
|
3718
|
-
return variant.blocks;
|
|
3719
|
-
},
|
|
3720
|
-
get parent() {
|
|
3721
|
-
return props.builderBlock?.id;
|
|
3722
|
-
},
|
|
3723
|
-
path: `component.options.variants.${index}.blocks`
|
|
3724
|
-
}));
|
|
3725
|
-
effect(() => setAttribute(_el$2, "data-variant-id", `${props.builderBlock?.id}-${index}`));
|
|
3726
|
-
return _el$2;
|
|
3727
|
-
})();
|
|
3728
|
-
}
|
|
3729
|
-
}), createComponent(inlined_styles_default, {
|
|
3730
|
-
get nonce() {
|
|
3731
|
-
return props.builderContext?.nonce || "";
|
|
3688
|
+
get parent() {
|
|
3689
|
+
return props.builderBlock?.id;
|
|
3732
3690
|
},
|
|
3733
|
-
get
|
|
3734
|
-
return
|
|
3691
|
+
get path() {
|
|
3692
|
+
return blocksToRender().path;
|
|
3735
3693
|
},
|
|
3736
|
-
get
|
|
3737
|
-
return
|
|
3738
|
-
}
|
|
3739
|
-
}), createComponent(inlined_script_default, {
|
|
3740
|
-
get nonce() {
|
|
3741
|
-
return props.builderContext?.nonce || "";
|
|
3694
|
+
get context() {
|
|
3695
|
+
return props.builderContext;
|
|
3742
3696
|
},
|
|
3743
|
-
get
|
|
3744
|
-
return
|
|
3697
|
+
get registeredComponents() {
|
|
3698
|
+
return props.builderComponents;
|
|
3745
3699
|
},
|
|
3746
|
-
get
|
|
3747
|
-
return
|
|
3700
|
+
get BlocksWrapperProps() {
|
|
3701
|
+
return {
|
|
3702
|
+
...props.builderContext?.BlocksWrapperProps,
|
|
3703
|
+
"data-variant-id": `${props.builderBlock?.id}-${blocksToRender().index}`
|
|
3704
|
+
};
|
|
3748
3705
|
}
|
|
3749
|
-
})
|
|
3706
|
+
});
|
|
3750
3707
|
}
|
|
3751
3708
|
}), null);
|
|
3752
|
-
insert(_el$, createComponent(
|
|
3753
|
-
get
|
|
3754
|
-
return
|
|
3755
|
-
},
|
|
3756
|
-
get parent() {
|
|
3757
|
-
return props.builderBlock?.id;
|
|
3709
|
+
insert(_el$, createComponent(Show, {
|
|
3710
|
+
get when() {
|
|
3711
|
+
return memo(() => !!!shouldResetVariants())() && SDKS_REQUIRING_RESET_APPROACH.includes(TARGET) || !SDKS_REQUIRING_RESET_APPROACH.includes(TARGET);
|
|
3758
3712
|
},
|
|
3759
|
-
get
|
|
3760
|
-
return
|
|
3713
|
+
get children() {
|
|
3714
|
+
return [createComponent(Show, {
|
|
3715
|
+
get when() {
|
|
3716
|
+
return shouldRenderVariants();
|
|
3717
|
+
},
|
|
3718
|
+
get children() {
|
|
3719
|
+
return [createComponent(inlined_styles_default, {
|
|
3720
|
+
get nonce() {
|
|
3721
|
+
return props.builderContext?.nonce || "";
|
|
3722
|
+
},
|
|
3723
|
+
get styles() {
|
|
3724
|
+
return hideVariantsStyleString();
|
|
3725
|
+
},
|
|
3726
|
+
get id() {
|
|
3727
|
+
return `variants-styles-${props.builderBlock?.id}`;
|
|
3728
|
+
}
|
|
3729
|
+
}), createComponent(inlined_script_default, {
|
|
3730
|
+
get nonce() {
|
|
3731
|
+
return props.builderContext?.nonce || "";
|
|
3732
|
+
},
|
|
3733
|
+
get scriptStr() {
|
|
3734
|
+
return updateVisibilityStylesScript();
|
|
3735
|
+
},
|
|
3736
|
+
get id() {
|
|
3737
|
+
return `variants-visibility-script-${props.builderBlock?.id}`;
|
|
3738
|
+
}
|
|
3739
|
+
}), createComponent(For, {
|
|
3740
|
+
get each() {
|
|
3741
|
+
return props.variants;
|
|
3742
|
+
},
|
|
3743
|
+
children: (variant, _index) => {
|
|
3744
|
+
const index = _index();
|
|
3745
|
+
return createComponent(blocks_default, {
|
|
3746
|
+
get key() {
|
|
3747
|
+
return `${props.builderBlock?.id}-${index}`;
|
|
3748
|
+
},
|
|
3749
|
+
get BlocksWrapperProps() {
|
|
3750
|
+
return {
|
|
3751
|
+
...props.builderContext?.BlocksWrapperProps,
|
|
3752
|
+
"aria-hidden": true,
|
|
3753
|
+
hidden: true,
|
|
3754
|
+
"data-variant-id": `${props.builderBlock?.id}-${index}`
|
|
3755
|
+
};
|
|
3756
|
+
},
|
|
3757
|
+
get blocks() {
|
|
3758
|
+
return variant.blocks;
|
|
3759
|
+
},
|
|
3760
|
+
get parent() {
|
|
3761
|
+
return props.builderBlock?.id;
|
|
3762
|
+
},
|
|
3763
|
+
path: `component.options.variants.${index}.blocks`,
|
|
3764
|
+
get context() {
|
|
3765
|
+
return props.builderContext;
|
|
3766
|
+
},
|
|
3767
|
+
get registeredComponents() {
|
|
3768
|
+
return props.builderComponents;
|
|
3769
|
+
},
|
|
3770
|
+
get children() {
|
|
3771
|
+
return createComponent(inlined_script_default, {
|
|
3772
|
+
get nonce() {
|
|
3773
|
+
return props.builderContext?.nonce || "";
|
|
3774
|
+
},
|
|
3775
|
+
get scriptStr() {
|
|
3776
|
+
return scriptStr();
|
|
3777
|
+
},
|
|
3778
|
+
get id() {
|
|
3779
|
+
return `variants-script-${props.builderBlock?.id}-${index}`;
|
|
3780
|
+
}
|
|
3781
|
+
});
|
|
3782
|
+
}
|
|
3783
|
+
});
|
|
3784
|
+
}
|
|
3785
|
+
})];
|
|
3786
|
+
}
|
|
3787
|
+
}), createComponent(blocks_default, {
|
|
3788
|
+
get blocks() {
|
|
3789
|
+
return blocksToRender().blocks;
|
|
3790
|
+
},
|
|
3791
|
+
get parent() {
|
|
3792
|
+
return props.builderBlock?.id;
|
|
3793
|
+
},
|
|
3794
|
+
get path() {
|
|
3795
|
+
return blocksToRender().path;
|
|
3796
|
+
},
|
|
3797
|
+
get context() {
|
|
3798
|
+
return props.builderContext;
|
|
3799
|
+
},
|
|
3800
|
+
get registeredComponents() {
|
|
3801
|
+
return props.builderComponents;
|
|
3802
|
+
},
|
|
3803
|
+
get BlocksWrapperProps() {
|
|
3804
|
+
return {
|
|
3805
|
+
...props.builderContext?.BlocksWrapperProps,
|
|
3806
|
+
"data-variant-id": `${props.builderBlock?.id}-${blocksToRender().index}`
|
|
3807
|
+
};
|
|
3808
|
+
},
|
|
3809
|
+
get children() {
|
|
3810
|
+
return createComponent(Show, {
|
|
3811
|
+
get when() {
|
|
3812
|
+
return shouldRenderVariants();
|
|
3813
|
+
},
|
|
3814
|
+
get children() {
|
|
3815
|
+
return createComponent(inlined_script_default, {
|
|
3816
|
+
get nonce() {
|
|
3817
|
+
return props.builderContext?.nonce || "";
|
|
3818
|
+
},
|
|
3819
|
+
get scriptStr() {
|
|
3820
|
+
return scriptStr();
|
|
3821
|
+
},
|
|
3822
|
+
get id() {
|
|
3823
|
+
return `variants-script-${props.builderBlock?.id}-${DEFAULT_INDEX}`;
|
|
3824
|
+
}
|
|
3825
|
+
});
|
|
3826
|
+
}
|
|
3827
|
+
});
|
|
3828
|
+
}
|
|
3829
|
+
})];
|
|
3761
3830
|
}
|
|
3762
3831
|
}), null);
|
|
3763
3832
|
return _el$;
|
|
@@ -4044,7 +4113,7 @@ var componentInfo10 = {
|
|
|
4044
4113
|
}
|
|
4045
4114
|
};
|
|
4046
4115
|
var _tmpl$11 = /* @__PURE__ */ template(`<div>`);
|
|
4047
|
-
var _tmpl$
|
|
4116
|
+
var _tmpl$25 = /* @__PURE__ */ template(`<div><div class=builder-tabs-wrap>`);
|
|
4048
4117
|
var _tmpl$33 = /* @__PURE__ */ template(`<span>`);
|
|
4049
4118
|
function Tabs(props) {
|
|
4050
4119
|
const [activeTab, setActiveTab] = createSignal(props.defaultActiveTab ? props.defaultActiveTab - 1 : 0);
|
|
@@ -4059,7 +4128,7 @@ function Tabs(props) {
|
|
|
4059
4128
|
}
|
|
4060
4129
|
}
|
|
4061
4130
|
return (() => {
|
|
4062
|
-
const _el$ = _tmpl$
|
|
4131
|
+
const _el$ = _tmpl$25(), _el$2 = _el$.firstChild;
|
|
4063
4132
|
_el$2.style.setProperty("display", "flex");
|
|
4064
4133
|
_el$2.style.setProperty("flex-direction", "row");
|
|
4065
4134
|
_el$2.style.setProperty("overflow", "auto");
|
|
@@ -4591,7 +4660,7 @@ function logFetch(url) {
|
|
|
4591
4660
|
|
|
4592
4661
|
// src/blocks/form/form/form.tsx
|
|
4593
4662
|
var _tmpl$15 = /* @__PURE__ */ template(`<pre class="builder-form-error-text pre-04a43b72">`);
|
|
4594
|
-
var _tmpl$
|
|
4663
|
+
var _tmpl$26 = /* @__PURE__ */ template(`<form>`);
|
|
4595
4664
|
var _tmpl$34 = /* @__PURE__ */ template(`<style>.pre-04a43b72 {
|
|
4596
4665
|
padding: 10px;
|
|
4597
4666
|
color: red;
|
|
@@ -4784,7 +4853,7 @@ function FormComponent(props) {
|
|
|
4784
4853
|
}
|
|
4785
4854
|
let formRef;
|
|
4786
4855
|
return [(() => {
|
|
4787
|
-
const _el$ = _tmpl$
|
|
4856
|
+
const _el$ = _tmpl$26();
|
|
4788
4857
|
_el$.addEventListener("submit", (event) => onSubmit(event));
|
|
4789
4858
|
const _ref$ = formRef;
|
|
4790
4859
|
typeof _ref$ === "function" ? use(_ref$, _el$) : formRef = _el$;
|
|
@@ -4996,7 +5065,7 @@ var componentInfo16 = {
|
|
|
4996
5065
|
noWrap: true
|
|
4997
5066
|
};
|
|
4998
5067
|
var _tmpl$17 = /* @__PURE__ */ template(`<select>`);
|
|
4999
|
-
var _tmpl$
|
|
5068
|
+
var _tmpl$27 = /* @__PURE__ */ template(`<option>`);
|
|
5000
5069
|
function SelectComponent(props) {
|
|
5001
5070
|
return (() => {
|
|
5002
5071
|
const _el$ = _tmpl$17();
|
|
@@ -5024,7 +5093,7 @@ function SelectComponent(props) {
|
|
|
5024
5093
|
children: (option, _index) => {
|
|
5025
5094
|
const index = _index();
|
|
5026
5095
|
return (() => {
|
|
5027
|
-
const _el$2 = _tmpl$
|
|
5096
|
+
const _el$2 = _tmpl$27();
|
|
5028
5097
|
insert(_el$2, () => option.name || option.value);
|
|
5029
5098
|
effect(() => setAttribute(_el$2, "key", `${option.name}-${index}`));
|
|
5030
5099
|
effect(() => _el$2.value = option.value);
|
|
@@ -5268,7 +5337,7 @@ var componentInfo20 = {
|
|
|
5268
5337
|
}
|
|
5269
5338
|
};
|
|
5270
5339
|
var _tmpl$21 = /* @__PURE__ */ template(`<div>`);
|
|
5271
|
-
var _tmpl$
|
|
5340
|
+
var _tmpl$28 = /* @__PURE__ */ template(`<div><video class=builder-video><source type=video/mp4>`);
|
|
5272
5341
|
function Video(props) {
|
|
5273
5342
|
const [lazyVideoObserver, setLazyVideoObserver] = createSignal(void 0);
|
|
5274
5343
|
const videoProps = createMemo(() => {
|
|
@@ -5324,7 +5393,7 @@ function Video(props) {
|
|
|
5324
5393
|
}
|
|
5325
5394
|
});
|
|
5326
5395
|
return (() => {
|
|
5327
|
-
const _el$ = _tmpl$
|
|
5396
|
+
const _el$ = _tmpl$28(), _el$2 = _el$.firstChild, _el$3 = _el$2.firstChild;
|
|
5328
5397
|
_el$.style.setProperty("position", "relative");
|
|
5329
5398
|
const _ref$ = videoRef;
|
|
5330
5399
|
typeof _ref$ === "function" ? use(_ref$, _el$2) : videoRef = _el$2;
|
|
@@ -5461,7 +5530,7 @@ var getDefaultRegisteredComponents = () => [{
|
|
|
5461
5530
|
}, {
|
|
5462
5531
|
component: text_default,
|
|
5463
5532
|
...componentInfo11
|
|
5464
|
-
}, ...TARGET
|
|
5533
|
+
}, ...SDKS_SUPPORTING_PERSONALIZATION.includes(TARGET) ? [{
|
|
5465
5534
|
component: personalization_container_default,
|
|
5466
5535
|
...componentInfo6
|
|
5467
5536
|
}] : [], ...TARGET === "rsc" ? [] : [{
|
|
@@ -5498,7 +5567,7 @@ var UPDATE_VARIANT_VISIBILITY_SCRIPT = "function updateVariantVisibility(variant
|
|
|
5498
5567
|
|
|
5499
5568
|
// src/components/content-variants/helpers.ts
|
|
5500
5569
|
var UPDATE_COOKIES_AND_STYLES_SCRIPT_NAME = "builderIoAbTest";
|
|
5501
|
-
var
|
|
5570
|
+
var UPDATE_VARIANT_VISIBILITY_SCRIPT_FN_NAME2 = "builderIoRenderContent";
|
|
5502
5571
|
var getVariants = (content) => Object.values(content?.variations || {}).map((variant) => ({
|
|
5503
5572
|
...variant,
|
|
5504
5573
|
testVariationId: variant.id,
|
|
@@ -5523,20 +5592,20 @@ var checkShouldRenderVariants2 = ({
|
|
|
5523
5592
|
};
|
|
5524
5593
|
var getIsHydrationTarget = (target) => target === "react" || target === "reactNative";
|
|
5525
5594
|
var isAngularSDK = TARGET === "angular";
|
|
5526
|
-
var
|
|
5595
|
+
var isHydrationTarget2 = getIsHydrationTarget(TARGET);
|
|
5527
5596
|
var getInitVariantsFnsScriptString = () => `
|
|
5528
5597
|
window.${UPDATE_COOKIES_AND_STYLES_SCRIPT_NAME} = ${UPDATE_COOKIES_AND_STYLES_SCRIPT}
|
|
5529
|
-
window.${
|
|
5598
|
+
window.${UPDATE_VARIANT_VISIBILITY_SCRIPT_FN_NAME2} = ${UPDATE_VARIANT_VISIBILITY_SCRIPT}
|
|
5530
5599
|
`;
|
|
5531
5600
|
var getUpdateCookieAndStylesScript = (variants, contentId) => `
|
|
5532
5601
|
window.${UPDATE_COOKIES_AND_STYLES_SCRIPT_NAME}(
|
|
5533
|
-
"${contentId}",${JSON.stringify(variants)}, ${
|
|
5602
|
+
"${contentId}",${JSON.stringify(variants)}, ${isHydrationTarget2}, ${isAngularSDK}
|
|
5534
5603
|
)`;
|
|
5535
5604
|
var getUpdateVariantVisibilityScript = ({
|
|
5536
5605
|
contentId,
|
|
5537
5606
|
variationId
|
|
5538
|
-
}) => `window.${
|
|
5539
|
-
"${variationId}", "${contentId}", ${
|
|
5607
|
+
}) => `window.${UPDATE_VARIANT_VISIBILITY_SCRIPT_FN_NAME2}(
|
|
5608
|
+
"${variationId}", "${contentId}", ${isHydrationTarget2}
|
|
5540
5609
|
)`;
|
|
5541
5610
|
|
|
5542
5611
|
// src/helpers/preview-lru-cache/get.ts
|
|
@@ -5545,7 +5614,7 @@ function getPreviewContent(_searchParams) {
|
|
|
5545
5614
|
}
|
|
5546
5615
|
|
|
5547
5616
|
// src/constants/sdk-version.ts
|
|
5548
|
-
var SDK_VERSION = "4.0.
|
|
5617
|
+
var SDK_VERSION = "4.0.9";
|
|
5549
5618
|
|
|
5550
5619
|
// src/helpers/sdk-headers.ts
|
|
5551
5620
|
var getSdkHeaders = () => ({
|
|
@@ -6968,7 +7037,7 @@ function ContentVariants(props) {
|
|
|
6968
7037
|
return !props.isNestedRender && TARGET !== "reactNative";
|
|
6969
7038
|
},
|
|
6970
7039
|
get children() {
|
|
6971
|
-
return createComponent(inlined_script_default, {
|
|
7040
|
+
return [createComponent(inlined_script_default, {
|
|
6972
7041
|
id: "builderio-init-variants-fns",
|
|
6973
7042
|
get scriptStr() {
|
|
6974
7043
|
return getInitVariantsFnsScriptString();
|
|
@@ -6976,7 +7045,22 @@ function ContentVariants(props) {
|
|
|
6976
7045
|
get nonce() {
|
|
6977
7046
|
return props.nonce || "";
|
|
6978
7047
|
}
|
|
6979
|
-
})
|
|
7048
|
+
}), createComponent(Show, {
|
|
7049
|
+
get when() {
|
|
7050
|
+
return SDKS_SUPPORTING_PERSONALIZATION.includes(TARGET);
|
|
7051
|
+
},
|
|
7052
|
+
get children() {
|
|
7053
|
+
return createComponent(inlined_script_default, {
|
|
7054
|
+
id: "builderio-init-personalization-variants-fns",
|
|
7055
|
+
get nonce() {
|
|
7056
|
+
return props.nonce || "";
|
|
7057
|
+
},
|
|
7058
|
+
get scriptStr() {
|
|
7059
|
+
return getInitPersonalizationVariantsFnsScriptString();
|
|
7060
|
+
}
|
|
7061
|
+
});
|
|
7062
|
+
}
|
|
7063
|
+
})];
|
|
6980
7064
|
}
|
|
6981
7065
|
}), createComponent(Show, {
|
|
6982
7066
|
get when() {
|
|
@@ -7164,9 +7248,10 @@ var fetchSymbolContent = async ({
|
|
|
7164
7248
|
};
|
|
7165
7249
|
|
|
7166
7250
|
// src/blocks/symbol/symbol.tsx
|
|
7167
|
-
var _tmpl$
|
|
7251
|
+
var _tmpl$29 = /* @__PURE__ */ template(`<div>`);
|
|
7168
7252
|
function Symbol(props) {
|
|
7169
7253
|
const [contentToUse, setContentToUse] = createSignal(props.symbol?.content);
|
|
7254
|
+
const [symbolEntry, setSymbolEntry] = createSignal(props.symbol?.entry);
|
|
7170
7255
|
const blocksWrapper = createMemo(() => {
|
|
7171
7256
|
return "div";
|
|
7172
7257
|
});
|
|
@@ -7177,7 +7262,7 @@ function Symbol(props) {
|
|
|
7177
7262
|
return [...[props.attributes[getClassPropName()]], "builder-symbol", props.symbol?.inline ? "builder-inline-symbol" : void 0, props.symbol?.dynamic || props.dynamic ? "builder-dynamic-symbol" : void 0].filter(Boolean).join(" ");
|
|
7178
7263
|
});
|
|
7179
7264
|
function setContent() {
|
|
7180
|
-
if (contentToUse())
|
|
7265
|
+
if (contentToUse() && symbolEntry() === props.symbol?.entry)
|
|
7181
7266
|
return;
|
|
7182
7267
|
fetchSymbolContent({
|
|
7183
7268
|
symbol: props.symbol,
|
|
@@ -7185,6 +7270,7 @@ function Symbol(props) {
|
|
|
7185
7270
|
}).then((newContent) => {
|
|
7186
7271
|
if (newContent) {
|
|
7187
7272
|
setContentToUse(newContent);
|
|
7273
|
+
setSymbolEntry(props.symbol?.entry);
|
|
7188
7274
|
}
|
|
7189
7275
|
});
|
|
7190
7276
|
}
|
|
@@ -7196,7 +7282,7 @@ function Symbol(props) {
|
|
|
7196
7282
|
}
|
|
7197
7283
|
createEffect(on(() => [onUpdateFn_0_props_symbol()], onUpdateFn_0));
|
|
7198
7284
|
return (() => {
|
|
7199
|
-
const _el$ = _tmpl$
|
|
7285
|
+
const _el$ = _tmpl$29();
|
|
7200
7286
|
spread(_el$, mergeProps({
|
|
7201
7287
|
get ["class"]() {
|
|
7202
7288
|
return className();
|