@builder.io/sdk-vue
Version:
Builder.io SDK for Vue
48 lines (47 loc) • 2.56 kB
TypeScript
import type { BuilderBlock } from '../../types/builder-block';
import type { Target } from '../../types/targets';
import type { PersonalizationContainerProps } from './personalization-container.types';
export declare const DEFAULT_INDEX = "default";
export type UserAttributes = {
date?: string | Date;
urlPath?: string;
[key: string]: any;
};
type QueryOperator = 'is' | 'isNot' | 'contains' | 'startsWith' | 'endsWith' | 'greaterThan' | 'lessThan' | 'greaterThanOrEqualTo' | 'lessThanOrEqualTo';
type QueryValue = string | number | boolean | Array<string | number | boolean>;
export type Query = {
property: string;
operator: QueryOperator;
value: QueryValue;
};
type BlocksToRenderReturnType = {
blocks: BuilderBlock[];
path: string;
index: number | typeof DEFAULT_INDEX;
};
/**
* SDKs that support Variant Containers
*/
export declare const SDKS_SUPPORTING_PERSONALIZATION: Target[];
/**
* After hydration, we reset the tree
* These SDKs handle Personalization Container in a special way:
* - first, the inlined script will help us add `display: none`, `aria-hidden: true` and `hidden: true` to the non-winning variants
* - then, on mount / when the component is hydrated - we reset the tree with only the winning variant and deleting the entire tree
*
* This helps us to avoid flicker and show the correct / winning variant initially and then once we've hydrated we show the winning variant
* and keep a track of the cookies to update to the correct variant dynamically when the cookie updates.
*/
export declare const SDKS_REQUIRING_RESET_APPROACH: Target[];
export declare function checkShouldRenderVariants(variants: PersonalizationContainerProps['variants'], canTrack: boolean): boolean;
export declare function getBlocksToRender({ variants, previewingIndex, isHydrated, filteredVariants, fallbackBlocks }: {
variants: PersonalizationContainerProps['variants'];
previewingIndex?: number | null;
isHydrated: boolean;
filteredVariants: PersonalizationContainerProps['variants'];
fallbackBlocks?: BuilderBlock[];
}): BlocksToRenderReturnType;
export declare const getInitPersonalizationVariantsFnsScriptString: () => string;
export declare const getPersonalizationScript: (variants: PersonalizationContainerProps['variants'], blockId: string, locale?: string) => string;
export declare const getUpdateVisibilityStylesScript: (variants: PersonalizationContainerProps['variants'], blockId: string, locale?: string) => string;
export { filterWithCustomTargeting } from './helpers/inlined-fns';