import { Gindex, Node, Tree } from "@chainsafe/persistent-merkle-tree"; import { Type, ValueOf } from "../type/abstract.ts"; import { BasicType } from "../type/basic.ts"; import { CompositeType } from "../type/composite.ts"; import { NonOptionalFields, OptionalType } from "../type/optional.ts"; import { BitArray } from "../value/bitArray.ts"; import { TreeView } from "./abstract.ts"; export type FieldEntry>> = { fieldName: keyof Fields; fieldType: Fields[keyof Fields]; jsonKey: string; gindex: Gindex; optional: boolean; }; /** Expected API of this View's type. This interface allows to break a recursive dependency between types and views */ export type StableContainerTypeGeneric>> = CompositeType, ContainerTreeViewType, unknown> & { readonly fields: Fields; readonly fieldsEntries: FieldEntry>[]; tree_getActiveFields: (node: Node) => BitArray; tree_setActiveFields: (node: Node, activeFields: BitArray) => Node; tree_getActiveField: (node: Node, fieldIndex: number) => boolean; tree_setActiveField: (node: Node, fieldIndex: number, value: boolean) => Node; }; export type ValueOfFields>> = { [K in keyof Fields]: ValueOf; }; export type ViewType> = T extends CompositeType ? TV : T extends BasicType ? V : never; export type OptionalViewType> = T extends CompositeType ? // If composite, return view. MAY propagate changes updwards if not nullish TV | null | undefined : T extends BasicType ? V | null | undefined : never; export type FieldsView>> = { [K in keyof Fields]: Fields[K] extends OptionalType ? OptionalViewType : ViewType; }; export type ContainerTreeViewType>> = FieldsView & TreeView>; export type ContainerTreeViewTypeConstructor>> = { new (type: StableContainerTypeGeneric, tree: Tree): ContainerTreeViewType; }; export declare function getContainerTreeViewClass>>(type: StableContainerTypeGeneric): ContainerTreeViewTypeConstructor; type BytesRange = { start: number; end: number; }; /** * Precompute fixed and variable offsets position for faster deserialization. * @throws when activeFields does not align with non-optional field types * @returns Does a single pass over all fields and returns: * - isFixedLen: If field index [i] is fixed length * - fieldRangesFixedLen: For fields with fixed length, their range of bytes * - variableOffsetsPosition: Position of the 4 bytes offset for variable size fields * - fixedEnd: End of the fixed size range * - */ export declare function computeSerdesData>>(activeFields: BitArray, fields: FieldEntry[]): { isFixedLen: boolean[]; fieldRangesFixedLen: BytesRange[]; variableOffsetsPosition: number[]; fixedEnd: number; }; export {};