import { Animation, Stream } from './animation/index'; import { Behavior, ConstructorForBehavior } from './behavior'; import { Component, ComponentChildren, ConstructorForComponent, ConstructorProps } from './component'; import { ContextManager, Context } from './context'; import { Entity } from './entity'; import { ZComponentData } from './data/core'; export interface ZComponentOptions { data: ZComponentData; importMapping: { [id: string]: () => any; }; propReplacement: { [id: string]: { [id: string]: any; }; }; constructorPropReplacement: { [id: string]: { [id: string]: any; }; }; onConstructingNode?: (id: string | undefined) => void; } export interface ZComponentContextConstructorProps { zcomponent: ZComponent; children: ComponentChildren; } export declare class ZComponentContext extends Context { zcomponent: ZComponent; children: ComponentChildren; /** * Creates an instance of ZComponentContext. * @param contextManager - The current ContextManager * @param props - The constructor properties. */ constructor(contextManager: ContextManager, props: ZComponentContextConstructorProps); } export declare class ZComponent extends Component { constructorProps: ConstructorProps; private _opts; /** * The id of the component. */ id: string; /** * A map of elements to node IDs. */ idByElement: Map; /** * Object that maps node script names to scripts. */ nodes: { [id: string]: Component | Component[]; }; /** * Map of entites by ID. */ entityByID: Map; /** * A map of entity labels to components. */ entityByLabel: Map; /** * A map of node labels to components. */ nodeByLabel: Map>; private _constructedResolve; /** * A promise that is resolved once construction of this component is complete. */ constructed: Promise; /** * A boolean indicating if construction of this component is complete. */ isConstructed: boolean; /** * The animation object for this component. */ animation: Animation; /** * @zstreams layerclipids */ streams: { [id: string]: Stream; }; private _nodesById; private _behaviorsToInitialize; private _constructorPropOverridesByEntityID; /** * Creates an instance of ZComponent. * @param contextManager - The current ContextManager * @param constructorProps - The constructor properties. * @param _opts - The options for the component. */ constructor(contextManager: ContextManager, constructorProps: ConstructorProps, _opts: ZComponentOptions); private _updateAnimationRegistrations; private _animationTick; private _constructorForNode; private _constructorForBehavior; /** * This function returns the component with the given ID. If the component is not found, it will return undefined. * This function is used to get a component from a node ID, which is a string representation of a node. * The node ID is used to identify a node in the graph. * If a component constructor is passed as `type`, this function will ensure that the node that's returned * is an instance of that component, or return undefined if it is not. */ resolveNodeID(id: string, type?: ConstructorForComponent): T | undefined; /** * This function returns the behavior with the given ID. If the behavior is not found, it will return undefined. * This function is used to get a behavior from a behavior ID, which is a string representation of a behavior. */ resolveBehaviorID(id: string, type?: ConstructorForBehavior): T | undefined; /** * Resolves an entity ID to an entity instance. * * @param id - The ID of the entity to resolve. * @returns The resolved entity as an instance of T (which extends Entity), or undefined if the entity could not be resolved. * @template T The entity type. */ resolveEntityID(id: string): T | undefined; private _inflateBehaviors; private _wrapBehaviors; private _wrapFunctionCall; /** * Notifies the component that the properties of certain entities have changed. * * @param entries - A map where the keys are entity IDs and the values are sets of property names. */ notifyPropsChanged(entries: Map>): void; /** * The animation editor will call this function when the user changes * the list of clips in the animation. We need to update the clip * data for each clip that was changed. */ notifyClipsChanged(clips: Set): void; private _initializeOverrides; private _initializeConstructorPropOverrides; private _initializeComponentProps; private _setEntityProp; private _setEntityPropPath; /** * Returns the node with the specified ID. */ _getNodeById(id: string): Component | undefined; /** * Rsolves a stream ID to a stream object. The stream ID is a string that * is constructed from the entity ID of the stream's parent entity, followed by a * period, followed by the name of the stream. This function splits the string into * parts, and then uses the parts to traverse the entity tree until it finds the * named stream. */ resolveStreamID(id: string): Stream | undefined; /** * Traverses the component tree starting from the current component, * moving down the tree using either Breadth-First Search (BFS) or Depth-First Search (DFS), * and invokes the given callback function on each component. * * Breadth-first chosen for traversal can be specifying `true` for the second parameter * * Example usage: * ``` * component.traverse((comp) => { * // Your logic here, e.g. * console.log(comp.name); * }, true); * ``` * * @param callback A function that will be called for each component in the traversal. The current component is passed as a parameter to the callback. * @param breadthFirst If traversal should be breadth-first. Defaults to `false` (depth-first). */ traverse(callback: (comp: Component) => void, breadthFirst?: boolean): void; private _traverseBFS; private _traverseDFS; dispose(): never; }