import { AsyncMutableRefObject } from 'async-ref'; import React from 'react'; declare type Join = KP extends [infer A] ? A extends string ? A : never : KP extends [infer A, ...infer B] ? A extends string ? `${A}.${Join}` : never : never; declare type Split = KP extends `${infer A}.${infer B}` ? [A, ...Split] : [KP]; declare type FlagScalar = string | number | boolean; declare type Flags = { [key: string]: FlagScalar | Flags; }; declare type KeyPath = { [Key in keyof T & string]: T[Key] extends object ? [Key, ...KeyPath] : [Key]; }[keyof T & string]; declare type KeyPathString = Join>; declare type Subscriber = () => void; declare type Unsubscribe = () => void; declare type Notifier = () => void; declare type ExternalStore = { getSnapshot(): T; getServerSnapshot(): T; subscribe(sub: Subscriber): Unsubscribe; }; declare type GetValueFromKeyPath> = KP extends [infer K, ...infer Rest] ? GetValueFromKeyPath : T extends FlagScalar ? T : never; declare type GetValueFromKeyPathString>> = Split extends KeyPath ? GetValueFromKeyPath> : never; interface Backend { name: string; getSnapshot, T extends GetValueFromKeyPath>(keyPath: KP, defaultValue: T): T; getServerSnapshot, T extends GetValueFromKeyPath>(keyPath: KP, defaultValue: T): T; toExternalStore, T extends GetValueFromKeyPath>(keyPath: KP, defaultValue: T): ExternalStore; } declare abstract class AbstractBackend implements Backend { #private; abstract getSnapshot, T extends GetValueFromKeyPath>(keyPath: KP, defaultValue: T): T; getServerSnapshot, T extends GetValueFromKeyPath>(keyPath: KP, defaultValue: T): T; notify: Notifier; get name(): string; toExternalStore, T extends GetValueFromKeyPath>(keyPath: KP, defaultValue: T): ExternalStore; protected createAsyncRef(): AsyncMutableRefObject; } declare type AlwaysMapping = { boolean: boolean; string: string; number: number; }; declare class AlwaysBackend extends AbstractBackend { #private; constructor(alwaysMapping?: Partial); getSnapshot, T extends GetValueFromKeyPath>(keyPath: KP, defaultValue: T): T; } declare class StaticBackend extends AbstractBackend { #private; constructor(data: Partial); getSnapshot, T extends GetValueFromKeyPath>(keyPath: KP, defaultValue: T): T; } declare type RecursiveComputable = { [K in keyof T]: T[K] extends object ? RecursiveComputable : T[K] | ((arg: Root) => T[K]); }; declare type Computable = RecursiveComputable; declare class ComputedBackend extends StaticBackend { constructor(data: Computable); } declare class NullBackend extends AbstractBackend { getSnapshot, T extends GetValueFromKeyPath>(keyPath: KP, defaultValue: T): T; } declare const createFlags: () => { FlagBackendProvider: React.FC; }>>; Flag: { >>(props: { keyPath: K; defaultValue: GetValueFromKeyPathString; render(value: GetValueFromKeyPathString): React.ReactNode; fallback?(): React.ReactNode; }): JSX.Element; >(props: { keyPath: KP; defaultValue: GetValueFromKeyPath; render(value: GetValueFromKeyPath): React.ReactNode; fallback?(): React.ReactNode; }): JSX.Element; displayName: string; }; useFlag: { >>(keyPath: K_1, defaultValue: GetValueFromKeyPathString): GetValueFromKeyPathString; >(keyPath: KP_1, defaultValue: GetValueFromKeyPath): GetValueFromKeyPath; }; }; declare type KeyPath_ = KeyPath; declare type KeyPathString_ = KeyPathString; declare type GetValueFromKeyPath_> = GetValueFromKeyPath; declare type GetValueFromKeyPathString_> = GetValueFromKeyPathString; declare type ExternalStore_ = ExternalStore; declare type Backend_ = Backend; declare type AsyncMutableRefObject_ = AsyncMutableRefObject; declare module Types { type KeyPath = KeyPath_; type KeyPathString = KeyPathString_; type GetValueFromKeyPath> = GetValueFromKeyPath_; type GetValueFromKeyPathString> = GetValueFromKeyPathString_; type ExternalStore = ExternalStore_; type Backend = Backend_; type AsyncMutableRefObject = AsyncMutableRefObject_; } export { AbstractBackend, AlwaysBackend, ComputedBackend, NullBackend, StaticBackend, Types, createFlags };