import { type FunctionComponent, type PropsWithChildren, type Dispatch, type SetStateAction } from 'react'; import { type OptimizelyGraphConfig, type IOptiGraphClient } from '@remkoj/optimizely-graph-client'; import { type GenericContext, type TransferrableContext } from './types.js'; import { type ComponentTypeDictionary, type ComponentFactory } from '../factory/index.js'; export declare const enum OptimizelyCmsMode { default = "default", edit = "edit", preview = "preview" } export interface ClientContext extends GenericContext { setLocale: Dispatch>; setMode: Dispatch>; setEditableContentIsExperience: Dispatch>; } export declare class ClientContextInstance implements GenericContext { readonly client?: IOptiGraphClient | undefined; readonly factory: ComponentFactory; readonly locale?: string | undefined; readonly inEditMode: boolean; readonly inPreviewMode: boolean; readonly isDevelopment: boolean; readonly isDebug: boolean; readonly isDebugOrDevelopment: boolean; constructor(cfg: TransferrableContext, components: ComponentTypeDictionary); } export type OptimizelyCmsProps = { /** * The Optimizely Graph Client to use, provide either an instance of the * client, or the configuration used to create the instance. In case you * provide no parameters, the Client will try to infer the configuration * from the environment variables. */ client?: null | OptimizelyGraphConfig | IOptiGraphClient; /** * The authentication token to use for the Optimizely Graph Client. This * token will be applied to the client after it has been resolved from the * `client` property. If not provided the current authentication data of * the client will not be affected. */ clientToken?: string; /** * Marker to indicate if the debug mode should be activated. If not provided * it will be read from the Optimizely Graph Client, inferred by the `client` * property. */ isDebug?: boolean; /** * Marker to indicate if the development mode should be activated. If not * provided, it will be read from the `process.env.NODE_ENV` variable. If * this variable is not set it assumes it to be "production". */ isDevelopment?: boolean; /** * The default mode to initialize the context with, after initialization the * current mode will be state managed using `useState`. */ initialMode?: OptimizelyCmsMode; } & ({ /** * The component factory to be used to resolve content within the scope * of this provider. */ factory: ComponentFactory; /** * The defaults components to apply when there's no factory provided. If a * factory is provided, these components will not be added to the factory. */ initialComponents?: never; } | { /** * The component factory to be used to resolve content within the scope * of this provider. */ factory?: never; /** * The defaults components to apply when there's no factory provided. If a * factory is provided, these components will not be added to the factory. */ initialComponents: ComponentTypeDictionary; }); export declare const OptimizelyCms: FunctionComponent>; export declare const useOptimizelyCms: () => ClientContext; export declare function fromTransferrableContext(serialized: TransferrableContext, components: ComponentTypeDictionary): GenericContext;