import { ReactiveControllerHost } from 'lit'; import { OmitTypesFromRecord, ReadonlyIfType } from '../../global/helpers'; import { ConsumeContextOptions, ContextConsumerController } from './ContextConsumerController'; import { ContextProviderController, ProvideContextOptions } from './ContextProviderController'; /** * Creates and returns a pairable context consumer and provider. */ export declare function createContext(initialValue: T): Context; /** * Derives a context from others that was created with `createContext`. This assumes the * given `contexts` are ALL provided by the same host element. * * @param contexts - The contexts to derive values from as it updates. * @param derivation - Takes the original context values and outputs the derived value. */ export declare function derivedContext(contexts: T, derivation: (values: ContextTupleValues) => R): DerivedContext; export declare function isDerviedContext(context: Context | DerivedContext): context is DerivedContext; /** * Takes in a context record which is essentially an object containing 0 or more contexts, and sets * the given `host` element as the provider of all the contexts within the given record. * * @param host * @param contextRecord */ export declare function provideContextRecord>(host: ReactiveControllerHost, contextRecord: T, options?: { [P in keyof T]?: Omit, 'id'>; }): ContextProviderRecord; export interface Context { readonly id: symbol; readonly initialValue: T; provide(host: ReactiveControllerHost, options?: Omit, 'id'>): ContextProviderController; consume(host: ReactiveControllerHost, options?: Omit, 'id'>): ContextConsumerController; } export declare type DerivedContext = Context & { isDerived: true; }; export declare type ExtractContextType = C extends Context ? X : never; export declare type ContextTuple = readonly [Context, ...Array>]; export declare type ContextTupleValues = { readonly [K in keyof Tuple]: ExtractContextType; }; export declare type ContextRecord = { readonly [P in keyof RecordType]: Context | DerivedContext; }; export declare type ExtractContextRecordTypes> = { [P in keyof ContextRecordType]: ExtractContextType; }; export declare type ContextProviderRecord> = ExtractContextRecordTypes, ContextRecordType>> & { __destroy: () => void; }; export declare type OmitDerivedContextFromRecord = OmitTypesFromRecord>;