/** * @license * Copyright 2022-2026 Matter.js Authors * SPDX-License-Identifier: Apache-2.0 */ import type { ClusterType, ClusterTyping } from "@matter/types"; /** * @see {@link ClusterTyping} */ export type ClusterInterface = ClusterTyping; export namespace ClusterInterface { export const Empty: ClusterInterface = {}; export type Empty = ClusterInterface; export type Component = ClusterType.Component; export type InterfaceOf = B extends { Interface: infer I extends ClusterInterface } ? I : ClusterInterface; export type MethodsOf = InterfaceMethodsOf>; /** * All methods from all components, regardless of feature selection. */ export type AllMethodsOf = ClusterInterface extends I ? {} : AppliedMethodsOf>; export type ComponentsOf = I extends { Components: infer C extends Component[]; } ? C : []; export type InterfaceMethodsOf = ClusterInterface extends I ? {} : AppliedMethodsOf, S>>; export type AppliedMethodsOf = CA extends [ infer C extends Component, ...infer R extends Component[], ] ? (C extends { commands: infer M } ? M : {}) & AppliedMethodsOf : {}; export type ApplicableComponents = CA extends [ infer C extends Component, ...infer R extends Component[], ] ? S extends C["flags"] ? [C, ...ApplicableComponents] : ApplicableComponents : []; }