@builder.io/sdk-svelte 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/lib/browser/blocks/personalization-container/component-info.js +2 -1
- package/lib/browser/blocks/personalization-container/helpers/inlined-fns.d.ts +4 -1
- package/lib/browser/blocks/personalization-container/helpers/inlined-fns.js +45 -1
- package/lib/browser/blocks/personalization-container/helpers.d.ts +24 -4
- package/lib/browser/blocks/personalization-container/helpers.js +50 -19
- package/lib/browser/blocks/personalization-container/personalization-container.svelte +86 -38
- package/lib/browser/blocks/personalization-container/personalization-container.svelte.d.ts +2 -1
- package/lib/browser/blocks/personalization-container/personalization-container.types.d.ts +2 -2
- package/lib/browser/blocks/symbol/symbol.svelte +3 -1
- package/lib/browser/components/block/components/interactive-element.svelte +5 -2
- package/lib/browser/components/blocks/blocks.svelte +6 -4
- package/lib/browser/components/blocks/blocks.svelte.d.ts +5 -2
- package/lib/browser/components/blocks/blocks.types.d.ts +1 -1
- package/lib/browser/components/content-variants/content-variants.svelte +9 -0
- package/lib/browser/constants/builder-registered-components.js +2 -1
- package/lib/browser/constants/sdk-version.d.ts +1 -1
- package/lib/browser/constants/sdk-version.js +1 -1
- package/lib/edge/blocks/personalization-container/component-info.js +2 -1
- package/lib/edge/blocks/personalization-container/helpers/inlined-fns.d.ts +4 -1
- package/lib/edge/blocks/personalization-container/helpers/inlined-fns.js +45 -1
- package/lib/edge/blocks/personalization-container/helpers.d.ts +24 -4
- package/lib/edge/blocks/personalization-container/helpers.js +50 -19
- package/lib/edge/blocks/personalization-container/personalization-container.svelte +86 -38
- package/lib/edge/blocks/personalization-container/personalization-container.svelte.d.ts +2 -1
- package/lib/edge/blocks/personalization-container/personalization-container.types.d.ts +2 -2
- package/lib/edge/blocks/symbol/symbol.svelte +3 -1
- package/lib/edge/components/block/components/interactive-element.svelte +5 -2
- package/lib/edge/components/blocks/blocks.svelte +6 -4
- package/lib/edge/components/blocks/blocks.svelte.d.ts +5 -2
- package/lib/edge/components/blocks/blocks.types.d.ts +1 -1
- package/lib/edge/components/content-variants/content-variants.svelte +9 -0
- package/lib/edge/constants/builder-registered-components.js +2 -1
- package/lib/edge/constants/sdk-version.d.ts +1 -1
- package/lib/edge/constants/sdk-version.js +1 -1
- package/lib/node/blocks/personalization-container/component-info.js +2 -1
- package/lib/node/blocks/personalization-container/helpers/inlined-fns.d.ts +4 -1
- package/lib/node/blocks/personalization-container/helpers/inlined-fns.js +45 -1
- package/lib/node/blocks/personalization-container/helpers.d.ts +24 -4
- package/lib/node/blocks/personalization-container/helpers.js +50 -19
- package/lib/node/blocks/personalization-container/personalization-container.svelte +86 -38
- package/lib/node/blocks/personalization-container/personalization-container.svelte.d.ts +2 -1
- package/lib/node/blocks/personalization-container/personalization-container.types.d.ts +2 -2
- package/lib/node/blocks/symbol/symbol.svelte +3 -1
- package/lib/node/components/block/components/interactive-element.svelte +5 -2
- package/lib/node/components/blocks/blocks.svelte +6 -4
- package/lib/node/components/blocks/blocks.svelte.d.ts +5 -2
- package/lib/node/components/blocks/blocks.types.d.ts +1 -1
- package/lib/node/components/content-variants/content-variants.svelte +9 -0
- package/lib/node/constants/builder-registered-components.js +2 -1
- package/lib/node/constants/sdk-version.d.ts +1 -1
- package/lib/node/constants/sdk-version.js +1 -1
- package/package.json +2 -2
- package/src/blocks/personalization-container/component-info.ts +2 -1
- package/src/blocks/personalization-container/helpers/inlined-fns.ts +42 -2
- package/src/blocks/personalization-container/helpers.ts +60 -24
- package/src/blocks/personalization-container/personalization-container.svelte +95 -38
- package/src/blocks/personalization-container/personalization-container.types.ts +2 -2
- package/src/blocks/symbol/symbol.svelte +3 -1
- package/src/components/block/components/interactive-element.svelte +8 -2
- package/src/components/blocks/blocks-wrapper.svelte +13 -1
- package/src/components/blocks/blocks.svelte +7 -4
- package/src/components/blocks/blocks.types.ts +1 -1
- package/src/components/content-variants/content-variants.svelte +12 -0
- package/src/constants/builder-registered-components.ts +2 -1
- package/src/constants/sdk-version.ts +1 -1
|
@@ -3,6 +3,9 @@
|
|
|
3
3
|
* They cannot import anything.
|
|
4
4
|
*/
|
|
5
5
|
import type { Query, UserAttributes } from '../helpers';
|
|
6
|
+
import { type PersonalizationContainerProps } from '../personalization-container.types';
|
|
6
7
|
export declare function filterWithCustomTargeting(userAttributes: UserAttributes, query: Query[], startDate?: string, endDate?: string): boolean;
|
|
7
|
-
export declare
|
|
8
|
+
export declare function updateVisibilityStylesScript(variants: PersonalizationContainerProps['variants'], blockId: string, isHydrationTarget: boolean, locale?: string): void;
|
|
9
|
+
export declare const 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}";
|
|
8
10
|
export declare const 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}";
|
|
11
|
+
export declare const 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}";
|
|
@@ -83,5 +83,49 @@ export function filterWithCustomTargeting(userAttributes, query, startDate, endD
|
|
|
83
83
|
return objectMatchesQuery(userAttributes, filter);
|
|
84
84
|
});
|
|
85
85
|
}
|
|
86
|
-
export
|
|
86
|
+
export function updateVisibilityStylesScript(variants, blockId, isHydrationTarget, locale) {
|
|
87
|
+
function getCookie(name) {
|
|
88
|
+
const nameEQ = name + '=';
|
|
89
|
+
const ca = document.cookie.split(';');
|
|
90
|
+
for (let i = 0; i < ca.length; i++) {
|
|
91
|
+
let c = ca[i];
|
|
92
|
+
while (c.charAt(0) == ' ')
|
|
93
|
+
c = c.substring(1, c.length);
|
|
94
|
+
if (c.indexOf(nameEQ) == 0)
|
|
95
|
+
return c.substring(nameEQ.length, c.length);
|
|
96
|
+
}
|
|
97
|
+
return null;
|
|
98
|
+
}
|
|
99
|
+
const visibilityStylesEl = document.currentScript?.previousElementSibling;
|
|
100
|
+
if (!visibilityStylesEl) {
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
if (isHydrationTarget) {
|
|
104
|
+
visibilityStylesEl.remove();
|
|
105
|
+
const currentScript = document.currentScript;
|
|
106
|
+
if (currentScript) {
|
|
107
|
+
currentScript.remove();
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
else {
|
|
111
|
+
const attributes = JSON.parse(getCookie('builder.userAttributes') || '{}');
|
|
112
|
+
if (locale) {
|
|
113
|
+
attributes.locale = locale;
|
|
114
|
+
}
|
|
115
|
+
const winningVariantIndex = variants?.findIndex(function (variant) {
|
|
116
|
+
return window.filterWithCustomTargeting(attributes, variant.query, variant.startDate, variant.endDate);
|
|
117
|
+
});
|
|
118
|
+
if (winningVariantIndex !== -1) {
|
|
119
|
+
let newStyleStr = variants?.map((_, index) => {
|
|
120
|
+
if (index === winningVariantIndex)
|
|
121
|
+
return '';
|
|
122
|
+
return `div[data-variant-id="${blockId}-${index}"] { display: none !important; } `;
|
|
123
|
+
}).join('') || '';
|
|
124
|
+
newStyleStr += `div[data-variant-id="${blockId}-default"] { display: none !important; } `;
|
|
125
|
+
visibilityStylesEl.innerHTML = newStyleStr;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
export const 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}";
|
|
87
130
|
export const 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}";
|
|
131
|
+
export const 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}";
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import type { BuilderBlock } from '../../types/builder-block';
|
|
2
|
+
import type { Target } from '../../types/targets';
|
|
2
3
|
import type { PersonalizationContainerProps } from './personalization-container.types';
|
|
4
|
+
export declare const DEFAULT_INDEX = "default";
|
|
3
5
|
export type UserAttributes = {
|
|
4
6
|
date?: string | Date;
|
|
5
7
|
urlPath?: string;
|
|
@@ -12,6 +14,25 @@ export type Query = {
|
|
|
12
14
|
operator: QueryOperator;
|
|
13
15
|
value: QueryValue;
|
|
14
16
|
};
|
|
17
|
+
type BlocksToRenderReturnType = {
|
|
18
|
+
blocks: BuilderBlock[];
|
|
19
|
+
path: string;
|
|
20
|
+
index: number | typeof DEFAULT_INDEX;
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* SDKs that support Variant Containers
|
|
24
|
+
*/
|
|
25
|
+
export declare const SDKS_SUPPORTING_PERSONALIZATION: Target[];
|
|
26
|
+
/**
|
|
27
|
+
* After hydration, we reset the tree
|
|
28
|
+
* These SDKs handle Personalization Container in a special way:
|
|
29
|
+
* - first, the inlined script will help us add `display: none`, `aria-hidden: true` and `hidden: true` to the non-winning variants
|
|
30
|
+
* - then, on mount / when the component is hydrated - we reset the tree with only the winning variant and deleting the entire tree
|
|
31
|
+
*
|
|
32
|
+
* This helps us to avoid flicker and show the correct / winning variant initially and then once we've hydrated we show the winning variant
|
|
33
|
+
* and keep a track of the cookies to update to the correct variant dynamically when the cookie updates.
|
|
34
|
+
*/
|
|
35
|
+
export declare const SDKS_REQUIRING_RESET_APPROACH: Target[];
|
|
15
36
|
export declare function checkShouldRenderVariants(variants: PersonalizationContainerProps['variants'], canTrack: boolean): boolean;
|
|
16
37
|
export declare function getBlocksToRender({ variants, previewingIndex, isHydrated, filteredVariants, fallbackBlocks }: {
|
|
17
38
|
variants: PersonalizationContainerProps['variants'];
|
|
@@ -19,9 +40,8 @@ export declare function getBlocksToRender({ variants, previewingIndex, isHydrate
|
|
|
19
40
|
isHydrated: boolean;
|
|
20
41
|
filteredVariants: PersonalizationContainerProps['variants'];
|
|
21
42
|
fallbackBlocks?: BuilderBlock[];
|
|
22
|
-
}):
|
|
23
|
-
|
|
24
|
-
path: string | undefined;
|
|
25
|
-
};
|
|
43
|
+
}): BlocksToRenderReturnType;
|
|
44
|
+
export declare const getInitPersonalizationVariantsFnsScriptString: () => string;
|
|
26
45
|
export declare const getPersonalizationScript: (variants: PersonalizationContainerProps['variants'], blockId: string, locale?: string) => string;
|
|
46
|
+
export declare const getUpdateVisibilityStylesScript: (variants: PersonalizationContainerProps['variants'], blockId: string, locale?: string) => string;
|
|
27
47
|
export { filterWithCustomTargeting } from './helpers/inlined-fns';
|
|
@@ -1,7 +1,25 @@
|
|
|
1
1
|
import { TARGET } from '../../constants/target';
|
|
2
2
|
import { isBrowser } from '../../functions/is-browser';
|
|
3
3
|
import { isEditing } from '../../functions/is-editing';
|
|
4
|
-
import { FILTER_WITH_CUSTOM_TARGETING_SCRIPT, PERSONALIZATION_SCRIPT } from './helpers/inlined-fns';
|
|
4
|
+
import { FILTER_WITH_CUSTOM_TARGETING_SCRIPT, PERSONALIZATION_SCRIPT, UPDATE_VISIBILITY_STYLES_SCRIPT } from './helpers/inlined-fns';
|
|
5
|
+
export const DEFAULT_INDEX = 'default';
|
|
6
|
+
const FILTER_WITH_CUSTOM_TARGETING_SCRIPT_FN_NAME = 'filterWithCustomTargeting';
|
|
7
|
+
const BUILDER_IO_PERSONALIZATION_SCRIPT_FN_NAME = 'builderIoPersonalization';
|
|
8
|
+
const UPDATE_VARIANT_VISIBILITY_SCRIPT_FN_NAME = 'updateVisibilityStylesScript';
|
|
9
|
+
/**
|
|
10
|
+
* SDKs that support Variant Containers
|
|
11
|
+
*/
|
|
12
|
+
export const SDKS_SUPPORTING_PERSONALIZATION = ['react', 'vue', 'svelte'];
|
|
13
|
+
/**
|
|
14
|
+
* After hydration, we reset the tree
|
|
15
|
+
* These SDKs handle Personalization Container in a special way:
|
|
16
|
+
* - first, the inlined script will help us add `display: none`, `aria-hidden: true` and `hidden: true` to the non-winning variants
|
|
17
|
+
* - then, on mount / when the component is hydrated - we reset the tree with only the winning variant and deleting the entire tree
|
|
18
|
+
*
|
|
19
|
+
* This helps us to avoid flicker and show the correct / winning variant initially and then once we've hydrated we show the winning variant
|
|
20
|
+
* and keep a track of the cookies to update to the correct variant dynamically when the cookie updates.
|
|
21
|
+
*/
|
|
22
|
+
export const SDKS_REQUIRING_RESET_APPROACH = ['vue', 'svelte'];
|
|
5
23
|
export function checkShouldRenderVariants(variants, canTrack) {
|
|
6
24
|
const hasVariants = variants && variants.length > 0;
|
|
7
25
|
if (TARGET === 'reactNative')
|
|
@@ -10,7 +28,7 @@ export function checkShouldRenderVariants(variants, canTrack) {
|
|
|
10
28
|
return false;
|
|
11
29
|
if (!canTrack)
|
|
12
30
|
return false;
|
|
13
|
-
if (TARGET
|
|
31
|
+
if (SDKS_REQUIRING_RESET_APPROACH.includes(TARGET))
|
|
14
32
|
return true;
|
|
15
33
|
if (isBrowser())
|
|
16
34
|
return false;
|
|
@@ -19,16 +37,20 @@ export function checkShouldRenderVariants(variants, canTrack) {
|
|
|
19
37
|
export function getBlocksToRender({ variants, previewingIndex, isHydrated, filteredVariants, fallbackBlocks }) {
|
|
20
38
|
const fallback = {
|
|
21
39
|
blocks: fallbackBlocks ?? [],
|
|
22
|
-
path: 'this.children'
|
|
40
|
+
path: 'this.children',
|
|
41
|
+
index: DEFAULT_INDEX
|
|
23
42
|
};
|
|
24
43
|
if (isHydrated && isEditing()) {
|
|
25
44
|
// If editing a specific variant
|
|
26
45
|
if (typeof previewingIndex === 'number' && previewingIndex < (variants?.length ?? 0)) {
|
|
27
|
-
const variant = variants[previewingIndex];
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
46
|
+
const variant = variants?.[previewingIndex];
|
|
47
|
+
if (variant) {
|
|
48
|
+
return {
|
|
49
|
+
blocks: variant.blocks,
|
|
50
|
+
path: `variants.${previewingIndex}.blocks`,
|
|
51
|
+
index: previewingIndex
|
|
52
|
+
};
|
|
53
|
+
}
|
|
32
54
|
}
|
|
33
55
|
// Otherwise we're editing the default variant
|
|
34
56
|
return fallback;
|
|
@@ -36,23 +58,32 @@ export function getBlocksToRender({ variants, previewingIndex, isHydrated, filte
|
|
|
36
58
|
// If we're on the browser, check if there's a winning variant
|
|
37
59
|
if (isBrowser()) {
|
|
38
60
|
const winningVariant = filteredVariants?.[0];
|
|
39
|
-
if (winningVariant) {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
61
|
+
if (winningVariant && variants) {
|
|
62
|
+
const variantIndex = variants.indexOf(winningVariant);
|
|
63
|
+
if (variantIndex !== -1) {
|
|
64
|
+
return {
|
|
65
|
+
blocks: winningVariant.blocks,
|
|
66
|
+
path: `variants.${variantIndex}.blocks`,
|
|
67
|
+
index: variantIndex
|
|
68
|
+
};
|
|
69
|
+
}
|
|
44
70
|
}
|
|
45
71
|
}
|
|
46
72
|
// If no winning variant or we are on the server, return the default variant
|
|
47
73
|
return fallback;
|
|
48
74
|
}
|
|
49
|
-
export const
|
|
75
|
+
export const getInitPersonalizationVariantsFnsScriptString = () => {
|
|
50
76
|
return `
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
getPersonalizedVariant(${JSON.stringify(variants)}, "${blockId}"${locale ? `, "${locale}"` : ''})
|
|
55
|
-
})();
|
|
77
|
+
window.${FILTER_WITH_CUSTOM_TARGETING_SCRIPT_FN_NAME} = ${FILTER_WITH_CUSTOM_TARGETING_SCRIPT}
|
|
78
|
+
window.${BUILDER_IO_PERSONALIZATION_SCRIPT_FN_NAME} = ${PERSONALIZATION_SCRIPT}
|
|
79
|
+
window.${UPDATE_VARIANT_VISIBILITY_SCRIPT_FN_NAME} = ${UPDATE_VISIBILITY_STYLES_SCRIPT}
|
|
56
80
|
`;
|
|
57
81
|
};
|
|
82
|
+
const isHydrationTarget = TARGET === 'react';
|
|
83
|
+
export const getPersonalizationScript = (variants, blockId, locale) => {
|
|
84
|
+
return `window.${BUILDER_IO_PERSONALIZATION_SCRIPT_FN_NAME}(${JSON.stringify(variants)}, "${blockId}", ${isHydrationTarget}${locale ? `, "${locale}"` : ''})`;
|
|
85
|
+
};
|
|
86
|
+
export const getUpdateVisibilityStylesScript = (variants, blockId, locale) => {
|
|
87
|
+
return `window.${UPDATE_VARIANT_VISIBILITY_SCRIPT_FN_NAME}(${JSON.stringify(variants)}, "${blockId}", ${isHydrationTarget}${locale ? `, "${locale}"` : ''})`;
|
|
88
|
+
};
|
|
58
89
|
export { filterWithCustomTargeting } from './helpers/inlined-fns';
|
|
@@ -2,16 +2,28 @@
|
|
|
2
2
|
import Blocks from "../../components/blocks/blocks.svelte";
|
|
3
3
|
import InlinedScript from "../../components/inlined-script.svelte";
|
|
4
4
|
import InlinedStyles from "../../components/inlined-styles.svelte";
|
|
5
|
+
import { TARGET } from "../../constants/target";
|
|
6
|
+
import { getClassPropName } from "../../functions/get-class-prop-name";
|
|
5
7
|
import { isEditing } from "../../functions/is-editing";
|
|
6
8
|
import { isPreviewing } from "../../functions/is-previewing";
|
|
7
9
|
import { getDefaultCanTrack } from "../../helpers/canTrack";
|
|
8
10
|
import { userAttributesService } from "../../helpers/user-attributes";
|
|
9
|
-
import {
|
|
11
|
+
import { filterAttrs } from "../helpers";
|
|
12
|
+
import { checkShouldRenderVariants, DEFAULT_INDEX, filterWithCustomTargeting, getBlocksToRender, getPersonalizationScript, getUpdateVisibilityStylesScript, SDKS_REQUIRING_RESET_APPROACH, } from "./helpers";
|
|
13
|
+
import "../helpers";
|
|
10
14
|
export let builderContext;
|
|
11
15
|
export let variants = undefined;
|
|
12
16
|
export let builderBlock;
|
|
13
|
-
export let previewingIndex = undefined;
|
|
14
17
|
export let attributes = undefined;
|
|
18
|
+
export let previewingIndex = undefined;
|
|
19
|
+
export let builderComponents;
|
|
20
|
+
$: attrs = () => {
|
|
21
|
+
return {
|
|
22
|
+
...filterAttrs(attributes, "on:", false),
|
|
23
|
+
...filterAttrs(attributes, "on:", true),
|
|
24
|
+
[getClassPropName()]: `builder-personalization-container ${attributes[getClassPropName()] || ""}`,
|
|
25
|
+
};
|
|
26
|
+
};
|
|
15
27
|
$: filteredVariants = () => {
|
|
16
28
|
return (variants || []).filter((variant) => {
|
|
17
29
|
return filterWithCustomTargeting({
|
|
@@ -28,24 +40,25 @@ $: blocksToRender = () => {
|
|
|
28
40
|
return getBlocksToRender({
|
|
29
41
|
variants: variants,
|
|
30
42
|
fallbackBlocks: builderBlock?.children,
|
|
31
|
-
isHydrated:
|
|
43
|
+
isHydrated: shouldResetVariants,
|
|
32
44
|
filteredVariants: filteredVariants(),
|
|
33
45
|
previewingIndex: previewingIndex,
|
|
34
46
|
});
|
|
35
47
|
};
|
|
36
48
|
$: hideVariantsStyleString = () => {
|
|
37
49
|
return (variants || [])
|
|
38
|
-
.map((_, index) => `[data-variant-id="${builderBlock?.id}-${index}"] { display: none; } `)
|
|
50
|
+
.map((_, index) => `div[data-variant-id="${builderBlock?.id}-${index}"] { display: none !important; } `)
|
|
39
51
|
.join("");
|
|
40
52
|
};
|
|
41
53
|
let rootRef;
|
|
42
54
|
let userAttributes = userAttributesService.getUserAttributes();
|
|
43
55
|
let scriptStr = getPersonalizationScript(variants, builderBlock?.id || "none", $builderContext?.rootState?.locale);
|
|
56
|
+
let updateVisibilityStylesScript = getUpdateVisibilityStylesScript(variants, builderBlock?.id || "none", $builderContext?.rootState?.locale);
|
|
44
57
|
let unsubscribers = [];
|
|
45
58
|
let shouldRenderVariants = checkShouldRenderVariants(variants, getDefaultCanTrack($builderContext?.canTrack));
|
|
46
|
-
let
|
|
59
|
+
let shouldResetVariants = false;
|
|
47
60
|
onMount(() => {
|
|
48
|
-
|
|
61
|
+
shouldResetVariants = true;
|
|
49
62
|
const unsub = userAttributesService.subscribeOnUserAttributesChange((attrs) => {
|
|
50
63
|
userAttributes = attrs;
|
|
51
64
|
});
|
|
@@ -54,7 +67,7 @@ onMount(() => {
|
|
|
54
67
|
if (rootRef) {
|
|
55
68
|
rootRef.dispatchEvent(new CustomEvent("builder.variantLoaded", {
|
|
56
69
|
detail: {
|
|
57
|
-
variant: variant ||
|
|
70
|
+
variant: variant || DEFAULT_INDEX,
|
|
58
71
|
content: $builderContext?.content,
|
|
59
72
|
},
|
|
60
73
|
bubbles: true,
|
|
@@ -64,7 +77,7 @@ onMount(() => {
|
|
|
64
77
|
if (entry.isIntersecting && rootRef) {
|
|
65
78
|
rootRef.dispatchEvent(new CustomEvent("builder.variantDisplayed", {
|
|
66
79
|
detail: {
|
|
67
|
-
variant: variant ||
|
|
80
|
+
variant: variant || DEFAULT_INDEX,
|
|
68
81
|
content: $builderContext?.content,
|
|
69
82
|
},
|
|
70
83
|
bubbles: true,
|
|
@@ -82,37 +95,72 @@ onDestroy(() => {
|
|
|
82
95
|
});
|
|
83
96
|
</script>
|
|
84
97
|
|
|
85
|
-
<div
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
98
|
+
<div bind:this={rootRef} {...attrs()}>
|
|
99
|
+
{#if shouldResetVariants && SDKS_REQUIRING_RESET_APPROACH.includes(TARGET)}
|
|
100
|
+
<Blocks
|
|
101
|
+
blocks={blocksToRender().blocks}
|
|
102
|
+
parent={builderBlock?.id}
|
|
103
|
+
path={blocksToRender().path}
|
|
104
|
+
context={builderContext}
|
|
105
|
+
registeredComponents={builderComponents}
|
|
106
|
+
BlocksWrapperProps={{
|
|
107
|
+
...$builderContext?.BlocksWrapperProps,
|
|
108
|
+
"data-variant-id": `${builderBlock?.id}-${blocksToRender().index}`,
|
|
109
|
+
}}
|
|
110
|
+
/>
|
|
111
|
+
{/if}
|
|
112
|
+
{#if (!shouldResetVariants && SDKS_REQUIRING_RESET_APPROACH.includes(TARGET)) || !SDKS_REQUIRING_RESET_APPROACH.includes(TARGET)}
|
|
113
|
+
{#if shouldRenderVariants}
|
|
114
|
+
<InlinedStyles
|
|
115
|
+
nonce={$builderContext?.nonce || ""}
|
|
116
|
+
styles={hideVariantsStyleString()}
|
|
117
|
+
id={`variants-styles-${builderBlock?.id}`}
|
|
118
|
+
/>
|
|
119
|
+
<InlinedScript
|
|
120
|
+
nonce={$builderContext?.nonce || ""}
|
|
121
|
+
scriptStr={updateVisibilityStylesScript}
|
|
122
|
+
id={`variants-visibility-script-${builderBlock?.id}`}
|
|
123
|
+
/>
|
|
124
|
+
|
|
125
|
+
{#each variants as variant, index (`${builderBlock?.id}-${index}`)}
|
|
126
|
+
<Blocks
|
|
127
|
+
BlocksWrapperProps={{
|
|
128
|
+
...$builderContext?.BlocksWrapperProps,
|
|
129
|
+
"aria-hidden": true,
|
|
130
|
+
hidden: true,
|
|
131
|
+
"data-variant-id": `${builderBlock?.id}-${index}`,
|
|
132
|
+
}}
|
|
96
133
|
blocks={variant.blocks}
|
|
97
134
|
parent={builderBlock?.id}
|
|
98
135
|
path={`component.options.variants.${index}.blocks`}
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
{
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
136
|
+
context={builderContext}
|
|
137
|
+
registeredComponents={builderComponents}
|
|
138
|
+
><InlinedScript
|
|
139
|
+
nonce={$builderContext?.nonce || ""}
|
|
140
|
+
{scriptStr}
|
|
141
|
+
id={`variants-script-${builderBlock?.id}-${index}`}
|
|
142
|
+
/></Blocks
|
|
143
|
+
>
|
|
144
|
+
{/each}
|
|
145
|
+
{/if}
|
|
146
|
+
<Blocks
|
|
147
|
+
blocks={blocksToRender().blocks}
|
|
148
|
+
parent={builderBlock?.id}
|
|
149
|
+
path={blocksToRender().path}
|
|
150
|
+
context={builderContext}
|
|
151
|
+
registeredComponents={builderComponents}
|
|
152
|
+
BlocksWrapperProps={{
|
|
153
|
+
...$builderContext?.BlocksWrapperProps,
|
|
154
|
+
"data-variant-id": `${builderBlock?.id}-${blocksToRender().index}`,
|
|
155
|
+
}}
|
|
156
|
+
>
|
|
157
|
+
{#if shouldRenderVariants}
|
|
158
|
+
<InlinedScript
|
|
159
|
+
nonce={$builderContext?.nonce || ""}
|
|
160
|
+
{scriptStr}
|
|
161
|
+
id={`variants-script-${builderBlock?.id}-${DEFAULT_INDEX}`}
|
|
162
|
+
/>
|
|
163
|
+
{/if}</Blocks
|
|
164
|
+
>
|
|
165
|
+
{/if}
|
|
118
166
|
</div>
|
|
@@ -5,8 +5,9 @@ declare const __propDef: {
|
|
|
5
5
|
builderContext: PersonalizationContainerProps["builderContext"];
|
|
6
6
|
variants?: PersonalizationContainerProps["variants"];
|
|
7
7
|
builderBlock: PersonalizationContainerProps["builderBlock"];
|
|
8
|
-
previewingIndex?: PersonalizationContainerProps["previewingIndex"];
|
|
9
8
|
attributes?: PersonalizationContainerProps["attributes"];
|
|
9
|
+
previewingIndex?: PersonalizationContainerProps["previewingIndex"];
|
|
10
|
+
builderComponents: PersonalizationContainerProps["builderComponents"];
|
|
10
11
|
};
|
|
11
12
|
events: {
|
|
12
13
|
[evt: string]: CustomEvent<any>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { BuilderBlock } from '../../types/builder-block';
|
|
2
|
-
import type { BuilderDataProps } from '../../types/builder-props';
|
|
2
|
+
import type { BuilderComponentsProp, BuilderDataProps } from '../../types/builder-props';
|
|
3
3
|
import type { Query } from './helpers';
|
|
4
4
|
export type PersonalizationContainerProps = {
|
|
5
5
|
children?: any;
|
|
@@ -11,4 +11,4 @@ export type PersonalizationContainerProps = {
|
|
|
11
11
|
startDate?: string;
|
|
12
12
|
endDate?: string;
|
|
13
13
|
}>;
|
|
14
|
-
} & BuilderDataProps;
|
|
14
|
+
} & BuilderDataProps & BuilderComponentsProp;
|
|
@@ -13,7 +13,7 @@ export let builderBlock;
|
|
|
13
13
|
export let builderComponents;
|
|
14
14
|
export let builderLinkComponent = undefined;
|
|
15
15
|
function setContent() {
|
|
16
|
-
if (contentToUse)
|
|
16
|
+
if (contentToUse && symbolEntry === symbol?.entry)
|
|
17
17
|
return;
|
|
18
18
|
fetchSymbolContent({
|
|
19
19
|
symbol: symbol,
|
|
@@ -21,6 +21,7 @@ function setContent() {
|
|
|
21
21
|
}).then((newContent) => {
|
|
22
22
|
if (newContent) {
|
|
23
23
|
contentToUse = newContent;
|
|
24
|
+
symbolEntry = symbol?.entry;
|
|
24
25
|
}
|
|
25
26
|
});
|
|
26
27
|
}
|
|
@@ -41,6 +42,7 @@ $: className = () => {
|
|
|
41
42
|
.join(" ");
|
|
42
43
|
};
|
|
43
44
|
let contentToUse = symbol?.content;
|
|
45
|
+
let symbolEntry = symbol?.entry;
|
|
44
46
|
onMount(() => {
|
|
45
47
|
setContent();
|
|
46
48
|
});
|
|
@@ -3,10 +3,10 @@
|
|
|
3
3
|
<script>import { getBlockActions } from "../../../functions/get-block-actions";
|
|
4
4
|
import { getBlockProperties } from "../../../functions/get-block-properties";
|
|
5
5
|
import Awaiter from "../../awaiter.svelte";
|
|
6
|
-
export let
|
|
6
|
+
export let wrapperProps;
|
|
7
7
|
export let block;
|
|
8
|
+
export let includeBlockProps;
|
|
8
9
|
export let context;
|
|
9
|
-
export let wrapperProps;
|
|
10
10
|
export let Wrapper;
|
|
11
11
|
$: attributes = () => {
|
|
12
12
|
return includeBlockProps
|
|
@@ -28,6 +28,9 @@ $: attributes = () => {
|
|
|
28
28
|
$: targetWrapperProps = () => {
|
|
29
29
|
return wrapperProps;
|
|
30
30
|
};
|
|
31
|
+
let forceRenderCount = 0;
|
|
32
|
+
function onUpdateFn_0(..._args) { }
|
|
33
|
+
$: onUpdateFn_0(...[wrapperProps, block?.component?.options]);
|
|
31
34
|
</script>
|
|
32
35
|
|
|
33
36
|
{#if Wrapper.load}
|
|
@@ -7,8 +7,9 @@ export let blocks;
|
|
|
7
7
|
export let parent;
|
|
8
8
|
export let path;
|
|
9
9
|
export let styleProp;
|
|
10
|
-
export let
|
|
10
|
+
export let BlocksWrapperProps;
|
|
11
11
|
export let context = undefined;
|
|
12
|
+
export let className = undefined;
|
|
12
13
|
export let linkComponent = undefined;
|
|
13
14
|
export let registeredComponents = undefined;
|
|
14
15
|
let builderContext = getContext(BuilderContext.key);
|
|
@@ -20,11 +21,12 @@ let componentsContext = getContext(ComponentsContext.key);
|
|
|
20
21
|
{parent}
|
|
21
22
|
{path}
|
|
22
23
|
{styleProp}
|
|
24
|
+
BlocksWrapperProps={BlocksWrapperProps ||
|
|
25
|
+
$context?.BlocksWrapperProps ||
|
|
26
|
+
$builderContext?.BlocksWrapperProps}
|
|
23
27
|
classNameProp={className}
|
|
24
28
|
BlocksWrapper={$context?.BlocksWrapper || $builderContext?.BlocksWrapper}
|
|
25
|
-
|
|
26
|
-
$builderContext?.BlocksWrapperProps}
|
|
27
|
-
>
|
|
29
|
+
><slot />
|
|
28
30
|
{#if blocks}
|
|
29
31
|
{#each blocks as block (block.id)}
|
|
30
32
|
<Block
|
|
@@ -6,15 +6,18 @@ declare const __propDef: {
|
|
|
6
6
|
parent: BlocksProps["parent"];
|
|
7
7
|
path: BlocksProps["path"];
|
|
8
8
|
styleProp: BlocksProps["styleProp"];
|
|
9
|
-
|
|
9
|
+
BlocksWrapperProps: BlocksProps["BlocksWrapperProps"];
|
|
10
10
|
context?: BlocksProps["context"];
|
|
11
|
+
className?: BlocksProps["className"];
|
|
11
12
|
linkComponent?: BlocksProps["linkComponent"];
|
|
12
13
|
registeredComponents?: BlocksProps["registeredComponents"];
|
|
13
14
|
};
|
|
14
15
|
events: {
|
|
15
16
|
[evt: string]: CustomEvent<any>;
|
|
16
17
|
};
|
|
17
|
-
slots: {
|
|
18
|
+
slots: {
|
|
19
|
+
default: {};
|
|
20
|
+
};
|
|
18
21
|
};
|
|
19
22
|
type BlocksProps_ = typeof __propDef.props;
|
|
20
23
|
export { BlocksProps_ as BlocksProps };
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import type { Writable } from "svelte/store";
|
|
3
3
|
import type { BuilderContextInterface, RegisteredComponents } from '../../context/types';
|
|
4
4
|
import type { BlocksWrapperProps } from './blocks-wrapper.svelte';
|
|
5
|
-
export type BlocksProps = Partial<Omit<BlocksWrapperProps, 'BlocksWrapper' | '
|
|
5
|
+
export type BlocksProps = Partial<Omit<BlocksWrapperProps, 'BlocksWrapper' | 'classNameProp'>> & {
|
|
6
6
|
context?: Writable<BuilderContextInterface>;
|
|
7
7
|
registeredComponents?: RegisteredComponents;
|
|
8
8
|
linkComponent?: any;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
<script context="module"></script>
|
|
2
2
|
|
|
3
3
|
<script>import { onMount } from "svelte";
|
|
4
|
+
import { SDKS_SUPPORTING_PERSONALIZATION, getInitPersonalizationVariantsFnsScriptString, } from "../../blocks/personalization-container/helpers";
|
|
4
5
|
import { TARGET } from "../../constants/target";
|
|
5
6
|
import { handleABTestingSync } from "../../helpers/ab-tests";
|
|
6
7
|
import { getDefaultCanTrack } from "../../helpers/canTrack";
|
|
@@ -67,6 +68,14 @@ onMount(() => {
|
|
|
67
68
|
scriptStr={getInitVariantsFnsScriptString()}
|
|
68
69
|
nonce={nonce || ""}
|
|
69
70
|
/>
|
|
71
|
+
|
|
72
|
+
{#if SDKS_SUPPORTING_PERSONALIZATION.includes(TARGET)}
|
|
73
|
+
<InlinedScript
|
|
74
|
+
id="builderio-init-personalization-variants-fns"
|
|
75
|
+
nonce={nonce || ""}
|
|
76
|
+
scriptStr={getInitPersonalizationVariantsFnsScriptString()}
|
|
77
|
+
/>
|
|
78
|
+
{/if}
|
|
70
79
|
{/if}
|
|
71
80
|
|
|
72
81
|
{#if shouldRenderVariants}
|
|
@@ -9,6 +9,7 @@ import { default as Fragment } from '../blocks/fragment/index';
|
|
|
9
9
|
import { componentInfo as imageComponentInfo } from '../blocks/image/component-info';
|
|
10
10
|
import { default as Image } from '../blocks/image/index';
|
|
11
11
|
import { componentInfo as personalizationContainerComponentInfo } from '../blocks/personalization-container/component-info';
|
|
12
|
+
import { SDKS_SUPPORTING_PERSONALIZATION } from '../blocks/personalization-container/helpers';
|
|
12
13
|
import { default as PersonalizationContainer } from '../blocks/personalization-container/index';
|
|
13
14
|
import { componentInfo as sectionComponentInfo } from '../blocks/section/component-info';
|
|
14
15
|
import { default as Section } from '../blocks/section/index';
|
|
@@ -50,7 +51,7 @@ export const getDefaultRegisteredComponents = () => [{
|
|
|
50
51
|
}, {
|
|
51
52
|
component: Text,
|
|
52
53
|
...textComponentInfo
|
|
53
|
-
}, ...(TARGET
|
|
54
|
+
}, ...(SDKS_SUPPORTING_PERSONALIZATION.includes(TARGET) ? [{
|
|
54
55
|
component: PersonalizationContainer,
|
|
55
56
|
...personalizationContainerComponentInfo
|
|
56
57
|
}] : []), ...(TARGET === 'rsc' ? [] : [{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const SDK_VERSION = "4.0.
|
|
1
|
+
export declare const SDK_VERSION = "4.0.9";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export const SDK_VERSION = "4.0.
|
|
1
|
+
export const SDK_VERSION = "4.0.9";
|
|
@@ -2,7 +2,8 @@ export const componentInfo = {
|
|
|
2
2
|
name: 'PersonalizationContainer',
|
|
3
3
|
shouldReceiveBuilderProps: {
|
|
4
4
|
builderBlock: true,
|
|
5
|
-
builderContext: true
|
|
5
|
+
builderContext: true,
|
|
6
|
+
builderComponents: true
|
|
6
7
|
},
|
|
7
8
|
noWrap: true,
|
|
8
9
|
image: 'https://cdn.builder.io/api/v1/image/assets%2FYJIGb4i01jvw0SRdL5Bt%2F37229ed30d8c41dfb10b8cca1992053a',
|