import { StartContext, ValueContext, NullValueContext, BooleanValueContext, StringValueContext, NumberValueContext, ArrayValueContext, ObjectValueContext, TypeInstanceValueContext, ObjectContext, PairContext, KeyContext, ArrayContext, TypeInstanceContext, BooleanContext, ScalarTypeInstanceContext, ObjectTypeInstanceContext, IdentifierContext, StringKeyContext } from "./grammar/TASONParser"; import type TASONTypeRegistry from "./TASONTypeRegistry"; import { TASONSerializerOptions } from "./TASONSerializerOptions"; import type { RuntimeSchemaAdapter } from "./schema/RuntimeSchemaAdapter"; type ParseExpected = (abstract new (...args: any[]) => any) | string; /** * 反序列化 Visitor。 * 有 schema 时的结构 walk 对齐 C# `TasonVisitor_Typed`: * - `FillObjectMembers` → {@link ObjectWithSchema} / {@link mapObjectBagWithSchema} * - `TypedArray` / `TypedValueContext` 元素期望类型 → {@link mapValueWithSchema} */ export declare class TASONVisitor { private registry; private options; /** * ObjectTypeInstance 嵌套深度。 * >0 且 handling 为 object-fallback-all、无字段契约时,保留数值包装。 */ private objectTypeDepth; /** * parseAs 传入的期望类型;仅消费根 TypeInstance,嵌套仍走 getDefaultType。 */ private expected; constructor(registry: TASONTypeRegistry, options: Required); visit(ctx: StartContext): any; /** * 指定类型反序列化入口。根 TypeInstance 用 expected 选型;无匹配抛错。 */ visitAs(ctx: StartContext, expected: ParseExpected): any; Start(ctx: StartContext): any; Value(ctx: ValueContext): any; ObjectValue(ctx: ObjectValueContext): Record; Object(ctx: ObjectContext): Record; /** * 带 schema 的 object 解析:先无类型解析 bag,再按字段契约递归映射 *(C# `FillObjectMembers` + `TypedValueContext`)。 */ ObjectWithSchema(ctx: ObjectContext, schema: unknown, adapter: RuntimeSchemaAdapter): Record; /** * 对已解析的 plain object bag 按 schema entries 递归收值。 */ private mapObjectBagWithSchema; /** * 单值按 schema 递归映射(C# `TypedValueContext`)。 * array → 元素 schema 只内省一次,大数组热路径只做数值转换; * 嵌套 plain object → entries;叶子 → mapTypeInstanceToRuntime。 */ private mapValueWithSchema; /** 可直接 mapTypeInstanceToRuntime 的叶子 kind(非结构) */ private isLeafRuntimeType; /** null-prototype 或 Object.prototype 的 bag 视为 plain object */ private isPlainObject; Pair(ctx: PairContext): { key: string; value: any; }; Key(ctx: KeyContext): string; Identifier(ctx: IdentifierContext): string; ArrayValue(ctx: ArrayValueContext): any[]; Array(ctx: ArrayContext): any[]; StringValue(ctx: StringValueContext | StringKeyContext): string; NumberValue(ctx: NumberValueContext): number; BooleanValue(ctx: BooleanValueContext): boolean; Boolean(ctx: BooleanContext): boolean; NullValue(ctx: NullValueContext): null; TypeInstanceValue(ctx: TypeInstanceValueContext): unknown; TypeInstance(ctx: TypeInstanceContext): unknown; ScalarTypeInstance(ctx: ScalarTypeInstanceContext): unknown; ObjectTypeInstance(ctx: ObjectTypeInstanceContext): unknown; /** * 解析 TypeInstance 所用 TypeInfo。 * 自动 parse:getDefaultType。 * parseAs:仅根节点消费 expected(ctor → getTypeInfoByCtor;TypeName → 默认实现,须同 entry / 别名)。 */ private resolveTypeInfo; private finishInstance; /** * 是否走 schema 契约收值。 * - object-fallback-native / object-fallback-all:有契约 → RuntimeType * - native / all:不走契约 */ private shouldApplySchemaContract; private getTextValue; } export {};