import { Context } from 'react'; /** * Serializes access to a global singleton value, with the first caller creating the value. * * @public */ declare function getOrCreateGlobalSingleton(id: string, supplier: () => T): T; /** * The versioned value interface is a container for a set of values that * can be looked up by version. It is intended to be used as a container * for values that can be versioned independently of package versions. * * @public */ type VersionedValue = { atVersion(version: Version): Versions[Version] | undefined; }; /** * Creates a container for a map of versioned values that implements VersionedValue. * * @public */ declare function createVersionedValueMap(versions: Versions): VersionedValue; /** * Get the existing or create a new versioned React context that's * stored inside a global singleton. * * @param key - A key that uniquely identifies the context. * @public * @example * * ```ts * const MyContext = createVersionedContext<{ 1: string }>('my-context'); * * const MyContextProvider = ({children}) => ( * * {children} * * ) * ``` */ declare function createVersionedContext(key: string): Context | undefined>; /** * A hook that simplifies the consumption of a versioned contexts that's * stored inside a global singleton. * * @param key - A key that uniquely identifies the context. * @public * @example * * ```ts * const versionedHolder = useVersionedContext<{ 1: string }>('my-context'); * * if (!versionedHolder) { * throw new Error('My context is not available!') * } * * const myValue = versionedHolder.atVersion(1); * * // ... * ``` */ declare function useVersionedContext(key: string): VersionedValue | undefined; /** * Creates a helper for writing tests towards multiple different * combinations of versions provided from a context. * * @param key - A key that uniquely identifies the context. * @public * @example * * ```ts * const context = createVersionedContextForTesting('my-context'); * * afterEach(() => { * context.reset(); * }); * * it('should work when provided with version 1', () => { * context.set({1: 'value-for-version-1'}) * * // ... * }) * ``` */ declare function createVersionedContextForTesting(key: string): { set(versions: { [x: number]: unknown; }): void; reset(): void; }; export { type VersionedValue, createVersionedContext, createVersionedContextForTesting, createVersionedValueMap, getOrCreateGlobalSingleton, useVersionedContext };