@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/index.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
|
|
|
@@ -1378,6 +1378,7 @@ var awaiter_default = Awaiter;
|
|
|
1378
1378
|
|
|
1379
1379
|
// src/components/block/components/interactive-element.tsx
|
|
1380
1380
|
function InteractiveElement(props) {
|
|
1381
|
+
createSignal(0);
|
|
1381
1382
|
const attributes = createMemo(() => {
|
|
1382
1383
|
return props.includeBlockProps ? {
|
|
1383
1384
|
...getBlockProperties({
|
|
@@ -1396,6 +1397,11 @@ function InteractiveElement(props) {
|
|
|
1396
1397
|
const targetWrapperProps = createMemo(() => {
|
|
1397
1398
|
return props.wrapperProps;
|
|
1398
1399
|
});
|
|
1400
|
+
const onUpdateFn_0_props_wrapperProps = createMemo(() => props.wrapperProps);
|
|
1401
|
+
const onUpdateFn_0_props_block__component__options = createMemo(() => props.block?.component?.options);
|
|
1402
|
+
function onUpdateFn_0() {
|
|
1403
|
+
}
|
|
1404
|
+
createEffect(on(() => [onUpdateFn_0_props_wrapperProps(), onUpdateFn_0_props_block__component__options()], onUpdateFn_0));
|
|
1399
1405
|
return createComponent(Show, {
|
|
1400
1406
|
get fallback() {
|
|
1401
1407
|
return createComponent(Dynamic, mergeProps(targetWrapperProps, {
|
|
@@ -1822,7 +1828,7 @@ function Block(props) {
|
|
|
1822
1828
|
});
|
|
1823
1829
|
}
|
|
1824
1830
|
var block_default = Block;
|
|
1825
|
-
var _tmpl$2 = /* @__PURE__ */ template(`<style>.dynamic-
|
|
1831
|
+
var _tmpl$2 = /* @__PURE__ */ template(`<style>.dynamic-450facf4 {
|
|
1826
1832
|
display: flex;
|
|
1827
1833
|
flex-direction: column;
|
|
1828
1834
|
align-items: stretch;
|
|
@@ -1871,7 +1877,7 @@ function BlocksWrapper(props) {
|
|
|
1871
1877
|
createEffect(on(() => [onUpdateFn_0_props_blocks()], onUpdateFn_0));
|
|
1872
1878
|
return [createComponent(Dynamic, mergeProps({
|
|
1873
1879
|
get ["class"]() {
|
|
1874
|
-
return className() + " dynamic-
|
|
1880
|
+
return className() + " dynamic-450facf4";
|
|
1875
1881
|
},
|
|
1876
1882
|
ref(r$) {
|
|
1877
1883
|
const _ref$ = blocksWrapperRef;
|
|
@@ -1918,17 +1924,17 @@ function Blocks(props) {
|
|
|
1918
1924
|
get styleProp() {
|
|
1919
1925
|
return props.styleProp;
|
|
1920
1926
|
},
|
|
1927
|
+
get BlocksWrapperProps() {
|
|
1928
|
+
return props.BlocksWrapperProps || props.context?.BlocksWrapperProps || builderContext?.BlocksWrapperProps;
|
|
1929
|
+
},
|
|
1921
1930
|
get classNameProp() {
|
|
1922
1931
|
return props.className;
|
|
1923
1932
|
},
|
|
1924
1933
|
get BlocksWrapper() {
|
|
1925
1934
|
return props.context?.BlocksWrapper || builderContext?.BlocksWrapper;
|
|
1926
1935
|
},
|
|
1927
|
-
get BlocksWrapperProps() {
|
|
1928
|
-
return props.context?.BlocksWrapperProps || builderContext?.BlocksWrapperProps;
|
|
1929
|
-
},
|
|
1930
1936
|
get children() {
|
|
1931
|
-
return createComponent(Show, {
|
|
1937
|
+
return [memo(() => props.children), createComponent(Show, {
|
|
1932
1938
|
get when() {
|
|
1933
1939
|
return props.blocks;
|
|
1934
1940
|
},
|
|
@@ -1957,7 +1963,7 @@ function Blocks(props) {
|
|
|
1957
1963
|
}
|
|
1958
1964
|
});
|
|
1959
1965
|
}
|
|
1960
|
-
});
|
|
1966
|
+
})];
|
|
1961
1967
|
}
|
|
1962
1968
|
});
|
|
1963
1969
|
}
|
|
@@ -2381,6 +2387,166 @@ function SectionComponent(props) {
|
|
|
2381
2387
|
}
|
|
2382
2388
|
var section_default = SectionComponent;
|
|
2383
2389
|
|
|
2390
|
+
// src/blocks/personalization-container/helpers/inlined-fns.ts
|
|
2391
|
+
function filterWithCustomTargeting(userAttributes, query, startDate, endDate) {
|
|
2392
|
+
function isString(val) {
|
|
2393
|
+
return typeof val === "string";
|
|
2394
|
+
}
|
|
2395
|
+
function isNumber(val) {
|
|
2396
|
+
return typeof val === "number";
|
|
2397
|
+
}
|
|
2398
|
+
function objectMatchesQuery(userattr, query2) {
|
|
2399
|
+
const result = (() => {
|
|
2400
|
+
const property = query2.property;
|
|
2401
|
+
const operator = query2.operator;
|
|
2402
|
+
let testValue = query2.value;
|
|
2403
|
+
if (query2 && query2.property === "urlPath" && query2.value && typeof query2.value === "string" && query2.value !== "/" && query2.value.endsWith("/")) {
|
|
2404
|
+
testValue = query2.value.slice(0, -1);
|
|
2405
|
+
}
|
|
2406
|
+
if (!(property && operator)) {
|
|
2407
|
+
return true;
|
|
2408
|
+
}
|
|
2409
|
+
if (Array.isArray(testValue)) {
|
|
2410
|
+
if (operator === "isNot") {
|
|
2411
|
+
return testValue.every((val) => objectMatchesQuery(userattr, {
|
|
2412
|
+
property,
|
|
2413
|
+
operator,
|
|
2414
|
+
value: val
|
|
2415
|
+
}));
|
|
2416
|
+
}
|
|
2417
|
+
return !!testValue.find((val) => objectMatchesQuery(userattr, {
|
|
2418
|
+
property,
|
|
2419
|
+
operator,
|
|
2420
|
+
value: val
|
|
2421
|
+
}));
|
|
2422
|
+
}
|
|
2423
|
+
const value = userattr[property];
|
|
2424
|
+
if (Array.isArray(value)) {
|
|
2425
|
+
return value.includes(testValue);
|
|
2426
|
+
}
|
|
2427
|
+
switch (operator) {
|
|
2428
|
+
case "is":
|
|
2429
|
+
return value === testValue;
|
|
2430
|
+
case "isNot":
|
|
2431
|
+
return value !== testValue;
|
|
2432
|
+
case "contains":
|
|
2433
|
+
return (isString(value) || Array.isArray(value)) && value.includes(String(testValue));
|
|
2434
|
+
case "startsWith":
|
|
2435
|
+
return isString(value) && value.startsWith(String(testValue));
|
|
2436
|
+
case "endsWith":
|
|
2437
|
+
return isString(value) && value.endsWith(String(testValue));
|
|
2438
|
+
case "greaterThan":
|
|
2439
|
+
return isNumber(value) && isNumber(testValue) && value > testValue;
|
|
2440
|
+
case "lessThan":
|
|
2441
|
+
return isNumber(value) && isNumber(testValue) && value < testValue;
|
|
2442
|
+
case "greaterThanOrEqualTo":
|
|
2443
|
+
return isNumber(value) && isNumber(testValue) && value >= testValue;
|
|
2444
|
+
case "lessThanOrEqualTo":
|
|
2445
|
+
return isNumber(value) && isNumber(testValue) && value <= testValue;
|
|
2446
|
+
default:
|
|
2447
|
+
return false;
|
|
2448
|
+
}
|
|
2449
|
+
})();
|
|
2450
|
+
return result;
|
|
2451
|
+
}
|
|
2452
|
+
const item = {
|
|
2453
|
+
query,
|
|
2454
|
+
startDate,
|
|
2455
|
+
endDate
|
|
2456
|
+
};
|
|
2457
|
+
const now = userAttributes.date && new Date(userAttributes.date) || /* @__PURE__ */ new Date();
|
|
2458
|
+
if (item.startDate && new Date(item.startDate) > now) {
|
|
2459
|
+
return false;
|
|
2460
|
+
} else if (item.endDate && new Date(item.endDate) < now) {
|
|
2461
|
+
return false;
|
|
2462
|
+
}
|
|
2463
|
+
if (!item.query || !item.query.length) {
|
|
2464
|
+
return true;
|
|
2465
|
+
}
|
|
2466
|
+
return item.query.every((filter) => {
|
|
2467
|
+
return objectMatchesQuery(userAttributes, filter);
|
|
2468
|
+
});
|
|
2469
|
+
}
|
|
2470
|
+
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}";
|
|
2471
|
+
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}";
|
|
2472
|
+
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}";
|
|
2473
|
+
|
|
2474
|
+
// src/blocks/personalization-container/helpers.ts
|
|
2475
|
+
var DEFAULT_INDEX = "default";
|
|
2476
|
+
var FILTER_WITH_CUSTOM_TARGETING_SCRIPT_FN_NAME = "filterWithCustomTargeting";
|
|
2477
|
+
var BUILDER_IO_PERSONALIZATION_SCRIPT_FN_NAME = "builderIoPersonalization";
|
|
2478
|
+
var UPDATE_VARIANT_VISIBILITY_SCRIPT_FN_NAME = "updateVisibilityStylesScript";
|
|
2479
|
+
var SDKS_SUPPORTING_PERSONALIZATION = ["react", "vue", "svelte"];
|
|
2480
|
+
var SDKS_REQUIRING_RESET_APPROACH = ["vue", "svelte"];
|
|
2481
|
+
function checkShouldRenderVariants(variants, canTrack) {
|
|
2482
|
+
const hasVariants = variants && variants.length > 0;
|
|
2483
|
+
if (TARGET === "reactNative")
|
|
2484
|
+
return false;
|
|
2485
|
+
if (!hasVariants)
|
|
2486
|
+
return false;
|
|
2487
|
+
if (!canTrack)
|
|
2488
|
+
return false;
|
|
2489
|
+
if (SDKS_REQUIRING_RESET_APPROACH.includes(TARGET))
|
|
2490
|
+
return true;
|
|
2491
|
+
if (isBrowser())
|
|
2492
|
+
return false;
|
|
2493
|
+
return true;
|
|
2494
|
+
}
|
|
2495
|
+
function getBlocksToRender({
|
|
2496
|
+
variants,
|
|
2497
|
+
previewingIndex,
|
|
2498
|
+
isHydrated,
|
|
2499
|
+
filteredVariants,
|
|
2500
|
+
fallbackBlocks
|
|
2501
|
+
}) {
|
|
2502
|
+
const fallback = {
|
|
2503
|
+
blocks: fallbackBlocks ?? [],
|
|
2504
|
+
path: "this.children",
|
|
2505
|
+
index: DEFAULT_INDEX
|
|
2506
|
+
};
|
|
2507
|
+
if (isHydrated && isEditing()) {
|
|
2508
|
+
if (typeof previewingIndex === "number" && previewingIndex < (variants?.length ?? 0)) {
|
|
2509
|
+
const variant = variants?.[previewingIndex];
|
|
2510
|
+
if (variant) {
|
|
2511
|
+
return {
|
|
2512
|
+
blocks: variant.blocks,
|
|
2513
|
+
path: `variants.${previewingIndex}.blocks`,
|
|
2514
|
+
index: previewingIndex
|
|
2515
|
+
};
|
|
2516
|
+
}
|
|
2517
|
+
}
|
|
2518
|
+
return fallback;
|
|
2519
|
+
}
|
|
2520
|
+
if (isBrowser()) {
|
|
2521
|
+
const winningVariant = filteredVariants?.[0];
|
|
2522
|
+
if (winningVariant && variants) {
|
|
2523
|
+
const variantIndex = variants.indexOf(winningVariant);
|
|
2524
|
+
if (variantIndex !== -1) {
|
|
2525
|
+
return {
|
|
2526
|
+
blocks: winningVariant.blocks,
|
|
2527
|
+
path: `variants.${variantIndex}.blocks`,
|
|
2528
|
+
index: variantIndex
|
|
2529
|
+
};
|
|
2530
|
+
}
|
|
2531
|
+
}
|
|
2532
|
+
}
|
|
2533
|
+
return fallback;
|
|
2534
|
+
}
|
|
2535
|
+
var getInitPersonalizationVariantsFnsScriptString = () => {
|
|
2536
|
+
return `
|
|
2537
|
+
window.${FILTER_WITH_CUSTOM_TARGETING_SCRIPT_FN_NAME} = ${FILTER_WITH_CUSTOM_TARGETING_SCRIPT}
|
|
2538
|
+
window.${BUILDER_IO_PERSONALIZATION_SCRIPT_FN_NAME} = ${PERSONALIZATION_SCRIPT}
|
|
2539
|
+
window.${UPDATE_VARIANT_VISIBILITY_SCRIPT_FN_NAME} = ${UPDATE_VISIBILITY_STYLES_SCRIPT}
|
|
2540
|
+
`;
|
|
2541
|
+
};
|
|
2542
|
+
var isHydrationTarget = TARGET === "react";
|
|
2543
|
+
var getPersonalizationScript = (variants, blockId, locale) => {
|
|
2544
|
+
return `window.${BUILDER_IO_PERSONALIZATION_SCRIPT_FN_NAME}(${JSON.stringify(variants)}, "${blockId}", ${isHydrationTarget}${locale ? `, "${locale}"` : ""})`;
|
|
2545
|
+
};
|
|
2546
|
+
var getUpdateVisibilityStylesScript = (variants, blockId, locale) => {
|
|
2547
|
+
return `window.${UPDATE_VARIANT_VISIBILITY_SCRIPT_FN_NAME}(${JSON.stringify(variants)}, "${blockId}", ${isHydrationTarget}${locale ? `, "${locale}"` : ""})`;
|
|
2548
|
+
};
|
|
2549
|
+
|
|
2384
2550
|
// src/helpers/url.ts
|
|
2385
2551
|
var getTopLevelDomain = (host) => {
|
|
2386
2552
|
if (host === "localhost" || host === "127.0.0.1") {
|
|
@@ -3359,7 +3525,8 @@ var componentInfo6 = {
|
|
|
3359
3525
|
name: "PersonalizationContainer",
|
|
3360
3526
|
shouldReceiveBuilderProps: {
|
|
3361
3527
|
builderBlock: true,
|
|
3362
|
-
builderContext: true
|
|
3528
|
+
builderContext: true,
|
|
3529
|
+
builderComponents: true
|
|
3363
3530
|
},
|
|
3364
3531
|
noWrap: true,
|
|
3365
3532
|
image: "https://cdn.builder.io/api/v1/image/assets%2FYJIGb4i01jvw0SRdL5Bt%2F37229ed30d8c41dfb10b8cca1992053a",
|
|
@@ -3421,208 +3588,22 @@ function isPreviewing(_search) {
|
|
|
3421
3588
|
return Boolean(normalizedSearch.indexOf("builder.preview=") !== -1);
|
|
3422
3589
|
}
|
|
3423
3590
|
|
|
3424
|
-
// src/blocks/personalization-container/helpers/inlined-fns.ts
|
|
3425
|
-
function filterWithCustomTargeting(userAttributes, query, startDate, endDate) {
|
|
3426
|
-
function isString(val) {
|
|
3427
|
-
return typeof val === "string";
|
|
3428
|
-
}
|
|
3429
|
-
function isNumber(val) {
|
|
3430
|
-
return typeof val === "number";
|
|
3431
|
-
}
|
|
3432
|
-
function objectMatchesQuery(userattr, query2) {
|
|
3433
|
-
const result = (() => {
|
|
3434
|
-
const property = query2.property;
|
|
3435
|
-
const operator = query2.operator;
|
|
3436
|
-
let testValue = query2.value;
|
|
3437
|
-
if (query2 && query2.property === "urlPath" && query2.value && typeof query2.value === "string" && query2.value !== "/" && query2.value.endsWith("/")) {
|
|
3438
|
-
testValue = query2.value.slice(0, -1);
|
|
3439
|
-
}
|
|
3440
|
-
if (!(property && operator)) {
|
|
3441
|
-
return true;
|
|
3442
|
-
}
|
|
3443
|
-
if (Array.isArray(testValue)) {
|
|
3444
|
-
if (operator === "isNot") {
|
|
3445
|
-
return testValue.every((val) => objectMatchesQuery(userattr, {
|
|
3446
|
-
property,
|
|
3447
|
-
operator,
|
|
3448
|
-
value: val
|
|
3449
|
-
}));
|
|
3450
|
-
}
|
|
3451
|
-
return !!testValue.find((val) => objectMatchesQuery(userattr, {
|
|
3452
|
-
property,
|
|
3453
|
-
operator,
|
|
3454
|
-
value: val
|
|
3455
|
-
}));
|
|
3456
|
-
}
|
|
3457
|
-
const value = userattr[property];
|
|
3458
|
-
if (Array.isArray(value)) {
|
|
3459
|
-
return value.includes(testValue);
|
|
3460
|
-
}
|
|
3461
|
-
switch (operator) {
|
|
3462
|
-
case "is":
|
|
3463
|
-
return value === testValue;
|
|
3464
|
-
case "isNot":
|
|
3465
|
-
return value !== testValue;
|
|
3466
|
-
case "contains":
|
|
3467
|
-
return (isString(value) || Array.isArray(value)) && value.includes(String(testValue));
|
|
3468
|
-
case "startsWith":
|
|
3469
|
-
return isString(value) && value.startsWith(String(testValue));
|
|
3470
|
-
case "endsWith":
|
|
3471
|
-
return isString(value) && value.endsWith(String(testValue));
|
|
3472
|
-
case "greaterThan":
|
|
3473
|
-
return isNumber(value) && isNumber(testValue) && value > testValue;
|
|
3474
|
-
case "lessThan":
|
|
3475
|
-
return isNumber(value) && isNumber(testValue) && value < testValue;
|
|
3476
|
-
case "greaterThanOrEqualTo":
|
|
3477
|
-
return isNumber(value) && isNumber(testValue) && value >= testValue;
|
|
3478
|
-
case "lessThanOrEqualTo":
|
|
3479
|
-
return isNumber(value) && isNumber(testValue) && value <= testValue;
|
|
3480
|
-
default:
|
|
3481
|
-
return false;
|
|
3482
|
-
}
|
|
3483
|
-
})();
|
|
3484
|
-
return result;
|
|
3485
|
-
}
|
|
3486
|
-
const item = {
|
|
3487
|
-
query,
|
|
3488
|
-
startDate,
|
|
3489
|
-
endDate
|
|
3490
|
-
};
|
|
3491
|
-
const now = userAttributes.date && new Date(userAttributes.date) || /* @__PURE__ */ new Date();
|
|
3492
|
-
if (item.startDate && new Date(item.startDate) > now) {
|
|
3493
|
-
return false;
|
|
3494
|
-
} else if (item.endDate && new Date(item.endDate) < now) {
|
|
3495
|
-
return false;
|
|
3496
|
-
}
|
|
3497
|
-
if (!item.query || !item.query.length) {
|
|
3498
|
-
return true;
|
|
3499
|
-
}
|
|
3500
|
-
return item.query.every((filter) => {
|
|
3501
|
-
return objectMatchesQuery(userAttributes, filter);
|
|
3502
|
-
});
|
|
3503
|
-
}
|
|
3504
|
-
var PERSONALIZATION_SCRIPT = `function getPersonalizedVariant(variants, blockId, locale) {
|
|
3505
|
-
if (!navigator.cookieEnabled) {
|
|
3506
|
-
return;
|
|
3507
|
-
}
|
|
3508
|
-
function getCookie(name) {
|
|
3509
|
-
const nameEQ = name + '=';
|
|
3510
|
-
const ca = document.cookie.split(';');
|
|
3511
|
-
for (let i = 0; i < ca.length; i++) {
|
|
3512
|
-
let c = ca[i];
|
|
3513
|
-
while (c.charAt(0) == ' ') c = c.substring(1, c.length);
|
|
3514
|
-
if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length);
|
|
3515
|
-
}
|
|
3516
|
-
return null;
|
|
3517
|
-
}
|
|
3518
|
-
function removeVariants() {
|
|
3519
|
-
variants?.forEach(function (_, index) {
|
|
3520
|
-
document.querySelector('template[data-variant-id="' + blockId + '-' + index + '"]')?.remove();
|
|
3521
|
-
});
|
|
3522
|
-
document.querySelector('script[data-id="variants-script-' + blockId + '"]')?.remove();
|
|
3523
|
-
document.querySelector('style[data-id="variants-styles-' + blockId + '"]')?.remove();
|
|
3524
|
-
}
|
|
3525
|
-
const attributes = JSON.parse(getCookie('builder.userAttributes') || '{}');
|
|
3526
|
-
if (locale) {
|
|
3527
|
-
attributes.locale = locale;
|
|
3528
|
-
}
|
|
3529
|
-
const winningVariantIndex = variants?.findIndex(function (variant) {
|
|
3530
|
-
return filterWithCustomTargeting(attributes, variant.query, variant.startDate, variant.endDate);
|
|
3531
|
-
});
|
|
3532
|
-
const isDebug = location.href.includes('builder.debug=true');
|
|
3533
|
-
if (isDebug) {
|
|
3534
|
-
console.debug('PersonalizationContainer', {
|
|
3535
|
-
attributes,
|
|
3536
|
-
variants,
|
|
3537
|
-
winningVariantIndex
|
|
3538
|
-
});
|
|
3539
|
-
}
|
|
3540
|
-
if (winningVariantIndex !== -1) {
|
|
3541
|
-
const winningVariant = document.querySelector('template[data-variant-id="' + blockId + '-' + winningVariantIndex + '"]');
|
|
3542
|
-
if (winningVariant) {
|
|
3543
|
-
const parentNode = winningVariant.parentNode;
|
|
3544
|
-
if (parentNode) {
|
|
3545
|
-
const newParent = parentNode.cloneNode(false);
|
|
3546
|
-
newParent.appendChild(winningVariant.content.firstChild);
|
|
3547
|
-
newParent.appendChild(winningVariant.content.lastChild);
|
|
3548
|
-
parentNode.parentNode?.replaceChild(newParent, parentNode);
|
|
3549
|
-
}
|
|
3550
|
-
if (isDebug) {
|
|
3551
|
-
console.debug('PersonalizationContainer', 'Winning variant Replaced:', winningVariant);
|
|
3552
|
-
}
|
|
3553
|
-
}
|
|
3554
|
-
} else if (variants && variants.length > 0) {
|
|
3555
|
-
removeVariants();
|
|
3556
|
-
}
|
|
3557
|
-
}`;
|
|
3558
|
-
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}";
|
|
3559
|
-
|
|
3560
|
-
// src/blocks/personalization-container/helpers.ts
|
|
3561
|
-
function checkShouldRenderVariants(variants, canTrack) {
|
|
3562
|
-
const hasVariants = variants && variants.length > 0;
|
|
3563
|
-
if (TARGET === "reactNative")
|
|
3564
|
-
return false;
|
|
3565
|
-
if (!hasVariants)
|
|
3566
|
-
return false;
|
|
3567
|
-
if (!canTrack)
|
|
3568
|
-
return false;
|
|
3569
|
-
if (TARGET === "vue" || TARGET === "svelte")
|
|
3570
|
-
return true;
|
|
3571
|
-
if (isBrowser())
|
|
3572
|
-
return false;
|
|
3573
|
-
return true;
|
|
3574
|
-
}
|
|
3575
|
-
function getBlocksToRender({
|
|
3576
|
-
variants,
|
|
3577
|
-
previewingIndex,
|
|
3578
|
-
isHydrated,
|
|
3579
|
-
filteredVariants,
|
|
3580
|
-
fallbackBlocks
|
|
3581
|
-
}) {
|
|
3582
|
-
const fallback = {
|
|
3583
|
-
blocks: fallbackBlocks ?? [],
|
|
3584
|
-
path: "this.children"
|
|
3585
|
-
};
|
|
3586
|
-
if (isHydrated && isEditing()) {
|
|
3587
|
-
if (typeof previewingIndex === "number" && previewingIndex < (variants?.length ?? 0)) {
|
|
3588
|
-
const variant = variants[previewingIndex];
|
|
3589
|
-
return {
|
|
3590
|
-
blocks: variant.blocks,
|
|
3591
|
-
path: `component.options.variants.${previewingIndex}.blocks`
|
|
3592
|
-
};
|
|
3593
|
-
}
|
|
3594
|
-
return fallback;
|
|
3595
|
-
}
|
|
3596
|
-
if (isBrowser()) {
|
|
3597
|
-
const winningVariant = filteredVariants?.[0];
|
|
3598
|
-
if (winningVariant) {
|
|
3599
|
-
return {
|
|
3600
|
-
blocks: winningVariant.blocks,
|
|
3601
|
-
path: `component.options.variants.${variants?.indexOf(winningVariant)}.blocks`
|
|
3602
|
-
};
|
|
3603
|
-
}
|
|
3604
|
-
}
|
|
3605
|
-
return fallback;
|
|
3606
|
-
}
|
|
3607
|
-
var getPersonalizationScript = (variants, blockId, locale) => {
|
|
3608
|
-
return `
|
|
3609
|
-
(function() {
|
|
3610
|
-
${FILTER_WITH_CUSTOM_TARGETING_SCRIPT}
|
|
3611
|
-
${PERSONALIZATION_SCRIPT}
|
|
3612
|
-
getPersonalizedVariant(${JSON.stringify(variants)}, "${blockId}"${locale ? `, "${locale}"` : ""})
|
|
3613
|
-
})();
|
|
3614
|
-
`;
|
|
3615
|
-
};
|
|
3616
|
-
|
|
3617
3591
|
// src/blocks/personalization-container/personalization-container.tsx
|
|
3618
3592
|
var _tmpl$9 = /* @__PURE__ */ template(`<div>`);
|
|
3619
|
-
var _tmpl$25 = /* @__PURE__ */ template(`<template>`);
|
|
3620
3593
|
function PersonalizationContainer(props) {
|
|
3621
3594
|
const [userAttributes, setUserAttributes] = createSignal(userAttributesService.getUserAttributes());
|
|
3622
3595
|
const [scriptStr, setScriptStr] = createSignal(getPersonalizationScript(props.variants, props.builderBlock?.id || "none", props.builderContext?.rootState?.locale));
|
|
3596
|
+
const [updateVisibilityStylesScript, setUpdateVisibilityStylesScript] = createSignal(getUpdateVisibilityStylesScript(props.variants, props.builderBlock?.id || "none", props.builderContext?.rootState?.locale));
|
|
3623
3597
|
const [unsubscribers, setUnsubscribers] = createSignal([]);
|
|
3624
3598
|
const [shouldRenderVariants, setShouldRenderVariants] = createSignal(checkShouldRenderVariants(props.variants, getDefaultCanTrack(props.builderContext?.canTrack)));
|
|
3625
|
-
const [
|
|
3599
|
+
const [shouldResetVariants, setShouldResetVariants] = createSignal(false);
|
|
3600
|
+
const attrs = createMemo(() => {
|
|
3601
|
+
return {
|
|
3602
|
+
...props.attributes,
|
|
3603
|
+
...{},
|
|
3604
|
+
[getClassPropName()]: `builder-personalization-container ${props.attributes[getClassPropName()] || ""}`
|
|
3605
|
+
};
|
|
3606
|
+
});
|
|
3626
3607
|
const filteredVariants = createMemo(() => {
|
|
3627
3608
|
return (props.variants || []).filter((variant) => {
|
|
3628
3609
|
return filterWithCustomTargeting({
|
|
@@ -3637,26 +3618,26 @@ function PersonalizationContainer(props) {
|
|
|
3637
3618
|
return getBlocksToRender({
|
|
3638
3619
|
variants: props.variants,
|
|
3639
3620
|
fallbackBlocks: props.builderBlock?.children,
|
|
3640
|
-
isHydrated:
|
|
3621
|
+
isHydrated: shouldResetVariants(),
|
|
3641
3622
|
filteredVariants: filteredVariants(),
|
|
3642
3623
|
previewingIndex: props.previewingIndex
|
|
3643
3624
|
});
|
|
3644
3625
|
});
|
|
3645
3626
|
const hideVariantsStyleString = createMemo(() => {
|
|
3646
|
-
return (props.variants || []).map((_, index) => `[data-variant-id="${props.builderBlock?.id}-${index}"] { display: none; } `).join("");
|
|
3627
|
+
return (props.variants || []).map((_, index) => `div[data-variant-id="${props.builderBlock?.id}-${index}"] { display: none !important; } `).join("");
|
|
3647
3628
|
});
|
|
3648
3629
|
let rootRef;
|
|
3649
3630
|
onMount(() => {
|
|
3650
|
-
|
|
3651
|
-
const unsub = userAttributesService.subscribeOnUserAttributesChange((
|
|
3652
|
-
setUserAttributes(
|
|
3631
|
+
setShouldResetVariants(true);
|
|
3632
|
+
const unsub = userAttributesService.subscribeOnUserAttributesChange((attrs2) => {
|
|
3633
|
+
setUserAttributes(attrs2);
|
|
3653
3634
|
});
|
|
3654
3635
|
if (!(isEditing() || isPreviewing())) {
|
|
3655
3636
|
const variant = filteredVariants()[0];
|
|
3656
3637
|
if (rootRef) {
|
|
3657
3638
|
rootRef.dispatchEvent(new CustomEvent("builder.variantLoaded", {
|
|
3658
3639
|
detail: {
|
|
3659
|
-
variant: variant ||
|
|
3640
|
+
variant: variant || DEFAULT_INDEX,
|
|
3660
3641
|
content: props.builderContext?.content
|
|
3661
3642
|
},
|
|
3662
3643
|
bubbles: true
|
|
@@ -3666,7 +3647,7 @@ function PersonalizationContainer(props) {
|
|
|
3666
3647
|
if (entry.isIntersecting && rootRef) {
|
|
3667
3648
|
rootRef.dispatchEvent(new CustomEvent("builder.variantDisplayed", {
|
|
3668
3649
|
detail: {
|
|
3669
|
-
variant: variant ||
|
|
3650
|
+
variant: variant || DEFAULT_INDEX,
|
|
3670
3651
|
content: props.builderContext?.content
|
|
3671
3652
|
},
|
|
3672
3653
|
bubbles: true
|
|
@@ -3683,70 +3664,158 @@ function PersonalizationContainer(props) {
|
|
|
3683
3664
|
const _el$ = _tmpl$9();
|
|
3684
3665
|
const _ref$ = rootRef;
|
|
3685
3666
|
typeof _ref$ === "function" ? use(_ref$, _el$) : rootRef = _el$;
|
|
3686
|
-
spread(_el$, mergeProps(
|
|
3687
|
-
get ["class"]() {
|
|
3688
|
-
return `builder-personalization-container ${props.attributes?.className || ""}`;
|
|
3689
|
-
}
|
|
3690
|
-
}, () => props.attributes), false, true);
|
|
3667
|
+
spread(_el$, mergeProps(attrs), false, true);
|
|
3691
3668
|
insert(_el$, createComponent(Show, {
|
|
3692
3669
|
get when() {
|
|
3693
|
-
return
|
|
3670
|
+
return memo(() => !!shouldResetVariants())() && SDKS_REQUIRING_RESET_APPROACH.includes(TARGET);
|
|
3694
3671
|
},
|
|
3695
3672
|
get children() {
|
|
3696
|
-
return
|
|
3697
|
-
get
|
|
3698
|
-
return
|
|
3673
|
+
return createComponent(blocks_default, {
|
|
3674
|
+
get blocks() {
|
|
3675
|
+
return blocksToRender().blocks;
|
|
3699
3676
|
},
|
|
3700
|
-
|
|
3701
|
-
|
|
3702
|
-
return (() => {
|
|
3703
|
-
const _el$2 = _tmpl$25();
|
|
3704
|
-
setAttribute(_el$2, "key", index);
|
|
3705
|
-
insert(_el$2, createComponent(blocks_default, {
|
|
3706
|
-
get blocks() {
|
|
3707
|
-
return variant.blocks;
|
|
3708
|
-
},
|
|
3709
|
-
get parent() {
|
|
3710
|
-
return props.builderBlock?.id;
|
|
3711
|
-
},
|
|
3712
|
-
path: `component.options.variants.${index}.blocks`
|
|
3713
|
-
}));
|
|
3714
|
-
effect(() => setAttribute(_el$2, "data-variant-id", `${props.builderBlock?.id}-${index}`));
|
|
3715
|
-
return _el$2;
|
|
3716
|
-
})();
|
|
3717
|
-
}
|
|
3718
|
-
}), createComponent(inlined_styles_default, {
|
|
3719
|
-
get nonce() {
|
|
3720
|
-
return props.builderContext?.nonce || "";
|
|
3677
|
+
get parent() {
|
|
3678
|
+
return props.builderBlock?.id;
|
|
3721
3679
|
},
|
|
3722
|
-
get
|
|
3723
|
-
return
|
|
3680
|
+
get path() {
|
|
3681
|
+
return blocksToRender().path;
|
|
3724
3682
|
},
|
|
3725
|
-
get
|
|
3726
|
-
return
|
|
3727
|
-
}
|
|
3728
|
-
}), createComponent(inlined_script_default, {
|
|
3729
|
-
get nonce() {
|
|
3730
|
-
return props.builderContext?.nonce || "";
|
|
3683
|
+
get context() {
|
|
3684
|
+
return props.builderContext;
|
|
3731
3685
|
},
|
|
3732
|
-
get
|
|
3733
|
-
return
|
|
3686
|
+
get registeredComponents() {
|
|
3687
|
+
return props.builderComponents;
|
|
3734
3688
|
},
|
|
3735
|
-
get
|
|
3736
|
-
return
|
|
3689
|
+
get BlocksWrapperProps() {
|
|
3690
|
+
return {
|
|
3691
|
+
...props.builderContext?.BlocksWrapperProps,
|
|
3692
|
+
"data-variant-id": `${props.builderBlock?.id}-${blocksToRender().index}`
|
|
3693
|
+
};
|
|
3737
3694
|
}
|
|
3738
|
-
})
|
|
3695
|
+
});
|
|
3739
3696
|
}
|
|
3740
3697
|
}), null);
|
|
3741
|
-
insert(_el$, createComponent(
|
|
3742
|
-
get
|
|
3743
|
-
return
|
|
3744
|
-
},
|
|
3745
|
-
get parent() {
|
|
3746
|
-
return props.builderBlock?.id;
|
|
3698
|
+
insert(_el$, createComponent(Show, {
|
|
3699
|
+
get when() {
|
|
3700
|
+
return memo(() => !!!shouldResetVariants())() && SDKS_REQUIRING_RESET_APPROACH.includes(TARGET) || !SDKS_REQUIRING_RESET_APPROACH.includes(TARGET);
|
|
3747
3701
|
},
|
|
3748
|
-
get
|
|
3749
|
-
return
|
|
3702
|
+
get children() {
|
|
3703
|
+
return [createComponent(Show, {
|
|
3704
|
+
get when() {
|
|
3705
|
+
return shouldRenderVariants();
|
|
3706
|
+
},
|
|
3707
|
+
get children() {
|
|
3708
|
+
return [createComponent(inlined_styles_default, {
|
|
3709
|
+
get nonce() {
|
|
3710
|
+
return props.builderContext?.nonce || "";
|
|
3711
|
+
},
|
|
3712
|
+
get styles() {
|
|
3713
|
+
return hideVariantsStyleString();
|
|
3714
|
+
},
|
|
3715
|
+
get id() {
|
|
3716
|
+
return `variants-styles-${props.builderBlock?.id}`;
|
|
3717
|
+
}
|
|
3718
|
+
}), createComponent(inlined_script_default, {
|
|
3719
|
+
get nonce() {
|
|
3720
|
+
return props.builderContext?.nonce || "";
|
|
3721
|
+
},
|
|
3722
|
+
get scriptStr() {
|
|
3723
|
+
return updateVisibilityStylesScript();
|
|
3724
|
+
},
|
|
3725
|
+
get id() {
|
|
3726
|
+
return `variants-visibility-script-${props.builderBlock?.id}`;
|
|
3727
|
+
}
|
|
3728
|
+
}), createComponent(For, {
|
|
3729
|
+
get each() {
|
|
3730
|
+
return props.variants;
|
|
3731
|
+
},
|
|
3732
|
+
children: (variant, _index) => {
|
|
3733
|
+
const index = _index();
|
|
3734
|
+
return createComponent(blocks_default, {
|
|
3735
|
+
get key() {
|
|
3736
|
+
return `${props.builderBlock?.id}-${index}`;
|
|
3737
|
+
},
|
|
3738
|
+
get BlocksWrapperProps() {
|
|
3739
|
+
return {
|
|
3740
|
+
...props.builderContext?.BlocksWrapperProps,
|
|
3741
|
+
"aria-hidden": true,
|
|
3742
|
+
hidden: true,
|
|
3743
|
+
"data-variant-id": `${props.builderBlock?.id}-${index}`
|
|
3744
|
+
};
|
|
3745
|
+
},
|
|
3746
|
+
get blocks() {
|
|
3747
|
+
return variant.blocks;
|
|
3748
|
+
},
|
|
3749
|
+
get parent() {
|
|
3750
|
+
return props.builderBlock?.id;
|
|
3751
|
+
},
|
|
3752
|
+
path: `component.options.variants.${index}.blocks`,
|
|
3753
|
+
get context() {
|
|
3754
|
+
return props.builderContext;
|
|
3755
|
+
},
|
|
3756
|
+
get registeredComponents() {
|
|
3757
|
+
return props.builderComponents;
|
|
3758
|
+
},
|
|
3759
|
+
get children() {
|
|
3760
|
+
return createComponent(inlined_script_default, {
|
|
3761
|
+
get nonce() {
|
|
3762
|
+
return props.builderContext?.nonce || "";
|
|
3763
|
+
},
|
|
3764
|
+
get scriptStr() {
|
|
3765
|
+
return scriptStr();
|
|
3766
|
+
},
|
|
3767
|
+
get id() {
|
|
3768
|
+
return `variants-script-${props.builderBlock?.id}-${index}`;
|
|
3769
|
+
}
|
|
3770
|
+
});
|
|
3771
|
+
}
|
|
3772
|
+
});
|
|
3773
|
+
}
|
|
3774
|
+
})];
|
|
3775
|
+
}
|
|
3776
|
+
}), createComponent(blocks_default, {
|
|
3777
|
+
get blocks() {
|
|
3778
|
+
return blocksToRender().blocks;
|
|
3779
|
+
},
|
|
3780
|
+
get parent() {
|
|
3781
|
+
return props.builderBlock?.id;
|
|
3782
|
+
},
|
|
3783
|
+
get path() {
|
|
3784
|
+
return blocksToRender().path;
|
|
3785
|
+
},
|
|
3786
|
+
get context() {
|
|
3787
|
+
return props.builderContext;
|
|
3788
|
+
},
|
|
3789
|
+
get registeredComponents() {
|
|
3790
|
+
return props.builderComponents;
|
|
3791
|
+
},
|
|
3792
|
+
get BlocksWrapperProps() {
|
|
3793
|
+
return {
|
|
3794
|
+
...props.builderContext?.BlocksWrapperProps,
|
|
3795
|
+
"data-variant-id": `${props.builderBlock?.id}-${blocksToRender().index}`
|
|
3796
|
+
};
|
|
3797
|
+
},
|
|
3798
|
+
get children() {
|
|
3799
|
+
return createComponent(Show, {
|
|
3800
|
+
get when() {
|
|
3801
|
+
return shouldRenderVariants();
|
|
3802
|
+
},
|
|
3803
|
+
get children() {
|
|
3804
|
+
return createComponent(inlined_script_default, {
|
|
3805
|
+
get nonce() {
|
|
3806
|
+
return props.builderContext?.nonce || "";
|
|
3807
|
+
},
|
|
3808
|
+
get scriptStr() {
|
|
3809
|
+
return scriptStr();
|
|
3810
|
+
},
|
|
3811
|
+
get id() {
|
|
3812
|
+
return `variants-script-${props.builderBlock?.id}-${DEFAULT_INDEX}`;
|
|
3813
|
+
}
|
|
3814
|
+
});
|
|
3815
|
+
}
|
|
3816
|
+
});
|
|
3817
|
+
}
|
|
3818
|
+
})];
|
|
3750
3819
|
}
|
|
3751
3820
|
}), null);
|
|
3752
3821
|
return _el$;
|
|
@@ -4033,7 +4102,7 @@ var componentInfo10 = {
|
|
|
4033
4102
|
}
|
|
4034
4103
|
};
|
|
4035
4104
|
var _tmpl$11 = /* @__PURE__ */ template(`<div>`);
|
|
4036
|
-
var _tmpl$
|
|
4105
|
+
var _tmpl$25 = /* @__PURE__ */ template(`<div><div class=builder-tabs-wrap>`);
|
|
4037
4106
|
var _tmpl$33 = /* @__PURE__ */ template(`<span>`);
|
|
4038
4107
|
function Tabs(props) {
|
|
4039
4108
|
const [activeTab, setActiveTab] = createSignal(props.defaultActiveTab ? props.defaultActiveTab - 1 : 0);
|
|
@@ -4048,7 +4117,7 @@ function Tabs(props) {
|
|
|
4048
4117
|
}
|
|
4049
4118
|
}
|
|
4050
4119
|
return (() => {
|
|
4051
|
-
const _el$ = _tmpl$
|
|
4120
|
+
const _el$ = _tmpl$25(), _el$2 = _el$.firstChild;
|
|
4052
4121
|
_el$2.style.setProperty("display", "flex");
|
|
4053
4122
|
_el$2.style.setProperty("flex-direction", "row");
|
|
4054
4123
|
_el$2.style.setProperty("overflow", "auto");
|
|
@@ -4580,7 +4649,7 @@ function logFetch(url) {
|
|
|
4580
4649
|
|
|
4581
4650
|
// src/blocks/form/form/form.tsx
|
|
4582
4651
|
var _tmpl$15 = /* @__PURE__ */ template(`<pre class="builder-form-error-text pre-04a43b72">`);
|
|
4583
|
-
var _tmpl$
|
|
4652
|
+
var _tmpl$26 = /* @__PURE__ */ template(`<form>`);
|
|
4584
4653
|
var _tmpl$34 = /* @__PURE__ */ template(`<style>.pre-04a43b72 {
|
|
4585
4654
|
padding: 10px;
|
|
4586
4655
|
color: red;
|
|
@@ -4773,7 +4842,7 @@ function FormComponent(props) {
|
|
|
4773
4842
|
}
|
|
4774
4843
|
let formRef;
|
|
4775
4844
|
return [(() => {
|
|
4776
|
-
const _el$ = _tmpl$
|
|
4845
|
+
const _el$ = _tmpl$26();
|
|
4777
4846
|
_el$.addEventListener("submit", (event) => onSubmit(event));
|
|
4778
4847
|
const _ref$ = formRef;
|
|
4779
4848
|
typeof _ref$ === "function" ? use(_ref$, _el$) : formRef = _el$;
|
|
@@ -4985,7 +5054,7 @@ var componentInfo16 = {
|
|
|
4985
5054
|
noWrap: true
|
|
4986
5055
|
};
|
|
4987
5056
|
var _tmpl$17 = /* @__PURE__ */ template(`<select>`);
|
|
4988
|
-
var _tmpl$
|
|
5057
|
+
var _tmpl$27 = /* @__PURE__ */ template(`<option>`);
|
|
4989
5058
|
function SelectComponent(props) {
|
|
4990
5059
|
return (() => {
|
|
4991
5060
|
const _el$ = _tmpl$17();
|
|
@@ -5013,7 +5082,7 @@ function SelectComponent(props) {
|
|
|
5013
5082
|
children: (option, _index) => {
|
|
5014
5083
|
const index = _index();
|
|
5015
5084
|
return (() => {
|
|
5016
|
-
const _el$2 = _tmpl$
|
|
5085
|
+
const _el$2 = _tmpl$27();
|
|
5017
5086
|
insert(_el$2, () => option.name || option.value);
|
|
5018
5087
|
effect(() => setAttribute(_el$2, "key", `${option.name}-${index}`));
|
|
5019
5088
|
effect(() => _el$2.value = option.value);
|
|
@@ -5257,7 +5326,7 @@ var componentInfo20 = {
|
|
|
5257
5326
|
}
|
|
5258
5327
|
};
|
|
5259
5328
|
var _tmpl$21 = /* @__PURE__ */ template(`<div>`);
|
|
5260
|
-
var _tmpl$
|
|
5329
|
+
var _tmpl$28 = /* @__PURE__ */ template(`<div><video class=builder-video><source type=video/mp4>`);
|
|
5261
5330
|
function Video(props) {
|
|
5262
5331
|
const [lazyVideoObserver, setLazyVideoObserver] = createSignal(void 0);
|
|
5263
5332
|
const videoProps = createMemo(() => {
|
|
@@ -5312,7 +5381,7 @@ function Video(props) {
|
|
|
5312
5381
|
}
|
|
5313
5382
|
});
|
|
5314
5383
|
return (() => {
|
|
5315
|
-
const _el$ = _tmpl$
|
|
5384
|
+
const _el$ = _tmpl$28(), _el$2 = _el$.firstChild, _el$3 = _el$2.firstChild;
|
|
5316
5385
|
_el$.style.setProperty("position", "relative");
|
|
5317
5386
|
const _ref$ = videoRef;
|
|
5318
5387
|
typeof _ref$ === "function" ? use(_ref$, _el$2) : videoRef = _el$2;
|
|
@@ -5449,7 +5518,7 @@ var getDefaultRegisteredComponents = () => [{
|
|
|
5449
5518
|
}, {
|
|
5450
5519
|
component: text_default,
|
|
5451
5520
|
...componentInfo11
|
|
5452
|
-
}, ...TARGET
|
|
5521
|
+
}, ...SDKS_SUPPORTING_PERSONALIZATION.includes(TARGET) ? [{
|
|
5453
5522
|
component: personalization_container_default,
|
|
5454
5523
|
...componentInfo6
|
|
5455
5524
|
}] : [], ...TARGET === "rsc" ? [] : [{
|
|
@@ -5486,7 +5555,7 @@ var UPDATE_VARIANT_VISIBILITY_SCRIPT = "function updateVariantVisibility(variant
|
|
|
5486
5555
|
|
|
5487
5556
|
// src/components/content-variants/helpers.ts
|
|
5488
5557
|
var UPDATE_COOKIES_AND_STYLES_SCRIPT_NAME = "builderIoAbTest";
|
|
5489
|
-
var
|
|
5558
|
+
var UPDATE_VARIANT_VISIBILITY_SCRIPT_FN_NAME2 = "builderIoRenderContent";
|
|
5490
5559
|
var getVariants = (content) => Object.values(content?.variations || {}).map((variant) => ({
|
|
5491
5560
|
...variant,
|
|
5492
5561
|
testVariationId: variant.id,
|
|
@@ -5511,20 +5580,20 @@ var checkShouldRenderVariants2 = ({
|
|
|
5511
5580
|
};
|
|
5512
5581
|
var getIsHydrationTarget = (target) => target === "react" || target === "reactNative";
|
|
5513
5582
|
var isAngularSDK = TARGET === "angular";
|
|
5514
|
-
var
|
|
5583
|
+
var isHydrationTarget2 = getIsHydrationTarget(TARGET);
|
|
5515
5584
|
var getInitVariantsFnsScriptString = () => `
|
|
5516
5585
|
window.${UPDATE_COOKIES_AND_STYLES_SCRIPT_NAME} = ${UPDATE_COOKIES_AND_STYLES_SCRIPT}
|
|
5517
|
-
window.${
|
|
5586
|
+
window.${UPDATE_VARIANT_VISIBILITY_SCRIPT_FN_NAME2} = ${UPDATE_VARIANT_VISIBILITY_SCRIPT}
|
|
5518
5587
|
`;
|
|
5519
5588
|
var getUpdateCookieAndStylesScript = (variants, contentId) => `
|
|
5520
5589
|
window.${UPDATE_COOKIES_AND_STYLES_SCRIPT_NAME}(
|
|
5521
|
-
"${contentId}",${JSON.stringify(variants)}, ${
|
|
5590
|
+
"${contentId}",${JSON.stringify(variants)}, ${isHydrationTarget2}, ${isAngularSDK}
|
|
5522
5591
|
)`;
|
|
5523
5592
|
var getUpdateVariantVisibilityScript = ({
|
|
5524
5593
|
contentId,
|
|
5525
5594
|
variationId
|
|
5526
|
-
}) => `window.${
|
|
5527
|
-
"${variationId}", "${contentId}", ${
|
|
5595
|
+
}) => `window.${UPDATE_VARIANT_VISIBILITY_SCRIPT_FN_NAME2}(
|
|
5596
|
+
"${variationId}", "${contentId}", ${isHydrationTarget2}
|
|
5528
5597
|
)`;
|
|
5529
5598
|
|
|
5530
5599
|
// src/helpers/preview-lru-cache/get.ts
|
|
@@ -5533,7 +5602,7 @@ function getPreviewContent(_searchParams) {
|
|
|
5533
5602
|
}
|
|
5534
5603
|
|
|
5535
5604
|
// src/constants/sdk-version.ts
|
|
5536
|
-
var SDK_VERSION = "4.0.
|
|
5605
|
+
var SDK_VERSION = "4.0.9";
|
|
5537
5606
|
|
|
5538
5607
|
// src/helpers/sdk-headers.ts
|
|
5539
5608
|
var getSdkHeaders = () => ({
|
|
@@ -6949,7 +7018,7 @@ function ContentVariants(props) {
|
|
|
6949
7018
|
return !props.isNestedRender && TARGET !== "reactNative";
|
|
6950
7019
|
},
|
|
6951
7020
|
get children() {
|
|
6952
|
-
return createComponent(inlined_script_default, {
|
|
7021
|
+
return [createComponent(inlined_script_default, {
|
|
6953
7022
|
id: "builderio-init-variants-fns",
|
|
6954
7023
|
get scriptStr() {
|
|
6955
7024
|
return getInitVariantsFnsScriptString();
|
|
@@ -6957,7 +7026,22 @@ function ContentVariants(props) {
|
|
|
6957
7026
|
get nonce() {
|
|
6958
7027
|
return props.nonce || "";
|
|
6959
7028
|
}
|
|
6960
|
-
})
|
|
7029
|
+
}), createComponent(Show, {
|
|
7030
|
+
get when() {
|
|
7031
|
+
return SDKS_SUPPORTING_PERSONALIZATION.includes(TARGET);
|
|
7032
|
+
},
|
|
7033
|
+
get children() {
|
|
7034
|
+
return createComponent(inlined_script_default, {
|
|
7035
|
+
id: "builderio-init-personalization-variants-fns",
|
|
7036
|
+
get nonce() {
|
|
7037
|
+
return props.nonce || "";
|
|
7038
|
+
},
|
|
7039
|
+
get scriptStr() {
|
|
7040
|
+
return getInitPersonalizationVariantsFnsScriptString();
|
|
7041
|
+
}
|
|
7042
|
+
});
|
|
7043
|
+
}
|
|
7044
|
+
})];
|
|
6961
7045
|
}
|
|
6962
7046
|
}), createComponent(Show, {
|
|
6963
7047
|
get when() {
|
|
@@ -7145,9 +7229,10 @@ var fetchSymbolContent = async ({
|
|
|
7145
7229
|
};
|
|
7146
7230
|
|
|
7147
7231
|
// src/blocks/symbol/symbol.tsx
|
|
7148
|
-
var _tmpl$
|
|
7232
|
+
var _tmpl$29 = /* @__PURE__ */ template(`<div>`);
|
|
7149
7233
|
function Symbol(props) {
|
|
7150
7234
|
const [contentToUse, setContentToUse] = createSignal(props.symbol?.content);
|
|
7235
|
+
const [symbolEntry, setSymbolEntry] = createSignal(props.symbol?.entry);
|
|
7151
7236
|
const blocksWrapper = createMemo(() => {
|
|
7152
7237
|
return "div";
|
|
7153
7238
|
});
|
|
@@ -7158,7 +7243,7 @@ function Symbol(props) {
|
|
|
7158
7243
|
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(" ");
|
|
7159
7244
|
});
|
|
7160
7245
|
function setContent() {
|
|
7161
|
-
if (contentToUse())
|
|
7246
|
+
if (contentToUse() && symbolEntry() === props.symbol?.entry)
|
|
7162
7247
|
return;
|
|
7163
7248
|
fetchSymbolContent({
|
|
7164
7249
|
symbol: props.symbol,
|
|
@@ -7166,6 +7251,7 @@ function Symbol(props) {
|
|
|
7166
7251
|
}).then((newContent) => {
|
|
7167
7252
|
if (newContent) {
|
|
7168
7253
|
setContentToUse(newContent);
|
|
7254
|
+
setSymbolEntry(props.symbol?.entry);
|
|
7169
7255
|
}
|
|
7170
7256
|
});
|
|
7171
7257
|
}
|
|
@@ -7177,7 +7263,7 @@ function Symbol(props) {
|
|
|
7177
7263
|
}
|
|
7178
7264
|
createEffect(on(() => [onUpdateFn_0_props_symbol()], onUpdateFn_0));
|
|
7179
7265
|
return (() => {
|
|
7180
|
-
const _el$ = _tmpl$
|
|
7266
|
+
const _el$ = _tmpl$29();
|
|
7181
7267
|
spread(_el$, mergeProps({
|
|
7182
7268
|
get ["class"]() {
|
|
7183
7269
|
return className();
|