/** * @license * Copyright 2022-2026 Matter.js Authors * SPDX-License-Identifier: Apache-2.0 */ import { Bytes, Merge } from "@matter/general"; import { Schema } from "./Schema.js"; declare const enum BitRangeType { Flag = 0, Number = 1, Enum = 2 } type BitRange = { type: TType; offset: number; length: number; _type?: T; }; declare const BitRange: (type: TType, offset: number, length: number) => BitRange; /** Defines the bit position of a boolean flag. */ export type BitFlag = BitRange; export declare const BitFlag: (offset: number) => BitFlag; /** Defines the bit position and bit length of a numeric value. */ export type BitField = BitRange; export declare const BitField: (offset: number, length: number) => BitField; /** Defines the bit position and bit length of an enum flag. */ export type BitFieldEnum = BitRange; export declare const BitFieldEnum: (offset: number, length: number) => BitFieldEnum; export type BitSchema = { [key: string]: BitFlag | BitField | BitFieldEnum; }; export type TypeFromBitSchema = { [K in keyof T]: T[K] extends BitFieldEnum ? E : T[K] extends BitField ? number : boolean; }; export type TypeFromPartialBitSchema = { [K in keyof T]?: T[K] extends BitFieldEnum ? E : T[K] extends BitField ? number : boolean; }; export type TypeFromBitmapSchema> = S extends Schema ? T : never; export declare class BitmapSchemaInternal extends Schema, number> { private readonly bitSchemas; private readonly masks; constructor(bitSchemas: T); /** * Allow to use a fully defined Bitmap schema as input, but also allow one where only the entries of bits set are * provided, rest is unset. */ encode(value: TypeFromPartialBitSchema): number; encodeInternal(value: TypeFromPartialBitSchema): number; decodeInternal(bitmap: number): TypeFromBitSchema; } export declare class ByteArrayBitmapSchemaInternal extends Schema> { private readonly bitSchemas; private readonly byteArrayLength; private readonly maskOffset; constructor(bitSchemas: T); encodeInternal(value: TypeFromBitSchema): Uint8Array; decodeInternal(data: Bytes): TypeFromBitSchema; } /** Create a partial bitmap from a flag sequence */ export type FlagsToBitmap = { [name in Uncapitalize]: true; }; /** Create a type with specified bit flags set */ export type BitFlags>[]> = Merge<{ [key in keyof T]: false; }, FlagsToBitmap>; /** Create a bitmap schema with a named subset of flags set */ export declare function BitFlags>[]>(bitSchemas: T, ...flags: [...F]): BitFlags; /** Create a full bitmap schema from a partial bitmap schema */ export declare function BitsFromPartial>(schema: S, bits: P): TypeFromBitSchema; /** Declares a bitmap schema by indicating the bit position and their names. */ export declare const BitmapSchema: (bitSchemas: T) => BitmapSchemaInternal; /** Declares a bitmap schema backed by a ByteArray by indicating the bit position and their names. */ export declare const ByteArrayBitmapSchema: (bitSchemas: T) => ByteArrayBitmapSchemaInternal; export {}; //# sourceMappingURL=BitmapSchema.d.ts.map