import { i as BirpcReturn, t as BirpcFn } from "../index-BKu9BxcT.mjs"; import { C as RpcFunctionType, E as Thenable, S as RpcFunctionSetupResult, T as RpcReturnSchema, _ as RpcFunctionDefinitionAnyWithContext, a as RpcDefinitionsToFunctionsWithNamespace, b as RpcFunctionDefinitionWithSchemas, c as RpcDumpCollectionOptions, d as RpcDumpRecord, f as RpcDumpRecordError, g as RpcFunctionDefinitionAny, h as RpcFunctionDefinition, i as RpcDefinitionsToFunctions, l as RpcDumpDefinition, m as RpcFunctionAgentOptions, n as RpcArgsSchema, o as RpcDump, p as RpcDumpStore, r as RpcDefinitionsFilter, s as RpcDumpClientOptions, t as EntriesToObject, u as RpcDumpGetter, v as RpcFunctionDefinitionBase, w as RpcFunctionsCollector, x as RpcFunctionDefinitionWithoutSchemas, y as RpcFunctionDefinitionToFunction } from "../types-KZOyhez5.mjs"; export interface RpcCacheOptions { functions: string[]; keySerializer?: (args: unknown[]) => string; } /** * @experimental API is expected to change. */ export declare class RpcCacheManager { private cacheMap; private options; private keySerializer; constructor(options: RpcCacheOptions); updateOptions(options: Partial): void; cached(m: string, a: unknown[]): T | undefined; has(m: string, a: unknown[]): boolean; apply(req: { m: string; a: unknown[]; }, res: unknown): void; validate(m: string): boolean; clear(fn?: string): void; } export declare class RpcFunctionsCollectorBase, SetupContext> implements RpcFunctionsCollector { readonly context: SetupContext; readonly definitions: Map>; readonly functions: LocalFunctions; private readonly _onChanged; constructor(context: SetupContext); register(fnDef: RpcFunctionDefinition, force?: boolean): void; update(fn: RpcFunctionDefinition, force?: boolean): void; onChanged(fn: (id?: string) => void): () => void; getHandler(name: T): Promise; getSchema(name: T): { args: RpcArgsSchema | undefined; returns: RpcReturnSchema | undefined; }; has(name: string): boolean; get(name: string): RpcFunctionDefinition | undefined; list(): string[]; } export declare function defineRpcFunction(definition: RpcFunctionDefinition): RpcFunctionDefinition; export declare function createDefineWrapperWithContext(): (definition: RpcFunctionDefinition) => RpcFunctionDefinition; export declare function getRpcResolvedSetupResult(definition: RpcFunctionDefinition, context: CONTEXT): Promise>; export declare function getRpcHandler(definition: RpcFunctionDefinition, context: CONTEXT): Promise<(...args: ARGS) => RETURN>; /** * Wire format used by the live RPC transports (WebSocket and SSE). * * - **JSON (default, unprefixed):** payload is plain JSON text. Used when * the dispatched method is declared `jsonSerializable: true`. Encoded * via {@link strictJsonStringify} (rejects non-JSON values), decoded * via `JSON.parse`. * - **Structured-clone (`s:` prefix):** payload is `s:` followed by * `structured-clone-es` text. Used when the method is declared * `jsonSerializable: false` (or omitted, the default). Round-trips * `Map`, `Set`, `Date`, `BigInt`, cycles, and class instances. * * birpc envelopes always start with `{`, so a leading byte that is not * `s` is unambiguously JSON. Each direction independently chooses its * encoding from local definitions; request and response are not * coupled by a mirror rule. */ export declare const STRUCTURED_CLONE_PREFIX = "s:"; /** * `JSON.stringify` with a single-pass strict replacer. * * Throws `DF0020` synchronously when the value contains a type JSON * cannot round-trip losslessly: `Map`, `Set`, `Date`, `BigInt`, class * instances, or `undefined` inside an array (silently becomes `null`). * * Native pass-throughs (no extra work needed): * - circular references: `JSON.stringify` raises `TypeError`. * - `BigInt` at top level: caught here for a friendlier error path. * * Lenient cases (allowed without throwing): * - `undefined` as an object property: legitimate optional field; * JSON.stringify just omits it. * - `undefined` at the root: legitimate "action returned nothing". * - `Symbol` / `Function` values: semantically "drop me" in JSON. * * `fnName` is used only for the diagnostic message; pass the RPC * function name when calling from a wire serializer / dump writer so * the error points at the offending function. */ export declare function strictJsonStringify(value: unknown, fnName?: string): string; /** * Validate positional arguments against their declared schemas. Only * indices with a schema are checked; extra arguments pass through * untouched. Throws `DF0038` on the first failing argument. * * Validation guards the payload without rewriting it: the original values * are handed to the handler unchanged, so a schema that describes a subset * of an object never silently strips the sender's extra fields (and any * declared transforms stay a purely type-level concern). * * @internal */ export declare function validateRpcArgs(name: string, argsSchema: RpcArgsSchema | undefined, args: readonly unknown[]): Promise; /** * Validate a handler's resolved return value against its declared schema. * Throws `DF0039` when the value fails the schema, otherwise returns the * original value unchanged (guard-only, never rewriting the payload; see * {@link validateRpcArgs}). Passes through when no return schema is set. * * @internal */ export declare function validateRpcReturn(name: string, returnSchema: RpcReturnSchema | undefined, value: unknown): Promise; /** * Validates RPC function definitions. * Action and event functions cannot have dumps (side effects should not be cached). * * @throws {Error} If an action or event function has a dump configuration */ export declare function validateDefinitions(definitions: readonly RpcFunctionDefinitionAny[]): void; /** * Validates a single RPC function definition. * * @throws {Error} If an action or event function has a dump configuration */ export declare function validateDefinition(definition: RpcFunctionDefinitionAny): void; export { type BirpcFn, type BirpcReturn, EntriesToObject, RpcArgsSchema, RpcDefinitionsFilter, RpcDefinitionsToFunctions, RpcDefinitionsToFunctionsWithNamespace, RpcDump, RpcDumpClientOptions, RpcDumpCollectionOptions, RpcDumpDefinition, RpcDumpGetter, RpcDumpRecord, RpcDumpRecordError, RpcDumpStore, RpcFunctionAgentOptions, RpcFunctionDefinition, RpcFunctionDefinitionAny, RpcFunctionDefinitionAnyWithContext, RpcFunctionDefinitionBase, RpcFunctionDefinitionToFunction, RpcFunctionDefinitionWithSchemas, RpcFunctionDefinitionWithoutSchemas, RpcFunctionSetupResult, RpcFunctionType, RpcFunctionsCollector, RpcReturnSchema, Thenable };