import * as _uniformdev_context from '@uniformdev/context'; import { VisitorDataStoreOptions, CookieTransitionDataStoreOptions, ContextInstance, ContextState, Context, LogMessage, TestVariant, TestOptions, PersonalizedVariant, PersonalizeOptions, TestEvent, PersonalizationEvent, CompositionMetadata, ContextOptions } from '@uniformdev/context'; import { ComponentInstance, RouteGetResponseComposition, RootComponentInstance } from '@uniformdev/canvas'; import { PropsWithChildren } from 'react'; type CacheMode = { type: RequestInit['cache']; } | { type: 'revalidate'; interval: number; }; type UniformServerConfig = { /** * Sets the default value of storage consent for new unknown visitors. * * @defaultValue false */ defaultConsent?: boolean; /** * Cache mode for manifest data. * */ manifestCache?: CacheMode & { bypassCache?: boolean; }; /** * Cache mode for canvas data. * */ canvasCache?: CacheMode & { disableSWR?: boolean; bypassCache?: boolean; }; /** * Cache mode for project map data. * */ projectMapCache?: CacheMode & { bypassCache?: boolean; }; /** * Options for Uniform Context */ context?: Pick & { /** * Disables the Uniform Context dev tools. * * @defaultValue false */ disableDevTools?: boolean; /** * Ceiling on the size in bytes of the visitor data cookie, measured on the percent-encoded * `name=value` pair. When the visitor's data does not fit, the least valuable parts are * dropped until it does. Local storage remains the complete copy. * * @defaultValue undefined - the cookie is unbounded */ cookieMaxBytes?: CookieTransitionDataStoreOptions['maxBytes']; }; /** * Configure where system components should be evaluated. */ evaluation?: { /** * Configure where personalization components should be evaluated. */ personalization: 'client' | 'server' | 'hybrid'; /** * Configure where testing components should be evaluated. */ testing: 'client' | 'server'; }; /** * 😅 */ experimental?: { /** * Enables edge cache of redirects. * * @defaultValue false */ edgeRedirects?: boolean; /** * Enables edge cache of compositions. * * @defaultValue false */ edgeCompositions?: boolean; /** * Dynamic tokens names that should be used for localization. */ localeDynamicInputs?: string[]; /** * When enabled, quirks will be serialized to a cookie so they are available on the server. */ quirkSerialization?: boolean; }; ppr?: { /** * Whether or not to wrap personalization components in a suspense boundary. */ personalizationSuspense?: boolean; /** * Whether or not to wrap test components in a suspense boundary. */ testSuspense?: boolean; }; }; type PageParameters = { /** * The params object from Next.js router. Used to resolve a composition. */ params: Promise<{ path?: string | string[]; }> | undefined; /** * The searchParams object from Next.js router. Used for signal evaluation. */ searchParams?: Promise<{ [key: string]: string | undefined; }>; }; type AwaitedPageParameters = { /** * The params object from Next.js router. Used to resolve a composition. */ params: Awaited; /** * The searchParams object from Next.js router. Used for signal evaluation. */ searchParams?: Awaited; }; type PlaygroundParameters = { /** * Used to retrieve the composition ID of the pattern. */ searchParams: Promise<{ [key: string]: string | undefined; }>; }; type AwaitedPlaygroundParameters = { /** * Used to retrieve the composition ID of the pattern. */ searchParams: Awaited; }; type SlotDefinition = { name: string; items: PropsWithChildren['children'][]; }; type ComponentProps = TProps & { component: ComponentInstance; context: CompositionContext; slots: Record; slotName: string | undefined; slotIndex: number | undefined; }; type CompositionContext = Omit & { composition: RootComponentInstance; path: string; state?: number; searchParams: { [key: string]: string | undefined; } | undefined; isDraftMode: boolean; isContextualEditing: boolean; previewMode: 'editor' | 'preview' | undefined; }; type AppDirectoryContext = Omit & { update: (update: Partial) => Promise; /** * Set the consent state for the current user. * @param consent - Whether the user has given consent. */ updateConsent: (consent: boolean) => Promise; /** * The current consent state for the user. */ get consent(): Readonly; /** * Internal use only. Please use `ContextUpdateTransfer` to handle any Context updates. * * @deprecated Use `ContextUpdateTransfer` to handle Context updates instead. */ internal_update: AppDirectoryContext['update']; }; type AppDirectoryContextState = Omit & AwaitedPageParameters; type AppDirectoryServerContext = Omit; type CreateUniformContextOptions = Omit & { serverCookieValue: string | undefined; cookieAttributes?: CookieTransitionDataStoreOptions['cookieAttributes']; cookieMaxBytes?: CookieTransitionDataStoreOptions['maxBytes']; quirkCookieValue?: string; experimental_quirksEnabled?: CookieTransitionDataStoreOptions['experimental_quirksEnabled']; }; declare const createUniformContext: ({ serverCookieValue, quirkCookieValue, experimental_quirksEnabled, cookieAttributes, cookieMaxBytes, ...rest }: CreateUniformContextOptions) => AppDirectoryContextInstance; declare class AppDirectoryContextInstance implements AppDirectoryContext { #private; readonly manifest: ContextInstance['manifest']; readonly events: ContextInstance['events']; constructor(context: Context); get scores(): Readonly<_uniformdev_context.ScoreVector>; get quirks(): Readonly<_uniformdev_context.Quirks>; getTestVariantId(testName: string): string | null | undefined; setTestVariantId(testName: string, variantId: string): void; log(...message: LogMessage): void; test(options: TestOptions): _uniformdev_context.TestResult; personalize(options: PersonalizeOptions): _uniformdev_context.PersonalizedResult; forget(fromAllDevices: boolean): Promise; getServerToClientTransitionState(): _uniformdev_context.ServerToClientTransitionState; internal_processTestEvent(event: TestEvent): void; internal_processPersonalizationEvent(event: PersonalizationEvent): void; update(update: Partial): Promise; /** * Gets the current canvas data */ getCompositionMetadata(): Readonly; /** * Updates the canvas data and emits a canvasDataUpdated event */ updateCompositionMetadata(newData: CompositionMetadata): Promise; updateConsent(consent: boolean): Promise; get consent(): boolean | undefined; internal_update(update: Partial): Promise; } type PersonalizeProps = { trackingEventName: string; count: number | string | undefined; algorithm?: string; }; type PersonalizeWithContextComponentProps = ComponentProps & { contextInstance: AppDirectoryServerContext; }; type RunPersonalizationProps = Omit | undefined; }>, 'slots' | 'slotName' | 'slotIndex'>; declare const runPersonalization: ({ component, trackingEventName, count, algorithm, contextInstance, context, }: RunPersonalizationProps) => { indexes: number[]; event: PersonalizationEvent; }; type TestProps = { test: string; }; declare const runTest: ({ test, component, contextInstance, context, }: Omit & { contextInstance: Pick | undefined; }, "slots" | "slotName" | "slotIndex">) => { index: number | null; event: TestEvent | null; }; type ResolvePathResult = { type: 'path'; value: string; }; declare const resolvePath: ({ params }: Pick) => ResolvePathResult; declare function getBaseUrl(): string; export { type AppDirectoryContext, AppDirectoryContextInstance, type AppDirectoryContextState, type AppDirectoryServerContext, type AwaitedPageParameters, type AwaitedPlaygroundParameters, type CacheMode, type ComponentProps, type CompositionContext, type CreateUniformContextOptions, type PageParameters, type PersonalizeProps, type PersonalizeWithContextComponentProps, type PlaygroundParameters, type ResolvePathResult, type RunPersonalizationProps, type SlotDefinition, type TestProps, type UniformServerConfig, createUniformContext, getBaseUrl, resolvePath, runPersonalization, runTest };