/** * @license * Copyright 2022-2026 Matter.js Authors * SPDX-License-Identifier: Apache-2.0 */ import { ElementTag, Specification } from "../common/index.js"; import { AnyElement } from "../elements/index.js"; import { Model } from "../models/index.js"; /** * This is a map of equivalent models keyed by "source name". The source name is a string that identifies the source of * the variant, such as "chip", "spec" or "local". */ export type VariantMap = { [sourceName: string]: Model; }; /** * Input to traverse(). */ export type TraverseMap = { [sourceName: string]: Model | AnyElement; }; /** * Supplies operational information about a set of variants. */ export interface VariantDetail { /** * The shared tag across all variants. */ tag: ElementTag; /** * The highest priority ID across all variants, if any variant has an ID. */ id?: number; /** * The canonical name to use for the variants. */ name: string; /** * The actual variants. */ map: VariantMap; } /** * Visits multiple model hierarchies simultaneously and builds state. */ export declare abstract class ModelVariantTraversal { private revision; private sourceNames; protected clusterState: ClusterState | undefined; private visiting; private modelTraversal; /** * Create a new visitor. Must list the valid names of sources. The order of this list implies the priority used * for choosing a name when multiple model variants have different names. */ constructor(revision: Specification.Revision, sourceNames: string[]); /** * Initiate traversal. The class is stateful so this call should not be invoked while traversal is ongoing. */ traverse(variants: TraverseMap): S; /** * This is the primary callback. It is invoked for every set of variants during traversal. It may optionally * return state that is returned from traverse(). * * @param variants the set of equivalent models * @param recurse call this function to recurse into variant children */ protected abstract visit(variants: VariantDetail, recurse: () => S[]): S; /** * Get the canonical name for a model. Within cluster scope alternate names may be selected, otherwise the name of * the model is returned. */ protected getCanonicalName(model: Model): string; /** * Determine if we are entering a cluster and install cluster state if so. */ protected enterCluster(variants: VariantDetail): boolean; /** * This is the function that actually recurses during the visit. */ private visitVariants; /** * Group children across variants with the same identity. */ private mapChildren; /** * Group children across variants with the same identity allowing for multiple definitions of an identity. This is * the primary function of {@link mapChildren} but allows for multiple definitions of the same element. */ private mapChildrenToMultimap; /** * Create a VariantDetail from a VariantMap. */ private createVariantDetail; } /** * Map of Model -> name */ type NameMapping = Map; /** * This type manages state that changes when we enter a cluster. */ type ClusterState = { canonicalNames: NameMapping; }; export {}; //# sourceMappingURL=ModelVariantTraversal.d.ts.map