import { optional, record } from '@synnaxlabs/x'; import { FC, PropsWithChildren } from 'react'; export interface ProviderProps extends PropsWithChildren { value: K; } /** * Hook is a hook whose key argument has been made optional by {@link Instance.bindHook}. * The key is resolved from the surrounding scope unless overridden. If the hook has no * arguments other than the key, it may be called with no arguments at all. */ export type Hook, R> = optional.Arg, R>; /** Instance is a created scope: a Provider plus hooks bound to a single key type. */ export interface Instance { /** Provider sets the active key for all descendants. */ Provider: FC>; /** * use resolves the active key. An explicitly passed override takes precedence over * the surrounding scope. It throws if neither an override nor a Provider is present. */ use: (override?: K) => K; /** useOptional behaves like use but returns undefined instead of throwing. */ useOptional: (override?: K) => K | undefined; /** * require narrows an already-resolved key, throwing if it is nullish. Use inside a * callback to enforce a key where the use hook cannot be called. */ require: (key: K | undefined) => K; /** * bindHook lifts a hook that requires a key into one whose key is optional, sourcing * it from the surrounding scope. All non-key arguments are forwarded unchanged. */ bindHook: , R>(hook: (args: Args) => R) => Hook; } /** * create mints a typed scope: a Provider that publishes an active key and hooks that * read it. Call once per domain so each scope carries its own branded key type and * nests independently of other domains. * @param name identifies the scope in error messages and the context display name. */ export declare const create: (name: string) => Instance; //# sourceMappingURL=scope.d.ts.map